quoted sample code:
// empty list: template<typename ... Args> struct List { struct head {static_assert(sizeof...(Args) != 0, "Attempt to access the head of an empty list."); }; struct tail {static_assert(sizeof...(Args) != 0, "Attempt to access the tail of an empty list."); }; }; // non-empty list: template<typename Head, typename... Tail> struct List<Head, Tail...> { typedef Head head; typedef List<tail ...> tail; };
- (Clause 14.7.1p1) Unless a class template specialization has been explicitly instantiated (14.7.2) or explicitly specialized (14.7.3), 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 implicit instantiation of a class template specialization causes the implicit instantiation of the declarations, but not of the definitions ... of the class member functions, member classes, [...].
- (Clause 14.7.1p11) An implementation shall not implicitly instantiate ... a member class...of a class template that does not require instantiation.
- (Clause 14.6p8) If no valid specialization can be generated for a template, and that template is not instantiated, the template is ill-formed, no diagnostic required.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.