Chapter 2, Template Fundamentals
Question 1
What category of types can be used for non-type template parameters?
Answer
Non-type template parameters can only have structural types. Structure types are integral types, floating-point types (as of C++20), enumeration types, pointer types (either to objects or functions), pointer to member types (either to member objects or member functions), lvalue reference types (either to objects or functions), and literal class types that meet several requirements: all base classes are public and non-mutable, all non-static data members are public and non-mutable, and the types of all the base classes and the non-static data members are also structural types or arrays thereof. const
and volatile
qualified versions of these types are also allowed.
Question 2
Where are default template arguments not allowed?
Answer
Default template arguments cannot be used for parameter packs, in declarations of friend class templates, and in the...