220 8420 <35db0731-9ff9-4e8a-ae2e-29e4974b46d8@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: hun.nemethpeter@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: A new keyword for either a type or a variable
 (typical use case for variadic template template)?
Date: Mon, 6 Jan 2014 22:55:40 -0800 (PST)
Lines: 367
Approved: news@gmane.org
Message-ID: <35db0731-9ff9-4e8a-ae2e-29e4974b46d8@isocpp.org>
References: <f4ec2cca-5951-447f-a938-0b2e5e3e233f@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_1125_5269115.1389077740219"
X-Trace: ger.gmane.org 1389077739 13011 80.91.229.3 (7 Jan 2014 06:55:39 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 7 Jan 2014 06:55:39 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBD3YT6VHQYIBB3OJV2LAKGQEWAHY4ZQ@isocpp.org Tue Jan 07 07:55:46 2014
Return-path: <std-proposals+bncBD3YT6VHQYIBB3OJV2LAKGQEWAHY4ZQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pd0-f198.google.com ([209.85.192.198])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBD3YT6VHQYIBB3OJV2LAKGQEWAHY4ZQ@isocpp.org>)
	id 1W0QZi-0002cJ-Ts
	for gclcip-std-proposals@m.gmane.org; Tue, 07 Jan 2014 07:55:43 +0100
Original-Received: by mail-pd0-f198.google.com with SMTP id g10sf51441724pdj.5
        for <gclcip-std-proposals@m.gmane.org>; Mon, 06 Jan 2014 22:55:41 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe
         :content-type;
        bh=R4OT1Vg7XdYQEv0L7xpUV2k95PydE8C5sAInvsYArFk=;
        b=zBC55EK9U1pWX16wr3o915oeg7ISVoAKU2YLCJuNsltOS7TIKUMoN2SmJZclMI4JFP
         netdv1UV/cZ6MEEStiB8SQdemXXYr0ZUkiU5my9kTXAnY+CRPWj5s9uw/72diRAqVHoD
         aHzThj9Q4uB+0wIQR1zrKuqiiOBE4vxCBWcqOt4ARTh4GNmJZc/CH+bdLWOr2VYUxhFu
         AMVBiTavbvng3KcOLqxo6LwQyA+WNZ7vRoQ/9Sx1V+Kns/879mtkJ44elufCuTUQV7HS
         44iPf5bDCyKavhtl40p4NEHCzkCvI5JaQGCNwH6PhdrBQ3Vy7ictFGvflfg1SJlXnCBD
         qEpQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=R4OT1Vg7XdYQEv0L7xpUV2k95PydE8C5sAInvsYArFk=;
        b=JB3btN3+tgga1uXO3fimwHeGKGFAYMb7QSfX7bttleDv8gEbTKDfzdN1rIYS40wlj8
         rsT/kXKJPB5XZxfIL0g/HuaSJppqWDJcceViaiRMtX6OFd4eHr6i9lemeDmZAKoQoHxX
         nSY3Ss1QZ6kYqMnS2Sp3zF24Meyi5cPbiVUNMK4M4lBjriLfIdHw6sEKCEsL9T61hMAL
         hT2qvKsJN5x1H9+o3ZRizwMxh9z/AGyDgNJTaeTYZq1nABCfepkTV/lJPcu2kVbwEaXI
         gM2b7OfOmHvnfJ6AjsDdgfhINOLAw+VLBC1tFb+t56n2pIIvAIrcvu50u0UKQz6/5QxX
         H7sg==
X-Gm-Message-State: ALoCoQkB1Z1SYfdXbucmz40t/MWTwcMmFtlDCvM/KaWGiRE4N4c5obyLUbbPodSXu/+3fZb7S68J
X-Received: by 10.66.218.70 with SMTP id pe6mr1224885pac.33.1389077741756;
        Mon, 06 Jan 2014 22:55:41 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.121.98 with SMTP id lj2ls6387170qeb.45.gmail; Mon, 06 Jan
 2014 22:55:40 -0800 (PST)
