220 9829 <878usaa8hz.fsf@euclid.axiomatics.org> article
Path: news.gmane.org!not-for-mail
From: Gabriel Dos Reis <gdr@axiomatics.org>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: auto variable templates?
Date: Sun, 16 Mar 2014 00:49:12 -0700
Organization: axiomatics.org
Lines: 84
Approved: news@gmane.org
Message-ID: <878usaa8hz.fsf@euclid.axiomatics.org>
References: <ec829ec4-9d4e-4d5c-8673-a58d46fec41b@isocpp.org>
	<CAOfiQqkf4N3Pga8V7n6as-CBdWWGJeKh-0s8ONxsdpRtamo-Cg@mail.gmail.com>
	<CANu6V4ViH09LeqDs_Vc2tivK97=6yThejGLJ6+m0dRx0Fu+vRQ@mail.gmail.com>
	<CAOfiQq=-DRrjX2sAxpqPhhorg4ARW9q4vNA=D5k7wHzikjMiBg@mail.gmail.com>
	<CANu6V4WZWY0+EWY=1_UWN1Yi8202mwCdiQQiLhY-hGFLCtAR6g@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
X-Trace: ger.gmane.org 1394956145 20510 80.91.229.3 (16 Mar 2014 07:49:05 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sun, 16 Mar 2014 07:49:05 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCSYNQUB2UHRB6NOSWMQKGQEYMHLPWY@isocpp.org Sun Mar 16 08:49:15 2014
Return-path: <std-proposals+bncBCSYNQUB2UHRB6NOSWMQKGQEYMHLPWY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pd0-f197.google.com ([209.85.192.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCSYNQUB2UHRB6NOSWMQKGQEYMHLPWY@isocpp.org>)
	id 1WP5oo-0005XJ-Q4
	for gclcip-std-proposals@m.gmane.org; Sun, 16 Mar 2014 08:49:15 +0100
Original-Received: by mail-pd0-f197.google.com with SMTP id fp1sf10337672pdb.0
        for <gclcip-std-proposals@m.gmane.org>; Sun, 16 Mar 2014 00:49:13 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:to:subject:in-reply-to:organization
         :references:sender:date:message-id:lines:mime-version
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=BbjFzI4E088VNTB5uDrZsJvPPTJPjqTfmj5n/WwRb3Q=;
        b=e7VEnWnziWNDL7i9vro3GWlhDnhQSrpkGgKruFmWj9sNP0l/9WkDVxKabuHDTNknwk
         nvmBJkMQJGXjsGCVuOmdgz20EaMrnyhVGF67D0/sqSlRi36R55saj5A5bSIhKT1lGfOT
         bLTPF4+O7kjuGH2q1x3nzsqOWDjyZlPoG6OlWunxFVYGzNuGcYE9BrSOmZ4WcuXCmIJP
         noTJxVmCLi8vd6NoAfK2P9QTf6V8TfskijMvotFNS00yEvXyX/99b6Xng484K8t9X65v
         +uwT/A298lyETq/tFdENuqvRBnMiuuPuHsNIqvDRwCmbiG5eUXkkYC61fN18kzV/YXcT
         ulaw==
X-Gm-Message-State: ALoCoQmes9CrjpteRAvjaF/oGrl+Dfi1eKaBblsWUI6JW/LICcvnoxtiuS27OGe2u9tMxsUJ9lOL
X-Received: by 10.66.253.9 with SMTP id zw9mr7639503pac.38.1394956153686;
        Sun, 16 Mar 2014 00:49:13 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.182.190.1 with SMTP id gm1ls551081obc.65.gmail; Sun, 16 Mar
 2014 00:49:12 -0700 (PDT)
X-Received: by 10.60.246.10 with SMTP id xs10mr15302354oec.18.1394956152850;
        Sun, 16 Mar 2014 00:49:12 -0700 (PDT)
Original-Received: from mail.axiomatics.org ([2600:3c00::f03c:91ff:feae:e0e6])
        by mx.google.com with ESMTP id e6si7848738oen.136.2014.03.16.00.49.12
        for <std-proposals@isocpp.org>;
        Sun, 16 Mar 2014 00:49:12 -0700 (PDT)
Received-SPF: neutral (google.com: 2600:3c00::f03c:91ff:feae:e0e6 is neither permitted nor denied by best guess record for domain of gdr@axiomatics.org) client-ip=2600:3c00::f03c:91ff:feae:e0e6;
Original-Received: from euclid.axiomatics.org (localhost [IPv6:::1])
	by mail.axiomatics.org (Postfix) with ESMTP id 919C5E70D
	for <std-proposals@isocpp.org>; Sun, 16 Mar 2014 00:49:12 -0700 (PDT)
In-Reply-To: <CANu6V4WZWY0+EWY=1_UWN1Yi8202mwCdiQQiLhY-hGFLCtAR6g@mail.gmail.com>
	(Johannes Schaub's message of "Sun, 16 Mar 2014 01:31:35 +0100")
Original-Sender: gdr@axiomatics.org
Original-Lines: 76
X-Original-Sender: gdr@axiomatics.org
X-Original-Authentication-Results: mx.google.com;       spf=neutral
 (google.com: 2600:3c00::f03c:91ff:feae:e0e6 is neither permitted nor denied
 by best guess record for domain of gdr@axiomatics.org) smtp.mail=gdr@axiomatics.org
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:9829
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/9829>

Johannes Schaub <schaub.johannes@googlemail.com> writes:

| 2014-03-16 1:17 GMT+01:00 Richard Smith <richard@metafoo.co.uk>:
| > On Sat, Mar 15, 2014 at 5:13 PM, Johannes Schaub
| > <schaub.johannes@googlemail.com> wrote:
| >>
| >> 2014-03-16 0:38 GMT+01:00 Richard Smith <richard@metafoo.co.uk>:
| >> > On Sat, Mar 15, 2014 at 1:46 PM, Andrew Tomazos
| >> > <andrewtomazos@gmail.com>
| >> > wrote:
| >> >>
| >> >> Is the following supposed to be ill-formed according to the current
| >> >> draft?
| >> >>
| >> >> template<class> constexpr auto X = 42;
| >> >>
| >> >> int main()
| >> >> {
| >> >>         static_assert(X<int> == 42, "");
| >> >> }
| >> >>
| >> >>
| >> >> [dcl.spec.auto]/4 says that auto is allowed when declaring variables in
| >> >> namespace-scope, but doesn't explicitly say in variable templates -
| >> >> consequently this is ill-formed.
| >> >
| >> >
| >> > A specialization of a variable template is a variable, so this is
| >> > allowed.
| >> >
| >>
| >> I don't understand this reason. The following is not a specialization
| >> of a variable template, is it?
| >>
| >>    template<class> constexpr auto X = 42;
| >>
| >> The Standard says in 7.1.6.4p6, "A program that uses auto or
| >> decltype(auto) in a context not explicitly allowed in this section is
| >> ill-formed."
| >>
| >> The section does not explicitly allow "auto" for variable templates.
| >> Why does it matter that the specialization of that template is a
| >> variable?
| >
| >
| > Because the validity of a template isn't governed by the usual language
| > rules. 14.6/8: "No diagnostic shall be issued for a template for which a
| > valid specialization can be generated."
| >
| 
| Thanks, I have never interpreted this sentence in that way. It just
| sounds to me as a warning to prematurely rejecting compilers. IMO a
| much better way to word this would be along the way of
| 
|    "A template that is made ill-formed by a rule not in this paragraph
| is still well-formed as long as a valid specialization can be
| generated for it."
| 
| As it is stated in the Standard, it sounds like the rule talks about
| well-formed templates only.


The general model of C++ templates, since day 1, is that if decl is a
valid declaration, then

   template <parameter-list> decl

is also a valid declaration.  There are a few exceptions (like you can't
have a non-static data member templates or virtual function templats),
but that is basically it. 

Inverting that principle gives a "formal" rule that Richard pointed out
in his previous message, although tha rules cover more grounds.

-- Gaby

-- 

--- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.
