Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //класс, выделяющий и управляющий памятью
- class allocator {
- public:
- using size_type = std::size_t;
- using difference_type = std::ptrdiff_t;
- using pointer = T*;
- using const_pointer = const T*;
- using reference = typename std::add_lvalue_reference<T>::type;
- using const_reference = typename std::add_lvalue_reference<const T>::type;
- using value_type = T;
- allocator() noexcept = default;
- allocator(const allocator&) noexcept = default;
- template <class U>
- allocator(const allocator<U>&) noexcept {};
- ~allocator() = default;
- pointer allocate(size_type size) {
- auto p = ::operator new(size * sizeof(value_type));
- return static_cast<pointer>(p);
- }
- void deallocate(pointer p, size_type n) noexcept {
- ::operator delete (p, n);
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement