Created on 2015-11-19.00:00:00 last changed 8 months ago
Additional notes (March, 2024)
This issue is related to issue 2296.
Notes from the March, 2018 meeting:
CWG felt that such errors should be substitution failures, not hard errors.
According to 13.9.2 [temp.inst] paragraph 11,
If a function template f is called in a way that requires a default argument to be used, the dependent names are looked up, the semantics constraints are checked, and the instantiation of any template used in the default argument is done as if the default argument had been an initializer used in a function template specialization with the same scope, the same template parameters and the same access as that of the function template f used at that point, except that the scope in which a closure type is declared (7.5.6.2 [expr.prim.lambda.closure]) — and therefore its associated namespaces — remain as determined from the context of the definition for the default argument. This analysis is called default argument instantiation. The instantiated default argument is then used as the argument of f.
Some details are not clear from this description. For example, given
#include <type_traits> template<class T> struct Foo { Foo(T = nullptr) {} }; bool b = std::is_constructible<Foo<int>>::value; int main() {}
does “used” mean odr-used or used in any way? Is a failure of default argument instantiation in the immediate context of the call or is a failure a hard error? And does it apply only to function templates, as it says, or should it apply to member functions of class templates? There is implementation divergence on these questions.
History | |||
---|---|---|---|
Date | User | Action | Args |
2024-03-14 19:00:17 | admin | set | messages: + msg7634 |
2018-04-11 00:00:00 | admin | set | messages: + msg6199 |
2018-04-11 00:00:00 | admin | set | status: open -> drafting |
2015-11-19 00:00:00 | admin | create |