10 static constexpr bool isLarge =
sizeof(Obj) > Obj::smallObjSize ||
alignof(Obj) >
alignof(std::max_align_t)
13 template <
class Obj,
class... Args>
15 constructImpl(
void* to, Args&&... args)
noexcept(std::is_nothrow_constructible_v<Obj, Args...>) {
16 if constexpr (isLarge<Obj>) {
17 return ::new Obj(std::forward<Args>(args)...);
19 return ::new (to) Obj(std::forward<Args>(args)...);
23 static constexpr void destroyImpl(Obj* self)
noexcept {
24 if constexpr (isLarge<Obj>) {
32 AnyObjBase() =
default;
33 AnyObjBase(AnyObjBase
const&) =
delete;
34 AnyObjBase& operator=(AnyObjBase
const&) =
delete;
36 virtual ~AnyObjBase() =
default;
38 virtual AnyObjBase* copy(
void* to)
const = 0;
39 virtual AnyObjBase* move(
void* to)
noexcept = 0;
40 virtual void tidy()
noexcept = 0;