Std :: tuple is required to use empty base class optimization?

Will be

std::is_empty<std::tuple<Args...>>::value

      

returns true if each type is Args

empty? A quick test in gcc 4.9 means it does, but is it required by the standard?

+3


source to share


1 answer


No, there is no requirement to tuple

use inheritance to enable empty base class optimization.

The only textual specification of the tuple library is:

This subclause describes a tuple library that provides a tuple type as a class template tuple that can be created with any number of arguments. Each template argument specifies the type of the element in the tuple. Hence, tuples are heterogeneous, fixed sets of values. Instantiating a tuple with two arguments is similar to instantiating a pair with the same two arguments.



without mentioning any implementation details; and the template specification begins:

template <class... Types>
class tuple {

      

without indicating that it should inherit from anything.

+6


source







All Articles