Non-constexpr Optional
and trivial relocation
Optional
and trivial relocationHere’s a simple non-constexpr-friendly Optional
type. (Godbolt.)
template<class T>
class [[trivially_relocatable(std::is_trivially_relocatable_v<T>)]] Optional {
~~~~
alignas(T) char data_[sizeof(T)];
bool engaged_ = false;
};