Skip to content

Latest commit

 

History

History
35 lines (26 loc) · 1.49 KB

File metadata and controls

35 lines (26 loc) · 1.49 KB

do_is_equal

  • memory_resource[meta header]
  • function[meta id-type]
  • std::pmr[meta namespace]
  • memory_resource[meta class]
  • cpp17[meta cpp]
virtual bool do_is_equal(const memory_resource& other) const noexcept = 0;

概要

今のオブジェクト(this)で確保(allocate)したメモリ領域が、otherによって解放(deallocate)でき、その逆も可能かをチェックする。

引数

  • other -- チェックするmemory_resourceオブジェクト

戻り値

this->allocate()で確保したメモリ領域をother.deallocate()で問題なく解放でき、その逆も可能な場合にtrueを返す。

thisotherの指すオブジェクトは必ずしも同じ型ではない可能性があるので、実装ではdynamic_castによってthisotherの指すオブジェクトの型が一致することをチェックし、さもなければ直ちにfalseを返す必要がある。

つまり、あるmemory_resourceの実装(派生クラス)Dはこの関数実装内で最初にdynamic_cast<const D*>(&other) == nullptrをチェックし、結果がtrueならば直ちにfalseを返すようにする必要がある。

バージョン

言語

  • C++17

処理系

関連項目