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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d2f0af5e440b367f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-08 06:59:17 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!bigboote.WPI.EDU!news.tufts.edu!uunet!dca.uu.net!ash.uu.net!spool.news.uu.net!not-for-mail Date: Tue, 08 Jul 2003 09:59:15 -0400 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5a) Gecko/20030611 Thunderbird/0.1a X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: proposal for new assignment operators References: <3EF9CD5F.6030608@cogeco.ca> <3doRhIgUmUYX@eisner.encompasserve.org> <3F038B77.2F2E41B7@adaworks.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Organization: KBC Financial Products Message-ID: <1057672755.789189@master.nyc.kbcfp.com> Cache-Post-Path: master.nyc.kbcfp.com!unknown@nightcrawler.nyc.kbcfp.com X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) NNTP-Posting-Host: 204.253.250.10 X-Trace: 1057672755 4305 204.253.250.10 Xref: archiver1.google.com comp.lang.ada:40128 Date: 2003-07-08T09:59:15-04:00 List-Id: James Rogers wrote: > This is interesting. Not too long ago in comp.lang.c++.moderated I was > told floats cannot be used as template parameters. Was I told correctly? A "typename" template parameter must be matched by an actual argument which is a type, and this can be any type, including any primitive type. Template parameters may also be constant values rather than types, and in that case, those parameters cannot be floating point. > I was surprised when I was told that. I have wondered if it is true, and > if so, why. Template parameters are used in the linkage of instantiated templates (loosely speaking, the parameters are interpolated into the name of the instantiation), and template arguments can be constant expressions. Allowing floating-point parameters would lead to questions of equivalence of instantiations. In my opinion that's not such a terrible burden, and I would have allowed it, but the standard doesn't. Some compilers offer it as an extension. As a sample of the problem, consider template char *f() { static char c; return &c; } bool b = f<1./3.>() == f<1./6.+1./6.>(); How do you specify what the value of 'b' should be?