C++ Logo

std-discussion

Advanced search

Re: Partial ordering of function template which have a place holder for deduced class type in the template parameter list.

From: Olivier Kannengieser <okannen_at_[hidden]>
Date: Wed, 5 Aug 2020 12:22:39 +0200
I made some search, placeholder for deduced class type in non type template
parameter was added by the merge of P0732R2
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0732r2.pdf>. Was
this feature not supposed to be merged in the standard?

Le mar. 4 août 2020 à 21:34, Olivier Kannengieser <okannen_at_[hidden]> a
écrit :

> The paragraph that allowes place holder for deduced class type in template
> parameter is [dcl.type.class.deduc]/§2
>
> >A placeholder for a deduced class type can also be used in the
> type-specifier-seq <http://eel.is/c++draft/dcl.type#nt:type-specifier-seq> in
> the new-type-id <http://eel.is/c++draft/expr.new#nt:new-type-id> or
> type-id <http://eel.is/c++draft/dcl.name#nt:type-id> of a new-expression
> <http://eel.is/c++draft/expr.new#nt:new-expression>, as the
> simple-type-specifier
> <http://eel.is/c++draft/dcl.type.simple#nt:simple-type-specifier> in an explicit
> type conversion (functional notation)
> <http://eel.is/c++draft/expr.type.conv>, or as the type-specifier
> <http://eel.is/c++draft/dcl.type#nt:type-specifier> in the
> parameter-declaration
> <http://eel.is/c++draft/dcl.fct#nt:parameter-declaration> of a
> template-parameter
> <http://eel.is/c++draft/temp.param#nt:template-parameter>.
> <http://eel.is/c++draft/dcl.type.class.deduct#2.sentence-1>
>
> I had not read non normative "Notes", and apparently the behavior seems to
> be recognize by the standard [temp.func.order]/§3
>
> >
> [Note <http://eel.is/c++draft/temp.func.order#3.note-1>:
> The type replacing the placeholder in the type of the value synthesized
> for a non-type template parameter is also a unique synthesized type.
> <http://eel.is/c++draft/temp.func.order#3.sentence-2>
> — *end note*]
>
> This is a frustrating limitation because at least it makes impossible to
> partially specialize any class template with a non-type template parameter
> that uses a placeholder for deduced class type. Should not this be changed?
>
> Le lun. 3 août 2020 à 00:44, Ville Voutilainen via Std-Discussion <
> std-discussion_at_[hidden]> a écrit :
>
>> On Mon, 3 Aug 2020 at 01:33, Jason McKesson via Std-Discussion
>> <std-discussion_at_[hidden]> wrote:
>> >
>> > On Sun, Aug 2, 2020 at 2:30 PM Olivier Kannengieser via Std-Discussion
>> > <std-discussion_at_[hidden]> wrote:
>> > >
>> > > No this is what I meant. 'A x' is a C++20 feature: place holder for
>> deduced class type for the declaration of non type template parameter.
>> >
>> > No, "place holder for deduced class type for the declaration of non
>> > type template parameter" is the C++17 feature that allows `auto x` to
>> > work in template arguments. A template name by itself is not a
>> > placeholder.
>> >
>> > C++20 allows `ConceptName auto x`, which does the above except with a
>> > concept constraint as to `x`'s type.
>> >
>> > At no point does C++ permit `TemplateName x` to work in a template
>> > parameter list. There were some Concept ideas that `TemplateName<auto>
>> > x` might work, and maybe Concepts TS allowed you to drop the argument.
>> > But C++20 does not.
>>
>> I'm not sure what you mean by "TemplateName x", but this certainly does
>> work:
>>
>> template <class T> concept foo = /* whatever */;
>>
>> template <foo T> void f(); // or struct, class, etc.
>>
>> That foo is probably not what you mean by TemplateName, because it's a
>> ConceptName.
>> --
>> Std-Discussion mailing list
>> Std-Discussion_at_[hidden]
>> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>>
>

Received on 2020-08-05 05:26:26