On 5 February 2018 at 09:16, Stephan Bergmann wrote: > On 05.02.2018 06:06, Simon Marchi wrote: >> >> On 2018-02-04 02:17 PM, Martin Sebor wrote: >>> >>> Printing the suffix is unhelpful because it leads to unnecessary >>> differences in diagnostics (even in non-template contexts). For >>> templates with non-type template parameters there is no difference >>> between, say A<1>, A<1U>, A<(unsigned) 1>, or even A<Green> when >>> Green is an enumerator that evaluates to 1, so including the suffix >>> serves no useful purpose. >> >> >> This is the part I don't understand. In Roman's example, spelling >> foo<10> and foo<10u> resulted in two different instantiations of the >> template, with different code. So that means it can make a difference, >> can't it? > > > Yes, for non-type template parameters whose type contains a placeholder type > (i.e., "auto IVAL" in the earlier example), which is a new feature of C++17.
Right, for C++14 saying foo<2> is entirely unambiguous because the type of the template parameter is fixed. For C++17 a template declared as "template<auto> class foo" can be instantiated with different types, so foo<2> and foo<2u> don't refer to the same specialiation. > My understanding is that printing the suffix would be essential in such > cases. Not sufficient, it doesn't help distinguish foo<(short)2>, foo<(int)2> or foo<(signed char)2> because there is no suffix for signed/unsigned short or signed/unsigned char.