Namespaces
Variants
Views
Actions

Standard library header <memory>

From cppreference.com
< cpp‎ | header
Revision as of 13:38, 22 December 2012 by Bazzy (Talk | contribs)

This header is part of the dynamic memory management library.

Contents

Classes

Template:cpp/memory/dcl list unique ptrTemplate:cpp/memory/dcl list shared ptrTemplate:cpp/memory/dcl list weak ptrTemplate:cpp/memory/dcl list auto ptrTemplate:cpp/memory/dcl list owner lessTemplate:cpp/memory/dcl list enable shared from thisTemplate:cpp/memory/dcl list bad weak ptrTemplate:cpp/memory/dcl list default deleteTemplate:cpp/memory/dcl list allocatorTemplate:cpp/memory/dcl list allocator traitsTemplate:cpp/memory/dcl list allocator arg tTemplate:cpp/memory/dcl list allocator argTemplate:cpp/memory/dcl list uses allocatorTemplate:cpp/memory/gc/dcl list pointer safetyTemplate:cpp/memory/dcl list pointer traitsTemplate:cpp/memory/shared ptr/dcl list hashTemplate:cpp/memory/unique ptr/dcl list hashTemplate:cpp/memory/dcl list allocator arg
Smart pointers categories
Smart pointers helper classes
Allocators
Other
Forward declaration
Defined in header <functional>
(C++11)
hash function object
(class template) [edit]

Constants

Functions

Template:cpp/memory/dcl list uninitialized copyTemplate:cpp/memory/dcl list uninitialized copy nTemplate:cpp/memory/dcl list uninitialized fillTemplate:cpp/memory/dcl list uninitialized fill nTemplate:cpp/memory/dcl list raw storage iteratorTemplate:cpp/memory/dcl list get temporary bufferTemplate:cpp/memory/dcl list return temporary bufferTemplate:cpp/memory/gc/dcl list declare reachableTemplate:cpp/memory/gc/dcl list undeclare reachableTemplate:cpp/memory/gc/dcl list declare no pointersTemplate:cpp/memory/gc/dcl list undeclare no pointersTemplate:cpp/memory/gc/dcl list get pointer safetyTemplate:cpp/memory/dcl list addressofTemplate:cpp/memory/dcl list alignTemplate:cpp/memory/shared ptr/dcl list make sharedTemplate:cpp/memory/shared ptr/dcl list allocate sharedTemplate:cpp/memory/shared ptr/dcl list pointer castTemplate:cpp/memory/shared ptr/dcl list get deleterTemplate:cpp/memory/shared ptr/dcl list operator cmpTemplate:cpp/memory/shared ptr/dcl list operator ltltTemplate:cpp/memory/shared ptr/dcl list swap2
Uninitialized storage
Garbage collector support
Miscellaneous
Smart pointer non-member operations
Template:cpp/memory/shared ptr/dcl list atomic
Template:cpp/memory/unique ptr/dcl list operator cmpTemplate:cpp/memory/unique ptr/dcl list swap2Template:cpp/memory/weak ptr/dcl list swap2Template:cpp/memory/allocator/dcl list operator cmpTemplate:cpp/memory/scoped allocator adaptor/dcl list operator cmp
Allocator non-member operations

Synopsis

namespace std {
    // pointer traits
    template <class Ptr> struct pointer_traits;
    template <class T> struct pointer_traits<T*>;
 
    // pointer safety
    enum class pointer_safety { relaxed, preferred, strict };
    void declare_reachable(void *p);
    template <class T> T *undeclare_reachable(T *p);
    void declare_no_pointers(char *p, size_t n);
    void undeclare_no_pointers(char *p, size_t n);
    pointer_safety get_pointer_safety() noexcept;
 
    // pointer alignment function
    void *align(std::size_t alignment, std::size_t size,
                void *&ptr, std::size_t& space);
 
    // allocator argument tag
    struct allocator_arg_t { };
    constexpr allocator_arg_t allocator_arg = allocator_arg_t();
 
    // uses_allocator
    template <class T, class Alloc> struct uses_allocator;
 
    // allocator traits
    template <class Alloc> struct allocator_traits;
 
    // the default allocator:
    template <class T> class allocator;
    template <> class allocator<void>;
    template <class T, class U>
        bool operator==(const allocator<T>&, const allocator<U>&) noexcept;
    template <class T, class U>
        bool operator!=(const allocator<T>&, const allocator<U>&) noexcept;
 
    // raw storage iterator:
    template <class OutputIterator, class T> class raw_storage_iterator;
 
    // temporary buffers:
    template <class T>
        pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept;
    template <class T>
        void return_temporary_buffer(T* p);
 
    // specialized algorithms:
    template <class T> T* addressof(T& r) noexcept;
    template <class InputIterator, class ForwardIterator>
        ForwardIterator uninitialized_copy(InputIterator first, InputIterator last,
                                           ForwardIterator result);
    template <class InputIterator, class Size, class ForwardIterator>
        ForwardIterator uninitialized_copy_n(InputIterator first, Size n,
                                             ForwardIterator result);
    template <class ForwardIterator, class T>
        void uninitialized_fill(ForwardIterator first, ForwardIterator last,
                                const T& x);
    template <class ForwardIterator, class Size, class T>
        ForwardIterator uninitialized_fill_n(ForwardIterator first, Size n, const T& x);
    // class template unique_ptr:
    template <class T> class default_delete;
    template <class T> class default_delete<T[]>;
    template <class T, class D = default_delete<T>> class unique_ptr;
    template <class T, class D> class unique_ptr<T[], D>;
 
