-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Full name of submitter: Anoop S. Rana
Reference (section label): [dcl.fct.def.delete]
Issue description: Currently [dcl.fct.def.delete] says:
A construct that designates a deleted function implicitly or explicitly, other than to declare it or to appear as the operand of a reflect-expression ([expr.reflect]), is ill-formed.
Note the emphasis on "designates". Also note that in previous C++ standards, the word "designates" used to say "refers to". Now, since deleted functions also take part in overload resolution, meaning we are "referring to" them during the overload resolution for a given call, we should clarify/change "designates" to "is selected" in the above quoted reference. For example, consider the following example(created just to make it more concrete):
template<typename T> void foo(T t ) //#1 primary template
{
std::cout << "#1: variant T t\n";
}
template<typename T> void foo(T* t ) =delete; //#2 primary template
//this specializes #2
template<> void foo(int* t )
{
std::cout << "specialization int* t\n";
}
int main()
{
foo(new int{1}); //will use the specialization as expected
}
Here, for the call foo(new int(1));, overload resolution takes place during which both primary templates(including the deleted one) is also considered. And since the deleted one is a better match it will be selected(and later its specialization will be used). My point is that during the overload resolution phase, we(or the compiler or whatever) conceptually need to "refer to" the deleted function template. But [dcl.fct.def.delete] explicitly prohibits designation of a deleted function template. The problem is that it is hard to define "refers to" or "designates" correctly as it is a very commonly used term(the standard uses it around 200 times in the draft). So, I suggest that for [dcl.fct.def.delete] case, we should add mention that this applies only when the designated function template is used which isn't in this case becasue we have a specialization.