#pragma GCC system_header #ifndef _LIBCXX_MEMORY #define _LIBCXX_MEMORY #include <__config> #include #include #include #include _LIBCXX_BEGIN_NAMESPACE_STD template class unique_ptr { public: unique_ptr() : m_data(nullptr) { } unique_ptr(T* data) : m_data(data) { } unique_ptr(std::nullptr_t) : m_data(nullptr) { } unique_ptr& operator=(std::nullptr_t) { reset(); return *this; } unique_ptr(unique_ptr&& moving) noexcept : m_data(nullptr) { moving.swap(*this); } unique_ptr& operator=(unique_ptr&& moving) noexcept { moving.swap(*this); return *this; } template unique_ptr(unique_ptr&& moving) { unique_ptr tmp((T*)moving.release()); tmp.swap(*this); } template unique_ptr& operator=(unique_ptr&& moving) { unique_ptr tmp((T*)moving.release()); tmp.swap(*this); return *this; } T* release() noexcept { T* result = m_data; m_data = nullptr; return result; } void swap(unique_ptr& src) noexcept { T* tmp_data = m_data; m_data = src.m_data; src.m_data = tmp_data; } void reset() { T* tmp = release(); delete tmp; } void reset(T* new_ptr) { T* tmp = release(); delete tmp; m_data = new_ptr; } ~unique_ptr() { delete m_data; } unique_ptr(unique_ptr const&) = delete; unique_ptr& operator=(unique_ptr const&) = delete; T* operator->() const { return m_data; } T& operator*() const { return *m_data; } T* get() const { return m_data; } explicit operator bool() const { return m_data; } private: T* m_data { nullptr }; }; template struct allocator_traits { using allocator_type = Alloc; using value_type = typename Alloc::value_type; using pointer = typename Alloc::pointer; using const_pointer = typename Alloc::const_pointer; using void_pointer = typename Alloc::void_pointer; using const_void_pointer = typename Alloc::const_void_pointer; using difference_type = typename Alloc::difference_type; using size_type = typename Alloc::size_type; }; template struct __rebind_alloc_helper; template