220 9830 <87y50a8tr4.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:53:03 -0700
Organization: axiomatics.org
Lines: 84
Approved: news@gmane.org
Message-ID: <87y50a8tr4.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>
	<CANu6V4X36vs+s5f3A_rQoKSyKuGBZtiJNkK44oVNWod=Z-jdMw@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 1394956378 22814 80.91.229.3 (16 Mar 2014 07:52:58 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sun, 16 Mar 2014 07:52:58 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCSYNQUB2UHRBYFQSWMQKGQELJPRY6A@isocpp.org Sun Mar 16 08:53:08 2014
Return-path: <std-proposals+bncBCSYNQUB2UHRBYFQSWMQKGQELJPRY6A@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ob0-f199.google.com ([209.85.214.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCSYNQUB2UHRBYFQSWMQKGQELJPRY6A@isocpp.org>)
	id 1WP5sY-0000uS-9q
	for gclcip-std-proposals@m.gmane.org; Sun, 16 Mar 2014 08:53:06 +0100
Original-Received: by mail-ob0-f199.google.com with SMTP id wo20sf17086339obc.10
        for <gclcip-std-proposals@m.gmane.org>; Sun, 16 Mar 2014 00:53:05 -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=oxzcBcMI6Es4ey2c4+rUuC1zlNfX/WhQaim22bzQ2NE=;
        b=HmWyRixs1tKYHd2WCwpm2C/LabmXe40XeltntQYL7v/DthIfaBkvytvHLd3Evw8iGV
         XL7UtXZhByIOOw6IW1pslgw0dfUGbeDH1cO1hAf0tD7onDLqr0a9ZHQL4qtr5SvOHn0L
         lKV+RypkA14T1vFS/44xoW3avVKuXsWs45Y9Mmz9sqb8kQFanL3rbVaSFG0Gkw5c7ObJ
         IUcV4Hgxk4pJEAamsrpbl+2GBI9dhBdiMVMF1MeZzys5JCV6kYwRhtLDHC/eNjA277aH
         fViYKjLTMuB3q1PfTnRcRklNjBeKQtXCHq3JYP1ftz/nkf5zaAepK7eZ+vr92SttT6u2
         Dqfw==
X-Gm-Message-State: ALoCoQk4LT6M6s8kAi4ZDlqEW7wzWVZymLyI/9FaLIy2/r6LGCMJhKf2Rl3rytVj17u28WilUsgR
X-Received: by 10.42.53.135 with SMTP id n7mr6379842icg.11.1394956385387;
        Sun, 16 Mar 2014 00:53:05 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.182.55.9 with SMTP id n9ls500133obp.49.gmail; Sun, 16 Mar 2014
 00:53:04 -0700 (PDT)
X-Received: by 10.60.15.131 with SMTP id x3mr15197272oec.15.1394956384488;
        Sun, 16 Mar 2014 00:53:04 -0700 (PDT)
Original-Received: from mail.axiomatics.org ([2600:3c00::f03c:91ff:feae:e0e6])
        by mx.google.com with ESMTP id jb8si7999880obb.91.2014.03.16.00.53.04
        for <std-proposals@isocpp.org>;
        Sun, 16 Mar 2014 00:53:04 -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 352FCE70D
	for <std-proposals@isocpp.org>; Sun, 16 Mar 2014 00:53:04 -0700 (PDT)
In-Reply-To: <CANu6V4X36vs+s5f3A_rQoKSyKuGBZtiJNkK44oVNWod=Z-jdMw@mail.gmail.com>
	(Johannes Schaub's message of "Sun, 16 Mar 2014 01:53:52 +0100")
Original-Sender: gdr@axiomatics.org
Original-Lines: 75
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:9830
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/9830>

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."
| >
| 
| It's also not clear to me where to draw the line. Consider
| 
| class Y {
|   typedef int type;
| };
| 
| template<Y::type N>
| struct X { };
| 
| The specialization of this template does not have template parameters,

I don't understand why this particular observation is important.  Could
you elaborate?

| since it's a normal class. A diangostic should therefor not be
| generated for the class template, since the specialization is valid.
| However, clang complains
| 
| "main.cpp:5:13: error: 'type' is a private member of 'Y'"

The issue here is different: it is the declaration itself that is invalid
in the sense that the declaration of the template (regardless of whether
it can have a specialization) uses an inaccessible name.

-- 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/.

.
