220 19329 <1dd8b6ba-584c-4c1d-8667-6976afb5d785@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: A new is_specialized type trait
Date: Mon, 27 Jul 2015 15:44:35 -0700 (PDT)
Lines: 135
Approved: news@gmane.org
Message-ID: <1dd8b6ba-584c-4c1d-8667-6976afb5d785@isocpp.org>
References: <8947d0c5-ed96-47fb-ad13-16557605356f@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_1411_1125784689.1438037075459"
X-Trace: ger.gmane.org 1438037081 8396 80.91.229.3 (27 Jul 2015 22:44:41 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Mon, 27 Jul 2015 22:44:41 +0000 (UTC)
Cc: morwenn29@gmail.com
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDLZJYWNDQINJ2G2VUCRUBC25LVBA@isocpp.org Tue Jul 28 00:44:38 2015
Return-path: <std-proposals+bncBDLZJYWNDQINJ2G2VUCRUBC25LVBA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ob0-f198.google.com ([209.85.214.198])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDLZJYWNDQINJ2G2VUCRUBC25LVBA@isocpp.org>)
	id 1ZJr8Q-0005d5-Ay
	for gclcip-std-proposals@m.gmane.org; Tue, 28 Jul 2015 00:44:38 +0200
Original-Received: by obkg7 with SMTP id g7sf179454964obk.0
        for <gclcip-std-proposals@m.gmane.org>; Mon, 27 Jul 2015 15:44:37 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:cc:message-id:in-reply-to:references:subject
         :mime-version:content-type:x-original-sender:reply-to:precedence
         :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=VY80WITWAWvB8MY/hEDuQGQghHoc4mr6/oodLRPq3ok=;
        b=BQ6Ajd+Dz9LMIm8WDQhWDDPqMS3QelRZBdrqMDuEIj7ISraHCe5CL1u6xfSiteKeSL
         M++n8JAJY/Eh5Or3Ua0QFzXzggLyH08TrscQIMQRYBffd/nYHuokAIKjnI0cr0QyD13R
         QRHmOxcE2ySh/uAcW+Vocu8BNcDwNSnNxkthVGBMiRd7PH8BBOppTqMHYFaaoYbC8t+2
         F/LIABPQTqAZQjseZ9OsZxh1bEkM6UuJMYIVnA0qvdxp2c1HVh0C05I1u5dvkrXa6qsl
         Sqzk3Kz9ZmRWW2KEuci7KejT7SYHawuCenuNVJg67LvNKqbPShQRy43FRFm88tJYHy+A
         cFCA==
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:cc:message-id:in-reply-to
         :references:subject:mime-version:content-type:x-original-sender
         :reply-to:precedence:mailing-list:list-id:x-spam-checked-in-group
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=VY80WITWAWvB8MY/hEDuQGQghHoc4mr6/oodLRPq3ok=;
        b=TskSzVbG+t9t/AbtDJY8pPSIyEAcWCOC4Bo9QkyX/rWm4NP+gezX0SK41R4fLsd6Q1
         IcYcZiZMwZEc8lHgxENQxyoVMFtREW8qnWHZ0HGOCMHBPbnA+gvrleotTM1vAlaxMnqr
         CIM8durIAdJ6W3eWKCZv3/diDkOSNKK2hskS/xcG22twK5zyC6Ge1cmWij/07yGYhzYT
         NQ8E3Rwt6wCb77BAa36KJ+B3i8uWDokTAUL4rwEl9TR3ONV0JdvFkqRvuRwKtucDag/s
         uL+b1F2LvGie+0i6Q1cnXAWsTgjUeJWIlxck6aM5QtdXe4dZwQo+E6wofI/NdH6Pauq6
         o3YQ==
X-Gm-Message-State: ALoCoQknWkaGvRix7l9zr48p1gmi8NIbmxe0aAb4oal9koDx5+g5IlzEyPhcYe4epC9/yF5R+l/G
X-Received: by 10.50.111.231 with SMTP id il7mr280335igb.12.1438037077364;
        Mon, 27 Jul 2015 15:44:37 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.50.30.35 with SMTP id p3ls1084323igh.8.canary; Mon, 27 Jul
 2015 15:44:36 -0700 (PDT)
X-Received: by 10.50.4.1 with SMTP id g1mr3396igg.7.1438037076566;
        Mon, 27 Jul 2015 15:44:36 -0700 (PDT)
In-Reply-To: <8947d0c5-ed96-47fb-ad13-16557605356f@isocpp.org>
X-Original-Sender: arthur.j.odwyer@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: 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: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:19329
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/19329>

------=_Part_1411_1125784689.1438037075459
Content-Type: multipart/alternative; 
	boundary="----=_Part_1412_586445083.1438037075460"

