Compiling a project with an older version of g++ (4.8.0, MinGW) I found that this code fails to compile:
template
void foo() = delete;
tem
I don't know if the following will be enlightening but I found defect report 941: Explicit specialization of deleted function template with status C++11 that states the following (Emphasis Mine):
According to 14.7.3 [temp.expl.spec] paragraph 1, only non-deleted function templates may be explicitly specialized. There doesn't appear to be a compelling need for this restriction, however, and it could be useful to forbid use of implicitly-instantiated specializations while still allowing use of explicitly-specialized versions.
Proposed resolution (February, 2010):
Change 14.7.3 [temp.expl.spec] paragraph 1 as follows:
An explicit specialization of any of the following:
non-deletedfunction templateclass template
non-deletedmember function of a class templatestatic data member of a class template
member class of a class template
member class template of a class or class template
non-deletedmember function template of a class or class templatecan be declared...
Now the current state of the draft standard N4527 is 14.7.3 Explicit specialization [temp.expl.spec]:
1 An explicit specialization of any of the following:
(1.1) — function template
(1.2) — class template
(1.3) — variable template
(1.4) — member function of a class template
(1.5) — static data member of a class template
(1.6) — member class of a class template
(1.7) — member enumeration of a class template
(1.8) — member class template of a class or class template
(1.9) — member function template of a class or class template
...
So I guess:
template<typename T>
void foo() = delete;
template<>
void foo<int>(){}
int main() {
foo<int>();
return 0;
}
Is C++11 standard compatible code and should be accepted.