命名空间
变体
操作

标准库头文件 <scoped_allocator> (C++11)

来自 cppreference.cn
< cpp‎ | header
 
 
标准库头文件
语言支持
<cfloat>
<climits>
<compare> (C++20)
<contracts> (C++26)
<coroutine> (C++20)
<csetjmp>
<csignal>
<cstdarg>
<cstddef>
<cstdint> (C++11)
<cstdlib>
<exception>
<initializer_list> (C++11)   
<limits>
<new>
<source_location> (C++20)
<stdfloat> (C++23)
<typeinfo>
<version> (C++20)
概念
<concepts> (C++20)
诊断
<cassert>
<cerrno>
<debugging> (C++26)
<stacktrace> (C++23)
<stdexcept>
<system_error> (C++11)
内存管理
<memory>
<memory_resource> (C++17)
<scoped_allocator> (C++11)
元编程
<type_traits> (C++11)
<ratio> (C++11)
通用工具
<any> (C++17)
<bitset>
<bit> (C++20)
<charconv> (C++17)
<expected> (C++23)
<format> (C++20)
<functional>
<optional> (C++17)
<tuple> (C++11)
<typeindex> (C++11)
<utility>
<variant> (C++17)
容器
<array> (C++11)
<deque>
<flat_map> (C++23)
<flat_set> (C++23)
<forward_list> (C++11)
<hive> (C++26)
<inplace_vector> (C++26)   
<list>
<map>
<mdspan> (C++23)
<queue>
<set>
<span> (C++20)
<stack>
<unordered_map> (C++11)
<unordered_set> (C++11)
<vector>
迭代器
<iterator>
范围
<generator> (C++23)
<ranges> (C++20)
算法
<algorithm>
<numeric>
字符串
<cctype>
<cstring>
<cuchar> (C++11)
<cwchar>
<cwctype>
<string_view> (C++17)
<string>
文本处理
<clocale>
<codecvt> C++11/17/26*)
<locale>
<regex> (C++11)
<text_encoding> (C++26)   
数值
<cfenv> (C++11)
<cmath>
<complex>
<linalg> (C++26)
<numbers> (C++20)
<random> (C++11)
<simd> (C++26)
<valarray>
时间
<chrono> (C++11)
<ctime>
C 兼容性
<ccomplex> C++11/17/20*)
<ciso646> (直到 C++20)
<cstdalign> C++11/17/20*)
<cstdbool> C++11/17/20*)
<ctgmath> C++11/17/20*)
输入/输出
<cinttypes> (C++11)
<cstdio>
<filesystem> (C++17)
<fstream>
<iomanip>
<iosfwd>
<iostream>
<ios>
<istream>
<ostream>
<print> (C++23)
<spanstream> (C++23)
<sstream>
<streambuf>
<strstream> C++98/26*)
<syncstream> (C++20)
并发支持
<atomic> (C++11)
<barrier> (C++20)
<condition_variable> (C++11)
<future> (C++11)
<hazard_pointer> (C++26)
<latch> (C++20)
<mutex> (C++11)
<rcu> (C++26)
<semaphore> (C++20)
<shared_mutex> (C++14)
<stdatomic.h> (C++23)
<stop_token> (C++20)
<thread> (C++11)
执行支持
<execution> (C++17)



 

此头文件是动态内存管理库的一部分。

目录

为多层容器实现多层分配器
(类模板) [编辑]

函数

(C++20 中移除)
比较两个 scoped_allocator_adaptor 对象
(函数模板) [编辑]

[编辑] 概要

namespace std {
  // class template scoped_allocator_adaptor
  template<class OuterAlloc, class... InnerAlloc>
    class scoped_allocator_adaptor;
 
  // scoped allocator operators
  template<class OuterA1, class OuterA2, class... InnerAllocs>
    bool operator==(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
                    const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept;
}

[编辑] 类模板 std::scoped_allocator_adaptor

namespace std {
  template<class OuterAlloc, class... InnerAllocs>
  class scoped_allocator_adaptor : public OuterAlloc {
  private:
    using OuterTraits = allocator_traits<OuterAlloc>;   // exposition only
    scoped_allocator_adaptor<InnerAllocs...> inner;     // exposition only
 
  public:
    using outer_allocator_type = OuterAlloc;
    using inner_allocator_type = /* see description */;
 
    using value_type           = typename OuterTraits::value_type;
    using size_type            = typename OuterTraits::size_type;
    using difference_type      = typename OuterTraits::difference_type;
    using pointer              = typename OuterTraits::pointer;
    using const_pointer        = typename OuterTraits::const_pointer;
    using void_pointer         = typename OuterTraits::void_pointer;
    using const_void_pointer   = typename OuterTraits::const_void_pointer;
 
    using propagate_on_container_copy_assignment = /* see description */;
    using propagate_on_container_move_assignment = /* see description */;
    using propagate_on_container_swap            = /* see description */;
    using is_always_equal                        = /* see description */;
 
    template<class Tp> struct rebind {
      using other = scoped_allocator_adaptor<
        OuterTraits::template rebind_alloc<Tp>, InnerAllocs...>;
    };
 
    scoped_allocator_adaptor();
    template<class OuterA2>
      scoped_allocator_adaptor(OuterA2&& outerAlloc,
                               const InnerAllocs&... innerAllocs) noexcept;
 
    scoped_allocator_adaptor(const scoped_allocator_adaptor& other) noexcept;
    scoped_allocator_adaptor(scoped_allocator_adaptor&& other) noexcept;
 
    template<class OuterA2>
      scoped_allocator_adaptor(
        const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& other) noexcept;
    template<class OuterA2>
      scoped_allocator_adaptor(
        scoped_allocator_adaptor<OuterA2, InnerAllocs...>&& other) noexcept;
 
    scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default;
    scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default;
 
    ~scoped_allocator_adaptor();
 
    inner_allocator_type& inner_allocator() noexcept;
    const inner_allocator_type& inner_allocator() const noexcept;
    outer_allocator_type& outer_allocator() noexcept;
    const outer_allocator_type& outer_allocator() const noexcept;
 
    pointer allocate(size_type n);
    pointer allocate(size_type n, const_void_pointer hint);
    void deallocate(pointer p, size_type n);
    size_type max_size() const;
 
    template<class T, class... Args>
      void construct(T* p, Args&&... args);
 
    template<class T>
      void destroy(T* p);
 
    scoped_allocator_adaptor select_on_container_copy_construction() const;
  };
 
  template<class OuterAlloc, class... InnerAllocs>
    scoped_allocator_adaptor(OuterAlloc, InnerAllocs...)
      -> scoped_allocator_adaptor<OuterAlloc, InnerAllocs...>;
}