template<class T, T v> cannot specialize to template<bool &v> struct<bool &, v> in C++17?

1,270 views
Skip to first unread message

Tadeus Prastowo

unread,
Mar 5, 2019, 9:31:59 PM3/5/19
to std-discussion
Hi,

Could someone confirm whether in C++17 "template<class T, T v> struct
X" can or cannot be specialized as "template<bool &v> struct X<bool &,
v>", please?

As shown in https://www.godbolt.org/z/N3M443, GCC thinks that the
primary template can be specialized in that way both in C++14 and
C++17. Clang, on the other hand, thinks that it can only be done in
C++14. In C++17, Clang gives the following error:

<source>:6:8: error: class template partial specialization is not more
specialized than the primary template
[-Winvalid-partial-specialization]
struct X<bool &, v> {

Is that a Clang bug, or C++17 indeed changes the specialization
ordering of C++14?

Thank you.

--
Best regards,
Tadeus
Reply all
Reply to author
Forward
0 new messages