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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,262b74f44c7f873e X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!g47g2000cwa.googlegroups.com!not-for-mail From: matteo.bordin@gmail.com Newsgroups: comp.lang.ada Subject: Re: prohibit certain generic instantiations in Ada 2005 Date: 11 Feb 2006 00:04:44 -0800 Organization: http://groups.google.com Message-ID: <1139645084.563448.239040@g47g2000cwa.googlegroups.com> References: <1139508110.410006.28260@g14g2000cwa.googlegroups.com> <1139515341.782860.197930@f14g2000cwb.googlegroups.com> <1139581110.636535.107910@g44g2000cwa.googlegroups.com> NNTP-Posting-Host: 151.47.142.43 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1139645090 10790 127.0.0.1 (11 Feb 2006 08:04:50 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 11 Feb 2006 08:04:50 +0000 (UTC) In-Reply-To: User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.6) Gecko/20050317 Firefox/1.0.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: g47g2000cwa.googlegroups.com; posting-host=151.47.142.43; posting-account=F0PVCw0AAABbUMNt6pX6q_ZNh55rRxT7 Xref: g2news1.google.com comp.lang.ada:2855 Date: 2006-02-11T00:04:44-08:00 List-Id: I will provide a proper example in C++. With this code I can prohibit instantiation of template My_Class with T=int. class Checker{ public: static void check(float){}; private: static void check(int){}; }; template class My_Class{ public: My_Class(){ T t; Checker::check(t); } }; int main(){ My_Class mc = My_Class(); //COMPILE TIME ERROR!!!! //The error comes from the fact that Checker::check(int) is private My_Class mc2 = My_Class(); //OK!!! }; When I said that the compilation model for template of Ada is similar to C++, I meant in regards to compile-time code generation (opposed to the model of Java generics). In both languages (Ada and C++), templates can be used as a generative environment. I just want to know f here is a way to reproduce the C++ code I provided in Ada (2005). Thank you