Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::allocator_traits

      From cppreference.com
      <cpp‎ |memory
       
       
      Memory management library
      (exposition only*)
      Allocators
      Uninitialized memory algorithms
      Constrained uninitialized memory algorithms
      Memory resources
      Uninitialized storage(until C++20)
      (until C++20*)
      (until C++20*)
      Garbage collector support(until C++23)
      (C++11)(until C++23)
      (C++11)(until C++23)
      (C++11)(until C++23)
      (C++11)(until C++23)
      (C++11)(until C++23)
      (C++11)(until C++23)
       
       
      Defined in header<memory>
      template<class Alloc>
      struct allocator_traits;
      (since C++11)

      Theallocator_traits class template provides the standardized way to access various properties ofAllocators. The standard containers and other standard library components access allocators through this template.

      It is possible to use any class type as an allocator, as long as the user-provided specialization ofstd::allocator_traits implements all required functionality.

      (until C++23)

      A program that declares an explicit or partial specialization ofstd::allocator_traits is ill-formed, no diagnostic required.

      (since C++23)

      The default, non-specialized,std::allocator_traits contains the following members:

      Contents

      [edit]Member types

      Type Definition
      allocator_typeAlloc
      value_typeAlloc::value_type
      pointerAlloc::pointer if present, otherwisevalue_type*
      const_pointerAlloc::const_pointer if present, otherwisestd::pointer_traits<pointer>::rebind<const value_type>
      void_pointerAlloc::void_pointer if present, otherwisestd::pointer_traits<pointer>::rebind<void>
      const_void_pointerAlloc::const_void_pointer if present, otherwisestd::pointer_traits<pointer>::rebind<constvoid>
      difference_typeAlloc::difference_type if present, otherwisestd::pointer_traits<pointer>::difference_type
      size_typeAlloc::size_type if present, otherwisestd::make_unsigned<difference_type>::type
      propagate_on_container_copy_assignmentAlloc::propagate_on_container_copy_assignment if present, otherwisestd::false_type
      propagate_on_container_move_assignmentAlloc::propagate_on_container_move_assignment if present, otherwisestd::false_type
      propagate_on_container_swapAlloc::propagate_on_container_swap if present, otherwisestd::false_type
      is_always_equalAlloc::is_always_equal if present, otherwisestd::is_empty<Alloc>::type

      [edit]Member alias templates

      Type Definition
      rebind_alloc<T>Alloc::rebind<T>::other if present, otherwiseSomeAllocator<T, Args> if thisAlloc is of the formSomeAllocator<U, Args>, whereArgs is zero or moretype arguments
      rebind_traits<T>std::allocator_traits<rebind_alloc<T>>

      [edit]Member functions

      [static]
      allocates uninitialized storage using the allocator
      (public static member function)[edit]
      [static](C++23)
      allocates storage at least as large as the requested size via an allocator
      (public static member function)[edit]
      [static]
      deallocates storage using the allocator
      (public static member function)[edit]
      [static]
      constructs an object in the allocated storage
      (function template)[edit]
      [static]
      destructs an object stored in the allocated storage
      (function template)[edit]
      [static]
      returns the maximum object size supported by the allocator
      (public static member function)[edit]
      obtains the allocator to use after copying a standard container
      (public static member function)[edit]

      [edit]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

      DRApplied toBehavior as publishedCorrect behavior
      LWG 2108C++11there was no way to show an allocator is statelessis_always_equal provided

      [edit]See also

      container using allocator; associated traits (e.g.propagate_on_container_swap) usage
      (named requirement)
      the default allocator
      (class template)[edit]
      implements multi-level allocator for multi-level containers
      (class template)[edit]
      provides information about pointer-like types
      (class template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/memory/allocator_traits&oldid=183386"

      [8]ページ先頭

      ©2009-2025 Movatter.jp