Skip to content

Commit

Permalink
Update any.h
Browse files Browse the repository at this point in the history
  • Loading branch information
lackhole committed Oct 6, 2024
1 parent d4a59fb commit e34517b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions include/preview/__any/any.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ struct any_big_handler {

template<typename... Args>
static T& create(any* thiz, Args&&... args) {
any_big_handler<T>::get_ptr(*thiz) = ::new T(std::forward<Args>(args)...);
any_big_handler<T>::set_ptr(*thiz, ::new T(std::forward<Args>(args)...));
thiz->vptr_ = &any_big_handler<T>::handle;
return *any_big_handler<T>::get_ptr(*thiz);
}
Expand All @@ -363,6 +363,7 @@ struct any_big_handler {
using pointer = T*;
using const_pointer = std::add_const_t<T>*;

static void set_ptr(any& self, pointer ptr) noexcept { self.storage_.ptr = ptr; }
static pointer get_ptr( any& self) noexcept { return static_cast<pointer >(self.storage_.ptr); }
static const_pointer get_ptr(const any& self) noexcept { return static_cast<const_pointer>(self.storage_.ptr); }

Expand All @@ -375,7 +376,7 @@ struct any_big_handler {
}

static void move(any& self, any* other) {
any_big_handler<T>::get_ptr(*other) = any_big_handler<T>::get_ptr(self);
any_big_handler<T>::set_ptr(*other, any_big_handler<T>::get_ptr(self));
other->vptr_ = self.vptr_;
self.vptr_ = nullptr;
}
Expand Down

0 comments on commit e34517b

Please sign in to comment.