10class function_base :
public Base {
12 function_base() { this->construct_empty(); }
15 this->get_vtable().destroy(this->mStorage);
18 function_base(function_base&& other) {
20 other.get_vtable().move_to(other.mStorage, this->mStorage);
21 this->mStorage.vfptr = std::exchange(other.mStorage.vfptr,
nullptr);
23 this->construct_empty();
26 function_base& operator=(function_base&& other) {
27 if (
this != std::addressof(other)) {
29 this->get_vtable().destroy(this->mStorage);
32 other.get_vtable().move_to(other.mStorage, this->mStorage);
33 this->mStorage.vfptr = std::exchange(other.mStorage.vfptr,
nullptr);
35 this->construct_empty();
42 function_base& operator=(std::nullptr_t) {
44 this->get_vtable().destroy(this->mStorage);
45 this->mStorage.vfptr =
nullptr;
50 [[nodiscard]]
friend bool operator==(function_base
const& self, nullptr_t)
noexcept {
51 return !
static_cast<bool>(self);
56class function_base<DerivedType::Copyable, Base> :
public function_base<DerivedType::MoveOnly, Base> {
58 function_base() =
default;
59 function_base(function_base&&) =
default;
60 function_base& operator=(function_base&&) =
default;
62 function_base(function_base
const& other) {
64 other.get_vtable().copy_to(other.mStorage, this->mStorage);
65 this->mStorage.vfptr = other.mStorage.vfptr;
67 this->construct_empty();
70 function_base& operator=(function_base
const& other) {
71 if (
this != std::addressof(other)) {
73 this->get_vtable().destroy(this->mStorage);
76 other.get_vtable().copy_to(other.mStorage, this->mStorage);
77 this->mStorage.vfptr = other.mStorage.vfptr;
79 this->construct_empty();