What if the type of an entity with an undeduced placeholder type is needed?

40 views
Skip to first unread message

xskxzr

unread,
Jan 5, 2018, 11:05:10 PM1/5/18
to ISO C++ Standard - Discussion
Hi all,
[dcl.spec.auto]/9 specifies the case where the type of an entity with an undeduced placeholder type is needed to determine the type of an expression, but what about other cases?

For example, 
struct S {
 
template <auto i>
 
void f();
};

template <auto j>
void S::f() {}

To determine whether the definition is bound to the declaration, their template-heads are compared, and thus the types of i and j are needed to determine whether they are the same type. What does the standard say about this case?

Thanks,
xskxzr


Tam S. B.

unread,
Jan 6, 2018, 9:51:50 AM1/6/18
to std-dis...@isocpp.org
I think it should be the same as

auto f();
auto f() { return 0; }

That is, the declarations are valid and match each other as long as their placeholders have the same form, though in general the standard seems quite unclear on the validity of redeclarations that involves placeholder types.

________________________________________
From: xskxzr <xsk...@gmail.com>
Sent: Saturday, January 6, 2018 4:05:10 AM
To: ISO C++ Standard - Discussion
Subject: [std-discussion] What if the type of an entity with an undeduced placeholder type is needed?

Hi all,
,
[dcl.spec.auto]/9<http://www.eel.is/c++draft/dcl.spec.auto#9> specifies the case where the type of an entity with an undeduced placeholder type is needed to determine the type of an expression, but what about other cases?
--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussio...@isocpp.org<mailto:std-discussio...@isocpp.org>.
To post to this group, send email to std-dis...@isocpp.org<mailto:std-dis...@isocpp.org>.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.

Richard Smith

unread,
Jan 6, 2018, 10:06:54 PM1/6/18
to std-dis...@isocpp.org
See [temp.over.link]p6:

"Two template-heads are equivalent if [...] corresponding template-parameters are equivalent [...]. Two template-parameters are equivalent under the following conditions:
[...]
 - if they declare non-type template parameters, they have equivalent types."

Two type specifiers are generally considered equivalent if they name the same type (where the rules of [temp.over.link] are used to determine whether dependent expressions within the types are equivalent). As with any type, the placeholder type "auto" is equivalent to itself. But I don't think the standard *explicitly* says that anywhere.
Reply all
Reply to author
Forward
0 new messages