virtual bool do_is_equal(const memory_resource& other) const noexcept = 0;
概要
今のオブジェクト(this)で確保(allocate)したメモリ領域が、otherによって解放(deallocate)でき、その逆も可能かをチェックする。
引数
other-- チェックするmemory_resourceオブジェクト
戻り値
this->allocate()で確保したメモリ領域をother.deallocate()で問題なく解放でき、その逆も可能な場合にtrueを返す。
thisとotherの指すオブジェクトは必ずしも同じ型ではない可能性があるので、実装ではdynamic_castによってthisとotherの指すオブジェクトの型が一致することをチェックし、さもなければ直ちにfalseを返す必要がある。
つまり、あるmemory_resourceの実装(派生クラス)Dはこの関数実装内で最初にdynamic_cast<const D*>(&other) == nullptrをチェックし、結果がtrueならば直ちにfalseを返すようにする必要がある。
バージョン
言語
- C++17
処理系
- Clang: ??
- GCC: 9.1 ✅
- Visual C++: 2017 update 6 ✅