From 3743076139506254787
X-Google-Thread: f78e5,c9a289c55d59e43d
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news2.google.com!news3.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: Wed, 12 Jul 2006 12:50:30 -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: "Richard Smith" <richard@ex-parrot.com>
Newsgroups: comp.std.c++
Subject: Re: non-type template parameter in the new std.
Organization: http://groups.google.com
Message-ID: <1152726032.559269.324790@75g2000cwc.googlegroups.com>
References: <1152697717.720355.314370@35g2000cwc.googlegroups.com>
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; Linux i686; en-US; rv:1.7.10) Gecko/20060109 Firefox/1.0.6,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: 75g2000cwc.googlegroups.com; posting-host=217.206.92.194;
   posting-account=359WWg0AAAA2-4e3vEK4vPAh3j9nKTHe
X-Virus-Scanned: amavisd-new at ucar.edu
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
Date: Wed, 12 Jul 2006 12:46:51 CST
Lines: 41
NNTP-Posting-Host: 65.182.171.162
X-Trace: sv3-Fh3mZy3wKFdoIfubcYl++h9mItcYR3YN49DnuVXDp+UqoUy15hUyuTCtruOMtoOMbEeW6m/VWu3Mvuf!L9Ceba+89qHLf5ddwMJ4padITCYnGiaLOe/oaLpc5sHPUTa+2MKBq6slGBQL78T9fx3OEZFaQfwN!BRqM5EuWpRDkJktrsvZQ4QcuiJqdFtbsh2FMq9AZ+A==
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++:2693

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.

> 2) Why is it necessary to specify the type when the type can be derived
> from the literal for nontype template arguments e.g.

I don't think there's a fundamental technical reason why not; the two
issues that spring to mind are: what would the syntax be, and did it
seem likely in the mid-1990s when the current standard was being
produced that it would be of sufficient use to merit inclusion.  As to
the latter, my guess is: no.

Regarding the syntax, there isn't anything obvious that fits with C++
idea of templates.  The name of the type needs to be in scope when the
non-type template parameter is declared, so

  template <typename T, T Min, T Max>
  struct foo {};

but then, even supposing the compiler could deduce template arguments
for structs, how would T be deduced from Min and Max?  You can't
specify Min or Max without already having specified T:

  typedef foo< /* what goes here? */, 0, 360 > angle;

--
Richard Smith

---
[ 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                      ]



