- 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
- Clang: ??
- GCC: 9.1
- Visual C++: 2017 update 6