Skip to content

Latest commit

 

History

History
62 lines (45 loc) · 1.15 KB

deallocate.md

File metadata and controls

62 lines (45 loc) · 1.15 KB

deallocate

  • memory[meta header]
  • std[meta namespace]
  • allocator_traits[meta class]
  • function[meta id-type]
  • cpp11[meta cpp]
static void deallocate(Alloc& a, pointer p, size_type n);               // C++17 まで
static constexpr void deallocate(Alloc& a, pointer p, size_type n);     // C++20 から

概要

メモリを解放する。

効果

a.deallocate(p, n)

例外

投げない

#include <memory>

int main()
{
  std::allocator<int> alloc;
  using traits = std::allocator_traits<decltype(alloc)>;

  // 10要素のint領域を確保する
  std::size_t n = 10;
  int* p = traits::allocate(alloc, n);

  // 確保したメモリを解放する
  traits::deallocate(alloc, p, n);
}
  • deallocate[color ff0000]
  • traits::allocate[link allocate.md]

出力

バージョン

言語

  • C++11

処理系

参照