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-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!proxad.net!193.252.118.146.MISMATCH!news.wanadoo.fr!news.wanadoo.fr!not-for-mail Sender: obry@PASCAL Newsgroups: comp.lang.ada Subject: Re: Teaching new tricks to an old dog (C++ -->Ada) 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> <422f2de1$0$181$afc38c87@> From: Pascal Obry Date: 09 Mar 2005 18:40:47 +0100 Message-ID: Organization: Home - http://www.obry.net User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Date: 09 Mar 2005 18:40:48 CET NNTP-Posting-Host: 82.120.30.69 X-Trace: 1110390048 news.wanadoo.fr 1219 82.120.30.69:2818 X-Complaints-To: abuse@wanadoo.fr Xref: g2news1.google.com comp.lang.ada:8955 Date: 2005-03-09T18:40:48+01:00 List-Id: Hyman Rosen writes: > Keeping in mind that all template instantiations in C++ > are static and done at compile time, the answer is yes. > Here's a little example. Hard to understand. This looks like a template which instanciate other templates. No recusive definitions here. > #include > #include > #include > > struct NIL { }; type Nil is null record; > template struct CONS { }; generic type HEAD is private; type TAIL is private; package CONS_PKG is type CONS is null record; end CONS_PKG; > template struct x; generic type T is private; package X_PKG is type X is null record; end X_PKG; > template <> struct x { static void f() { } }; generic package X_NIL_PKG is type X_NIL is new X_PKG (Nil); procedure f; end X_NIL_PKG; > template struct x< CONS > > { > static void f() > { > std::cout << typeid(HEAD).name() << "\n"; > x::f(); > } > }; generic type HEAD is private; type TAIL is private; package X_CON_PKG is package CONS_HT is new CONS_PKG (HEAD, TAIL); package X_CONS is new X_PKG (CONS_HT.CONS); procedure F; end X_NIL_PKG; > int main() > { > x< CONS > > > >::f(); > } My C++ is a bit rusty, let me know if I got something wrong... Pascal. -- --|------------------------------------------------------ --| Pascal Obry Team-Ada Member --| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE --|------------------------------------------------------ --| http://www.obry.org --| "The best way to travel is by means of imagination" --| --| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595