------=_Part_1412_586445083.1438037075460
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Monday, July 27, 2015 at 4:11:46 AM UTC-7, Morwenn wrote:
>
> A some point in one of my projects, I needed a tait to check whether a=20
> template was specialized for a given type to use it if it was and fall ba=
ck=20
> to another template if it wasn't. Therefore, I wrote a small=20
> is_specialized trait class to do the job in the vein of the detection=20
> toolkit:
>
>     template<
>         template<typename...> class,
>         typename,
>         typename=3Dvoid    >    struct is_specialized:
>         std::false_type    {};
>     template<
>         template<typename...> class Template,
>         typename T    >    struct is_specialized<Template, T, std::void_t=
<decltype(Template<T>{})>>:
>         std::true_type    {};
>
> Would such an addition to the standard header <type_traits> be useful for=
 general-purpose specialization detection?
>
>
I'm glad you've found a better solution to your problem. But I don't=20
understand the worse solution!
Surely the code above merely checks whether Template<T> is well-formed (and=
=20
constructible from an empty braced-initializer).
I don't see how it does anything to check whether Template<T> comes from a=
=20
specialization (either full or partial).

For example, I see

    static_assert(is_specialized<std::vector, int>::value);
    static_assert(is_specialized<std::vector, bool>::value);

Are you trying to find some construct that would return true for=20
vector<bool> and false for vector<int>?
And if so, why??

=E2=80=93Arthur

--=20

---=20
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 e=
mail 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-proposa=
ls/.

------=_Part_1412_586445083.1438037075460
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Monday, July 27, 2015 at 4:11:46 AM UTC-7, Morwenn wrote:<blockquote cla=
ss=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #=
ccc solid;padding-left: 1ex;"><div dir=3D"ltr">A some point in one of my pr=
ojects, I needed a tait to check whether a template was specialized for a g=
iven type to use it if it was and fall back to another template if it wasn&=
#39;t. Therefore, I wrote a small <span style=3D"font-family:courier new,mo=
nospace">is_specialized</span> trait class to do the job in the vein of the=
 detection toolkit:<br><br><pre><code><span>    template</span><span>&lt;</=
span><span>
        </span><span>template</span><span>&lt;</span><span>typename</span><=
span>...&gt;</span><span> </span><span>class</span><span>,</span><span>
        </span><span>typename</span><span>,</span><span>
        </span><span>typename</span><span>=3D</span><span>void</span><span>
</span><span>    &gt;</span><span>
</span><span>    struct</span><span> is_specialized</span><span>:</span><sp=
an>
        std</span><span>::</span><span>false_type
</span><span>    {};</span><span>

</span><span>    template</span><span>&lt;</span><span>
        </span><span>template</span><span>&lt;</span><span>typename</span><=
span>...&gt;</span><span> </span><span>class</span><span> </span><span>Temp=
late</span><span>,</span><span>
    </span><span>    typename</span><span> T
</span><span>    &gt;</span><span>
</span><span>    struct</span><span> is_specialized</span><span>&lt;</span>=
<span>Template</span><span>,</span><span> T</span><span>,</span><span> std<=
/span><span>::</span><span>void_t</span><span>&lt;</span><span>decltype</sp=
an><span>(</span><span>Template</span><span>&lt;</span><span>T</span><span>=
&gt;{})&gt;&gt;:</span><span>
        std</span><span>::</span><span>true_type
</span><span>    {};</span></code><br><code><span></span></code><code><span=
><br><span style=3D"font-family:arial,sans-serif">Would such an addition to=
 the standard header <span style=3D"font-family:courier new,monospace">&lt;=
type_traits&gt;</span> be useful for general-purpose specialization detecti=
on?</span></span></code></pre></div></blockquote><div><br></div><div>I&#39;=
m glad you&#39;ve found a better solution to your problem. But I don&#39;t =
understand the worse solution!</div><div>Surely the code above merely check=
s whether Template&lt;T&gt; is well-formed (and constructible from an empty=
 braced-initializer).</div><div>I don&#39;t see how it does anything to che=
ck whether Template&lt;T&gt; comes from a specialization (either full or pa=
rtial).</div><div><br></div><div>For example, I see</div><div><br></div><di=
v>=C2=A0 =C2=A0 static_assert(is_specialized&lt;std::vector, int&gt;::value=
);</div><div><div>=C2=A0 =C2=A0 static_assert(is_specialized&lt;std::vector=
, bool&gt;::value);</div></div><div><br></div><div>Are you trying to find s=
ome construct that would return true for vector&lt;bool&gt; and false for v=
ector&lt;int&gt;?</div><div>And if so, why??</div><div><br></div><div>=E2=
=80=93Arthur</div>

<p></p>

-- <br />
<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 <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<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_1412_586445083.1438037075460--
------=_Part_1411_1125784689.1438037075459--

.
