Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::allocator_traits<Alloc>::destroy

      From cppreference.com
      <cpp‎ |memory‎ |allocator traits
       
       
      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 T>
      staticvoid destroy( Alloc& a, T* p);
      (since C++11)
      (constexpr since C++20)

      Calls the destructor of the object pointed to byp. If possible, does so by callinga.destroy(p). If not possible (e.g.Alloc does not have the member functiondestroy()), then callsthe destructor of*p directly, asp->~T()(until C++20)std::destroy_at(p)(since C++20).

      Contents

      [edit]Parameters

      a - allocator to use for destruction
      p - pointer to the object being destroyed

      [edit]Return value

      (none)

      [edit]Notes

      Because this function provides the automatic fall back to direct call to the destructor, the member functiondestroy() is an optionalAllocator requirement since C++11.

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]See also

      (until C++20)
      destructs an object in allocated storage
      (public member function ofstd::allocator<T>)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/memory/allocator_traits/destroy&oldid=173089"

      [8]ページ先頭

      ©2009-2025 Movatter.jp