cpp/memory/memory resource/do is equal: Difference between revisions
From cppreference.com
mNo edit summary |
|||
| (4 intermediate revisions by 4 users not shown) | |||
| Line 2: | Line 2: | ||
{{cpp/memory/memory_resource/navbar}} | {{cpp/memory/memory_resource/navbar}} | ||
{{ddcl|since=c++17|1= | {{ddcl|since=c++17|1= | ||
virtual bool do_is_equal(const std::pmr::memory_resource& other) const noexcept = 0; | virtual bool do_is_equal( const std::pmr::memory_resource& other ) const noexcept = 0; | ||
}} | }} | ||
Compares {{ | Compares {{|*this}} for equality with {{|other}}. | ||
Two {{tt|memory_resource}}s compare equal if and only if memory allocated from one {{tt|memory_resource}} can be deallocated from the other and vice versa. | Two {{tt|memory_resource}}s compare equal if and only if memory allocated from one {{tt|memory_resource}} can be deallocated from the other and vice versa. | ||
=== Notes === | === Notes === | ||
The most-derived type of {{ | The most-derived type of {{|other}} may not match the most derived type of {{|*this}}. A derived class implementation therefore must typically check whether the most derived types of {{|*this}} and {{|other}} match using {{|dynamic_cast}}, and immediately return {{|false}} if the cast fails. | ||
=== See also === | === See also === | ||
{{dsc begin}} | {{dsc begin}} | ||
{{dsc inc| cpp/memory/memory_resource/dsc is_equal}} | {{dsc inc|cpp/memory/memory_resource/dsc is_equal}} | ||
{{dsc end}} | {{dsc end}} | ||
{{langlinks|zh}} | {{langlinks|zh}} | ||