Created on 2024-01-15.00:00:00 last changed 4 months ago
Proposed resolution (approved by CWG 2024-02-16):
Change the example in 13.9.3 [temp.explicit] paragraph 4 as follows:
...
template<class T> void sort(Array<T>& v) { /* ... */ }
template void sort(Array<char>&); // argument is deduced here (13.10.2 [temp.arg.explicit])
...
Remove 13.9.3 [temp.explicit] paragraph 8:
A trailing template-argument can be left unspecified in an
explicit instantiation of a function template specialization or of a
member function template specialization provided it can be deduced
(13.10.3.7 [temp.deduct.decl]). If all template arguments can be
deduced, the empty template argument list <> may be omitted.
[Example 3:
template<class T> class Array { /* ... */ };
template<class T> void sort(Array<T>& v) { /* ... */ }
// instantiate sort(Array<int>&) -- template-argument deduced
template void sort<>(Array<int>&);
—end example]
Change the example in 13.9.4 [temp.expl.spec] paragraph 1 as follows:
... [ Example:template<class T> class stream; template<> class stream<char> { /* ... */ }; // #1 template<class T> class Array { /* ... */ }; template<class T> void sort(Array<T>& v) { /* ... */ } template<> void sort<int>(Array<int>&); // #2 template<> void sortGiven these declarations,<char*>(Array<char*>&); // #3 template argument is deduced (13.10.2 [temp.arg.explicit]) ...stream<char>#1 will be used as the definition of streams of chars; other streams will be handled by class template specializations instantiated from the class template. Similarly, #2 will be used as the sort function for arguments of type Array<int> and #3sort<char*>will be usedas the sort functionfor arguments of type Array<char*>; other Array types will be sorted by functions generated from the function template. —end example]
Remove 13.9.4 [temp.expl.spec] paragraph 10:
A trailing template-argument can be left unspecified in the template-id naming an explicit function template specialization provided it can be deduced (13.10.3.7 [temp.deduct.decl]). [Example 6:template<class T> class Array { /* ... */ }; template<class T> void sort(Array<T>& v); // explicit specialization for sort(Array<int>&) // with deduced template-argument of type int template<> void sort(Array<int>&);—end example]
[Accepted as a DR at the March, 2024 meeting.]
(From submission #489.)
Subclause 13.9.3 [temp.explicit] paragraph 8 specifies:
A trailing template-argument can be left unspecified in an
explicit instantiation of a function template specialization or of a
member function template specialization provided it can be deduced
(13.10.3.7 [temp.deduct.decl]). If all template arguments can be
deduced, the empty template argument list <> may be omitted.
[Example 3:
template<class T> class Array { /* ... */ };
template<class T> void sort(Array<T>& v) { /* ... */ }
// instantiate sort(Array<int>&) -- template-argument deduced
template void sort<>(Array<int>&);
—end example]
This paragraph is redundant with a more general provision on explicitly specifying template arguments in 13.10.2 [temp.arg.explicit] paragraph 4:
Trailing template arguments that can be deduced (13.10.3 [temp.deduct]) or obtained from default template-arguments may be omitted from the list of explicit template-arguments. [Note 1: A trailing template parameter pack (13.7.4 [temp.variadic]) not otherwise deduced will be deduced as an empty sequence of template arguments. —end note] If all of the template arguments can be deduced or obtained from default template-arguments, they may all be omitted; in this case, the empty template argument list <> itself may also be omitted. ...
A similar duplication is in 13.9.4 [temp.expl.spec] paragraph 10.
History | |||
---|---|---|---|
Date | User | Action | Args |
2024-07-20 13:52:34 | admin | set | status: dr -> drwp |
2024-04-05 21:43:46 | admin | set | status: ready -> dr |
2024-03-20 14:10:31 | admin | set | status: tentatively ready -> ready |
2024-02-16 23:23:05 | admin | set | status: review -> tentatively ready |
2024-02-03 00:15:40 | admin | set | messages: + msg7586 |
2024-02-03 00:15:40 | admin | set | status: open -> review |
2024-01-15 00:00:00 | admin | create |