You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is an implementation-defined quantity that specifies the limit on the total depth of recursive instantiations ([implimits]), which could involve more than one template. The result of an infinite recursion in instantiation is undefined.
has an example that:
template<classT> classX {
X<T>* p; // #1 // OK
X<T*> a; // #2 // implicit generation of X<T> requires// the implicit instantiation of X<T*> which requires// the implicit instantiation of X<T**> which …// an extra exampleexplicit(sizeof(X<T>)>1) operatorint(){ // #3return0;
}
};
In either case of the three, the injected-class-name X is used as a template-name as per [temp.local] p1. That means, all the use of X can be replaced by ::X. [temp.inst] p2 states that
Unless a class template specialization is a declared specialization, the class template specialization is implicitly instantiated when the specialization is referenced in a context that requires a completely-defined object type or when the completeness of the class type affects the semantics of the program.
The operand of sizeof requires the operand to have a completely-defined object type and the class template specialization X<T> is not a declared specialization, thus, that operand should cause the implicit instantiation of X<T>, the implicit instantiation for X<T>, in turn, causes the implicit instantiation of explicit(sizeof(X<T>)>1) , which process is recursive.
We do not have a sufficient reason that can interpret why the current instantiation won't cause that non-reasonable instantiation that would violate [temp.inst] p16.
The text was updated successfully, but these errors were encountered:
[temp.inst] p16
has an example that:
In either case of the three, the injected-class-name
X
is used as a template-name as per [temp.local] p1. That means, all the use ofX
can be replaced by::X
. [temp.inst] p2 states thatThe operand of
sizeof
requires the operand to have a completely-defined object type and the class template specializationX<T>
is not a declared specialization, thus, that operand should cause the implicit instantiation ofX<T>
, the implicit instantiation forX<T>
, in turn, causes the implicit instantiation ofexplicit(sizeof(X<T>)>1)
, which process is recursive.We do not have a sufficient reason that can interpret why the current instantiation won't cause that non-reasonable instantiation that would violate [temp.inst] p16.
The text was updated successfully, but these errors were encountered: