ebco

ebco is a way to gain the benefits of what is called the Empty Base Class Optimization (EBCO). It is meant to be used as a base class with the type and tag used to identify the member variable is replacing. Mostly superseded by [[no_unique_address]], except on one compiler that decided to make a Fractally Bad Decisionβ„’.

template<typename _Type, ::std::size_t _Tag = 0, typename = void>
class ebco

A class for optimizing the amount of space a certain member of type _Type might use.

Remark

The only reason this class continues to be necessary is because of Microsoft Visual C++. Every other compiler respects the new C++20 attribute [[no_unique_address]] - it is only Microsoft that explicitly decided that our opt-in indication that we care more about the object’s size is not important.

Template Parameters
  • _Type – The type of the member.

  • _Tag – A differentiating tag to separate this member from others when there are multiple bases of the same _Type.

Public Functions

ebco() = default

Default construction.

ebco(const ebco&) = default

Copy construction.

ebco(ebco&&) = default

Move construction.

ebco &operator=(const ebco&) = default

Copy assignment operator.

ebco &operator=(ebco&&) = default

Move assignment operator.

inline constexpr ebco(const _Type &__value) noexcept(::std::is_nothrow_copy_constructible_v<_Type>)

Copies the object into storage.

inline constexpr ebco(_Type &&__value) noexcept(::std::is_nothrow_move_constructible_v<_Type>)

Moves the object into storage.

inline constexpr ebco &operator=(const _Type &__value) noexcept(::std::is_nothrow_copy_assignable_v<_Type>)

Copy assigns into the previous object into storage.

inline constexpr ebco &operator=(_Type &&__value) noexcept(::std::is_nothrow_move_assignable_v<_Type>)

Move assigns into the previous object into storage.

template<typename _Arg, typename ..._Args, typename = ::std::enable_if_t<!::std::is_same_v<::std::remove_reference_t<::std::remove_cv_t<_Arg>>, ebco> && !::std::is_same_v<::std::remove_reference_t<::std::remove_cv_t<_Arg>>, _Type>>>
inline constexpr ebco(_Arg &&__arg, _Args&&... __args) noexcept(::std::is_nothrow_constructible_v<_Type, _Arg, _Args...>)

Constructs the object in storage from the given arguments.

inline constexpr _Type &get_value() & noexcept

Gets the wrapped value.

inline constexpr _Type const &get_value() const & noexcept

Gets the wrapped value.

inline constexpr _Type &&get_value() && noexcept

Gets the wrapped value.