From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,703c4f68db81387d X-Google-Thread: 109fba,703c4f68db81387d X-Google-Thread: 115aec,703c4f68db81387d X-Google-Thread: f43e6,703c4f68db81387d X-Google-Attributes: gid103376,gid109fba,gid115aec,gidf43e6,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!easynet-monga!easynet.net!oleane.net!oleane!not-for-mail From: =?ISO-8859-1?Q?Falk_Tannh=E4user?= Newsgroups: comp.lang.ada,comp.lang.c++,comp.realtime,comp.software-eng Subject: Re: Teaching new tricks to an old dog (C++ -->Ada) Date: Wed, 09 Mar 2005 18:31:52 +0100 Organization: Canon Research Centre France Message-ID: References: <4229bad9$0$1019$afc38c87@news.optusnet.com.au> <1110032222.447846.167060@g14g2000cwa.googlegroups.com> <871xau9nlh.fsf@insalien.org> <3SjWd.103128$Vf.3969241@news000.worldonline.dk> <87r7iu85lf.fsf@insalien.org> <1110052142.832650@athnrd02> <1110284070.410136.205090@o13g2000cwo.googlegroups.com> <395uqaF5rhu2mU1@individual.net> <1110377260.350158.58730@z14g2000cwz.googlegroups.com> <422f16d2$0$1089$9b4e6d93@newsread2.arcor-online.net> NNTP-Posting-Host: centre.crf.canon.fr Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: s1.news.oleane.net 1110389500 12277 194.2.158.33 (9 Mar 2005 17:31:40 GMT) X-Complaints-To: abuse@oleane.net NNTP-Posting-Date: Wed, 9 Mar 2005 17:31:40 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041217 X-Accept-Language: de, fr, pl, en, en-us In-Reply-To: Xref: g2news1.google.com comp.lang.ada:8954 comp.lang.c++:44817 comp.realtime:1144 comp.software-eng:4702 Date: 2005-03-09T18:31:52+01:00 List-Id: Pascal Obry wrote: > Hum, since you answered "no" and I answered "yes" it seems there is something > about "templates recurse" that I did not understand. In short what is a > recursive template in C++ ? One example in C++: template struct factorial { static unsigned const value = N * factorial::value; }; // Partial template specialisation to terminate the recursion: template<> struct factorial<0> { static unsigned const value = 1; }; With this, 'factorial<7>::value' will be a compile time constant equal to 5040. Another example: template struct pointer_info { typedef T base_type; static unsigned const indir_level = 0; }; // Partial template specialisation for types that are pointers: template struct pointer_info { typedef typename pointer_info::base_type base_type; static unsigned const indir_level = pointer_info::indir_level + 1; }; With this, suppose that you have typedef int***** foo_t; Then 'pointer_info::base_type' is a typedef (alias) for 'int' and 'pointer_info::indir_level' is a compile time constant equal to 5. Falk