X-Received: by 10.49.48.105 with SMTP id k9mr1450115qen.1.1389077740856;
        Mon, 06 Jan 2014 22:55:40 -0800 (PST)
In-Reply-To: <f4ec2cca-5951-447f-a938-0b2e5e3e233f@isocpp.org>
X-Original-Sender: hunnemethpeter@gmail.com
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:8420
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/8420>

------=_Part_1125_5269115.1389077740219
Content-Type: text/plain; charset=ISO-8859-1

I think compile time reflection can handle this case.
Based on this paper (
https://github.com/hun-nemethpeter/cpp-reflector-mini/blob/master/Proposal.md
),
the result will be similar to this:


// driver
struct SpecializationDriver
{
    constexpr SpecializationDriver(const meta::template_template_decl&templateTemplateDecl
, 
                                   const meta::template_decl& templateDecl)
      : result(templateTemplateDecl.getName() == templateDecl.getName()) { }
    constexpr bool result;
};

template<template <class...> class Template, class T> $use(
SpecializationDriver driver)
bool is_specialization_of()
{
   return driver.result;
}

int main()
{
    std::cout<< is_specialization_of<std::tuple,  std::tuple<double>>() <<::
std::endl;
    std::cout<< is_specialization_of<std::vector, std::tuple<double>>() <<::
std::endl;
    std::cout<< is_specialization_of<std::array,  std::tuple<double>>() <<::
std::endl;
    return 0;
}


Peter


On Wednesday, December 25, 2013 12:32:57 AM UTC+1, Vincent Reverdy wrote:
>
> Hi, 
>
> Currently, it is impossible, as far as I know, to write a "
> is_specialization_of" helper struct to detect whether a type is a 
> specialization of a given template.
> It can be illustrated with the following example:
> ----------------------------------------------------------------------
> #include <iostream>
> #include <type_traits>
> #include <tuple>
> #include <vector>
> #include <array>
>
> template <template <class...> class Template, class T>
> struct is_specialization_of 
> : std::false_type {};
>  
> template <template <class...> class Template, class... Args>
> struct is_specialization_of<Template, Template<Args...>> 
> : std::true_type {};
>
> int main()
> {
>     std::cout<<is_specialization_of<std::tuple,  
> std::tuple<double>>::value<<::std::endl;
>     std::cout<<is_specialization_of<std::vector, 
> std::tuple<double>>::value<<::std::endl;
>     std::cout<<is_specialization_of<std::array,  
> std::tuple<double>>::value<<::std::endl; // Error
>     return 0;
> }
> ----------------------------------------------------------------------
> It works well for templates of the form template <class...> but it fails 
> for mixed type/variable template like std::array.
> I think that it would be great (particularly for template metaprogramming) 
> to have a a new keyword (whose name has to be defined) to declare "a type 
> or a variable".
> With this new keyword, one could type:
> ----------------------------------------------------------------------
> #include <iostream>
> #include <type_traits>
> #include <tuple>
> #include <vector>
> #include <array>
>
> template <template <keyword...> class Template, class T>
> struct is_specialization_of 
> : std::false_type {};
>  
> template <template <keyword...> class Template, keyword... Args>
> struct is_specialization_of<Template, Template<keyword...>> 
> : std::true_type {};
>
> int main()
> {
>     std::cout<<is_specialization_of<std::tuple,  
> std::tuple<double>>::value<<::std::endl;
>     std::cout<<is_specialization_of<std::vector, 
> std::tuple<double>>::value<<::std::endl;
>     std::cout<<is_specialization_of<std::array,  
> std::tuple<double>>::value<<::std::endl; // Ok
>     return 0;
> }
> ----------------------------------------------------------------------
>
> Has it been already discussed? 
> If not, what is you opinion about such a thing?
> If yes, what were the issues?
> Do you have any suggestion for the name of this keyword?
>
> Thank you!
>
> Vincent R.
>
>

