std::is_empty (3) - Linux Manuals
std::is_empty: std::is_empty
NAME
Synopsis
Defined in header <type_traits>
template< class T > (since C++11)
struct is_empty;
If T is an empty type (that is, a non-union class type with no non-static data members other than bit-fields of size 0, no virtual functions, no virtual base classes, and no non-empty base classes), provides the member constant value equal true. For any other type, value is false.
If T is a non-union class type, T shall be a complete type; otherwise, the behavior is undefined.
Template parameters
T - a type to check
Helper variable template
template< class T > (since C++17)
inline constexpr bool is_empty_v = is_empty<T>::value;
Inherited from std::integral_constant
Member constants
value true if T is an empty class type , false otherwise
[static]
Member functions
operator bool (public member function)
operator() returns value
(C++14)
Member types
Type Definition
value_type bool
type std::integral_constant<bool, value>
Notes
Inheriting from empty base classes usually does not increase the size of a class due to empty_base_optimization.
std::is_empty<T> and all other type traits are empty classes.
Example
// Run this code
Possible output:
See also
is_class checks if a type is a non-union class type
(C++11)