    template <class T1, class D1, class T2, class D2>
        bool operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
    template <class T1, class D1, class T2, class D2>
        bool operator!=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
    template <class T1, class D1, class T2, class D2>
        bool operator<(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
    template <class T1, class D1, class T2, class D2>
        bool operator<=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
    template <class T1, class D1, class T2, class D2>
        bool operator>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
    template <class T1, class D1, class T2, class D2>
        bool operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
 
    template <class T, class D>
        bool operator==(const unique_ptr<T, D>& x, nullptr_t) noexcept;
    template <class T, class D>
        bool operator==(nullptr_t, const unique_ptr<T, D>& y) noexcept;
    template <class T, class D>
        bool operator!=(const unique_ptr<T, D>& x, nullptr_t) noexcept;
    template <class T, class D>
        bool operator!=(nullptr_t, const unique_ptr<T, D>& y) noexcept;
 
    template <class T, class D>
        bool operator<(const unique_ptr<T, D>& x, nullptr_t);
    template <class T, class D>
        bool operator<(nullptr_t, const unique_ptr<T, D>& y);
    template <class T, class D>
        bool operator<=(const unique_ptr<T, D>& x, nullptr_t);
    template <class T, class D>
        bool operator<=(nullptr_t, const unique_ptr<T, D>& y);
    template <class T, class D>
        bool operator>(const unique_ptr<T, D>& x, nullptr_t);
    template <class T, class D>
        bool operator>(nullptr_t, const unique_ptr<T, D>& y);
    template <class T, class D>
        bool operator>=(const unique_ptr<T, D>& x, nullptr_t);
    template <class T, class D>
        bool operator>=(nullptr_t, const unique_ptr<T, D>& y);
 
    // class bad_weak_ptr:
    class bad_weak_ptr;
 
    // class template shared_ptr:
    template<class T> class shared_ptr;
 
    // shared_ptr comparisons:
    template<class T, class U>
        bool operator==(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
    template<class T, class U>
        bool operator!=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
    template<class T, class U>
        bool operator<(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
    template<class T, class U>
        bool operator>(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
    template<class T, class U>
        bool operator<=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
    template<class T, class U>
        bool operator>=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
 
    template <class T>
        bool operator==(const shared_ptr<T>& x, nullptr_t) noexcept;
    template <class T>
        bool operator==(nullptr_t, const shared_ptr<T>& y) noexcept;
    template <class T>
        bool operator!=(const shared_ptr<T>& x, nullptr_t) noexcept;
    template <class T>
        bool operator!=(nullptr_t, const shared_ptr<T>& y) noexcept;
    template <class T>
        bool operator<(const shared_ptr<T>& x, nullptr_t) noexcept;
    template <class T>
        bool operator<(nullptr_t, const shared_ptr<T>& y) noexcept;
    template <class T>
        bool operator<=(const shared_ptr<T>& x, nullptr_t) noexcept;
    template <class T>
        bool operator<=(nullptr_t, const shared_ptr<T>& y) noexcept;
    template <class T>
        bool operator>(const shared_ptr<T>& x, nullptr_t) noexcept;
    template <class T>
    bool operator>(nullptr_t, const shared_ptr<T>& y) noexcept;
    template <class T>
        bool operator>=(const shared_ptr<T>& x, nullptr_t) noexcept;
    template <class T>
        bool operator>=(nullptr_t, const shared_ptr<T>& y) noexcept;
 
    // shared_ptr specialized algorithms:
    template<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b) noexcept;
 
    // shared_ptr casts:
    template<class T, class U>
        shared_ptr<T> static_pointer_cast(shared_ptr<U> const& r) noexcept;
    template<class T, class U>
        shared_ptr<T> dynamic_pointer_cast(shared_ptr<U> const& r) noexcept;
    template<class T, class U>
        shared_ptr<T> const_pointer_cast(shared_ptr<U> const& r) noexcept;
 
    // shared_ptr get_deleter:
    template<class D, class T> D* get_deleter(shared_ptr<T> const& p) noexcept;
 
    // shared_ptr I/O:
    template<class E, class T, class Y>
        basic_ostream<E, T>& operator<< (basic_ostream<E, T>& os, shared_ptr<Y> const& p);
 
    // class template weak_ptr:
    template<class T> class weak_ptr;
 
    // weak_ptr specialized algorithms:
    template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept;
 
    // class template owner_less:
    template<class T> class owner_less;
 
    // class template enable_shared_from_this:
    template<class T> class enable_shared_from_this;
 
    // shared_ptr atomic access:
    template<class T>
        bool atomic_is_lock_free(const shared_ptr<T>* p);
    template<class T>
        shared_ptr<T> atomic_load(const shared_ptr<T>* p);
    template<class T>
        shared_ptr<T> atomic_load_explicit(const shared_ptr<T>* p, memory_order mo);
    template<class T>
        void atomic_store(shared_ptr<T>* p, shared_ptr<T> r);
    template<class T>
        void atomic_store_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo);
    template<class T>
        shared_ptr<T> atomic_exchange(shared_ptr<T>* p, shared_ptr<T> r);
    template<class T>
        shared_ptr<T> atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r,
                                                memory_order mo);
    template<class T>
        bool atomic_compare_exchange_weak(
            shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T>  w);
    template<class T>
        bool atomic_compare_exchange_strong(
            shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T>  w);
    template<class T>
        bool atomic_compare_exchange_weak_explicit(
            shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w,
            memory_order success, memory_order failure);
    template<class T>
        bool atomic_compare_exchange_strong_explicit(
            shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w,
            memory_order success, memory_order failure);
 
    //  hash support
    template <class T> struct hash;
    template <class T, class D> struct hash<unique_ptr<T, D> >;
    template <class T> struct hash<shared_ptr<T> >;
 
    // auto_ptr (deprecated)
    template <class X> class auto_ptr;
}