Skip to content

Latest commit

 

History

History
60 lines (50 loc) · 1.35 KB

File metadata and controls

60 lines (50 loc) · 1.35 KB

operator==

  • memory_resource[meta header]
  • std::pmr[meta namespace]
  • function[meta id-type]
  • cpp17[meta cpp]
namespace std::pmr {
  template <class T1, class T2>
  bool operator==(const polymorphic_allocator<T1>& a,
                  const polymorphic_allocator<T2>& b) noexcept;
}

概要

2つのpolymorphic_allocatorオブジェクトを等値比較する。

戻り値

*a.resource() == *b.resource()

#include <iostream>
#include <memory_resource>

int main()
{
  auto mr = std::pmr::monotonic_buffer_resource{};
  std::pmr::polymorphic_allocator<int> alloc{ &mr };
  std::pmr::polymorphic_allocator<int> alloc2{};
  std::pmr::polymorphic_allocator<double> alloc3{ &mr };

  std::cout << std::boolalpha;
  std::cout << (alloc == alloc2) << std::endl;
  std::cout << (alloc == alloc) << std::endl;
  //同じmemory_resourceを利用していればtrue
  std::cout << (alloc == alloc3) << std::endl;
}
  • ==[color ff0000]
  • monotonic_buffer_resource[link /reference/memory_resource/monotonic_buffer_resource.md]

出力

false
true
true

バージョン

言語

  • C++17

処理系

関連項目