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.
-
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.