From 4944305901141055313
X-Google-Thread: f78e5,c9a289c55d59e43d
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII
Path: g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.speakeasy.net!news.speakeasy.net.POSTED!not-for-mail
NNTP-Posting-Date: Tue, 18 Jul 2006 08:20:01 -0500
Return-Path: <devnull@stump.algebra.com>
X-Authentication-Warning: mulga.csse.unimelb.edu.au: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Original-To: std-c++@mailman.ucar.edu
Delivered-To: std-c++@mailman.ucar.edu
From: "kanze" <kanze@gabi-soft.fr>
Newsgroups: comp.std.c++
Subject: Re: non-type template parameter in the new std.
Organization: http://groups.google.com
Message-ID: <1153227619.814308.53700@m73g2000cwd.googlegroups.com>
References: <1152726032.559269.324790@75g2000cwc.googlegroups.com>
   <memo.20060718092048.676A@brangdon.cix.compulink.co.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Complaints-To: groups-abuse@google.com
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.0.1) Gecko/20020920 Netscape/7.0,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: m73g2000cwd.googlegroups.com; posting-host=62.160.54.162;
   posting-account=qsfl8gwAAABZGaLp2a7FeTfDkJamzWYW
X-Virus-Scanned: amavisd-new at ucar.edu
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by mulga.csse.unimelb.edu.au id k6ID13PH006813
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
Date: Tue, 18 Jul 2006 08:18:36 CST
Lines: 89
NNTP-Posting-Host: 65.182.171.162
X-Trace: sv3-NANtF741akrJ0H4tcoAuk/qyjz57btzkPbkfBa78v/QeplEli1pELKtJqKSK8iOKf5nNHbn6GulM/p1!IgX+vNM47Rdy1pBNkZnMa0v6HmqAtpiY4GBH75xbM+UKWZiQ4CZcfuea7zCEGLYjSmzZe9tatr5/!jKtJtlahm7rv9TgrCjmuA6+hVhzV1GFoYno54tSu5Q==
X-Complaints-To: abuse@speakeasy.net
X-DMCA-Complaints-To: abuse@speakeasy.net
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.32
Xref: g2news2.google.com comp.std.c++:2819

Dave Harris wrote:
> richard@ex-parrot.com (Richard Smith) wrote (abridged):
> > werasm wrote:
> > > 1) Are floating point numbers non-type template parameters in the
> > > latest standard.

> > Not at present.  The rationale being that when cross
> > compiling, the compiler would need to exactly emulate the
> > floating point behaviour of the target processor, right down
> > to the details of rounding, handling of NaNs and infinites,
> > etc.

> Actually, as I understand it the problem is one of type
> checking.

It's definitely one of type checking.

> Given:

>     template <double v> struct X {};

>     void func( X<0.3333> ) {}
>     void func( X<1.0/3.0> ) {}

> is this two definitions of the same function that violates the
> one-definition rule, or are there two functions that take
> arguments of different types?

How is this different from:

    template< int v > struct X {} ;

    void func( X< 0 > ) {}
    void func( X< -1 & 1 > ) {}   //  Consider a 1's complement machine

or for that matter, even:

    template< typename T > struct X{} ;
    void func( x< unsigned int > ) {}
    void func( X< size_t > ) {}

> The answer depends on the precision of the floating
> point,

And with signed integers, and with type arguments in the
presence of typedef's.

> so we can't say whether the program is type-correct without
> knowing more about the implementation than we should.

> This is not really about cross-compiling. It is about *all*
> compilers being consistent, rather than one compiler emulating
> one other processor.

I don't think it's that black and white.  The issue of cross
compilation means that a compiler must fully emulate the
floating point hardware of the target platform if it is to be
consistent for that platform.  This is already true for int, of
course, but emulating 1's complement (if necessary) is a lot
easier than emulating floating point (and is already necessary
anyway---something like "#if (-1 & 1) == 0" is probably in
actual use somewhere to determine whether the target is 1's
complement or not).  Where as with floating point, on the other
hand...

It may not be just cross compilation.  On some machines 1.0/3.0
is equal to 0.33333333333333333 if the value is assigned to
memory, but not if the compiler manages to keep all of the
intermediate results in a register.

Globally, it's a thorny issue, and I think that there are a
variety of motivations behind not supporting it: some due to
cross compilation, others not.  (One possibility: allow it, but
don't allow anything but floating point literals as arguments,
and define equality as absolute equality over the real numbers.)

--
James Kanze                                           GABI Software
Conseils en informatique orient�e objet/
                   Beratung in objektorientierter Datenverarbeitung
9 place S�mard, 78210 St.-Cyr-l'�cole, France, +33 (0)1 30 23 00 34


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]