-- 

--- 
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/.

------=_Part_1125_5269115.1389077740219
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I think compile time reflection can handle this case.<br>B=
ased on this paper (<a href=3D"https://github.com/hun-nemethpeter/cpp-refle=
ctor-mini/blob/master/Proposal.md">https://github.com/hun-nemethpeter/cpp-r=
eflector-mini/blob/master/Proposal.md</a>),<br>the result will be similar t=
o this:<br><br><br><div class=3D"prettyprint" style=3D"background-color: rg=
b(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; bo=
rder-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div c=
lass=3D"subprettyprint"><span style=3D"color: #800;" class=3D"styled-by-pre=
ttify">// driver</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
struct</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #606;" class=3D"styled-by-prettify">Specializatio=
nDriver</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">constexpr<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #606;" class=3D"styled-by-prettify">SpecializationDriver=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">const</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> meta</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">template_template_decl</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> templateTemplateDecl</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> <br>&nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp=
; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">const</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> meta</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>template_decl</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">&amp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
templateDecl</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nb=
sp; &nbsp; &nbsp; </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
result</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">templateTempl=
ateDecl</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify">getName</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">=3D=3D</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> templateDecl</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">getName</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">())</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &=
nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">cons=
texpr</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">bool</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> result</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">};</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">template</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">template</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">&lt;</span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">class</span><span style=3D"color: #660;" class=3D"styled-by-prettify">...=
&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">class</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">Template</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">class</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> $use</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">(</span><span style=3D"color: #606;" class=3D"styled-by-prettify">Spec=
ializationDriver</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> driver</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">bool</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> is_specialization=
_of</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp;</span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">return</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> driver</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">result</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br></span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">in=
t</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> main</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; std</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">cout</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> is_specialization_of</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">std</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">tuple</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> &nbsp;std</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">tuple</span><span style=3D"color: #080;" class=3D"styled-by-prettify">&lt=
;double&gt;</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>&gt;()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;::</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify">std</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">endl</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; std</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify">cout</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> is_specialization_of</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">std</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">vector</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:=
:</span><span style=3D"color: #000;" class=3D"styled-by-prettify">tuple</sp=
an><span style=3D"color: #080;" class=3D"styled-by-prettify">&lt;double&gt;=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;()</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;::</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">std</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">endl</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>&nbsp; &nbsp; std</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">cout</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> is_specialization_of</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">std</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">array</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> &nbs=
p;std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">tuple</span><=
span style=3D"color: #080;" class=3D"styled-by-prettify">&lt;double&gt;</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;()</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;::</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">std</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">endl</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">return</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"style=
d-by-prettify">0</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
></span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><=
/div></code></div><br><br>Peter<br><br><br>On Wednesday, December 25, 2013 =
12:32:57 AM UTC+1, Vincent Reverdy wrote:<blockquote class=3D"gmail_quote" =
style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-l=
eft: 1ex;"><div dir=3D"ltr">Hi, <br><br>Currently, it is impossible, as far=
 as I know, to write a "<span style=3D"font-family:courier new,monospace">i=
s_specialization_of</span>" helper struct to detect whether a type is a spe=
cialization of a given template.<br>It can be illustrated with the followin=
g example:<br><span style=3D"font-family:courier new,monospace">-----------=
-------------------<wbr>------------------------------<wbr>----------</span=
><br><span style=3D"font-family:courier new,monospace">#include &lt;iostrea=
m&gt;<br>#include &lt;type_traits&gt;<br>#include &lt;tuple&gt;<br>#include=
 &lt;vector&gt;<br>#include &lt;array&gt;<br><br>template &lt;template &lt;=
class...&gt; class Template, class T&gt;<br>struct is_specialization_of <br=
>: std::false_type {};<br>&nbsp;<br>template &lt;template &lt;class...&gt; =
class Template, class... Args&gt;<br>struct is_specialization_of&lt;Templat=
e, Template&lt;Args...&gt;&gt; <br>: std::true_type {};<br><br>int main()<b=
r>{<br>&nbsp;&nbsp;&nbsp; std::cout&lt;&lt;is_specialization_<wbr>of&lt;std=
::tuple,&nbsp; std::tuple&lt;double&gt;&gt;::value&lt;&lt;::<wbr>std::endl;=
<br>&nbsp;&nbsp;&nbsp; std::cout&lt;&lt;is_specialization_<wbr>of&lt;std::v=
ector, std::tuple&lt;double&gt;&gt;::value&lt;&lt;::<wbr>std::endl;<br>&nbs=
p;&nbsp;&nbsp; std::cout&lt;&lt;is_specialization_<wbr>of&lt;std::array,&nb=
sp; std::tuple&lt;double&gt;&gt;::value&lt;&lt;::<wbr>std::endl; // Error<b=
r>&nbsp;&nbsp;&nbsp; return 0;<br>}</span><br><span style=3D"font-family:co=
urier new,monospace">------------------------------<wbr>-------------------=
-----------<wbr>----------</span><br>It works well for templates of the for=
m <span style=3D"font-family:courier new,monospace">template &lt;class...&g=
t;</span> but it fails for mixed type/variable template like <span style=3D=
"font-family:courier new,monospace">std::array</span>.<br>I think that it w=
ould be great (particularly for template metaprogramming) to have a a new k=
eyword (whose name has to be defined) to declare "a type or a variable".<br=
>With this new keyword, one could type:<br><span style=3D"font-family:couri=
er new,monospace">------------------------------<wbr>----------------------=
--------<wbr>----------</span><br><span style=3D"font-family:courier new,mo=
nospace">#include &lt;iostream&gt;<br>#include &lt;type_traits&gt;<br>#incl=
ude &lt;tuple&gt;<br>#include &lt;vector&gt;<br>#include &lt;array&gt;<br><=
br>template &lt;template &lt;keyword...&gt; class Template, class T&gt;<br>=
struct is_specialization_of <br>: std::false_type {};<br>&nbsp;<br>template=
 &lt;template &lt;keyword...&gt; class Template, keyword... Args&gt;<br>str=
uct is_specialization_of&lt;Template, Template&lt;keyword...&gt;&gt; <br>: =
std::true_type {};<br><br>int main()<br>{<br>&nbsp;&nbsp;&nbsp; std::cout&l=
t;&lt;is_specialization_<wbr>of&lt;std::tuple,&nbsp; std::tuple&lt;double&g=
t;&gt;::value&lt;&lt;::<wbr>std::endl;<br>&nbsp;&nbsp;&nbsp; std::cout&lt;&=
lt;is_specialization_<wbr>of&lt;std::vector, std::tuple&lt;double&gt;&gt;::=
value&lt;&lt;::<wbr>std::endl;<br>&nbsp;&nbsp;&nbsp; std::cout&lt;&lt;is_sp=
ecialization_<wbr>of&lt;std::array,&nbsp; std::tuple&lt;double&gt;&gt;::val=
ue&lt;&lt;::<wbr>std::endl; // Ok<br>&nbsp;&nbsp;&nbsp; return 0;<br>}</spa=
n><br><span style=3D"font-family:courier new,monospace">-------------------=
-----------<wbr>------------------------------<wbr>----------</span><br><br=
>Has it been already discussed? <br>If not, what is you opinion about such =
a thing?<br>If yes, what were the issues?<br>Do you have any suggestion for=
 the name of this keyword?<br><br>Thank you!<br><br>Vincent R.<br><br></div=
></blockquote></div>

<p></p>

-- <br />
&nbsp;<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_1125_5269115.1389077740219--

.
