std::experimental::pmr::resource_adaptor, std::pmr::experimental::resource_adaptor
| template< class Alloc > using resource_adaptor = /*resource-adaptor-imp*/< |
(函式庫基礎 TS) | |
| template< class Alloc > class /*resource-adaptor-imp*/ : public memory_resource; // 僅供說明使用 |
(函式庫基礎 TS) | |
別名模板 resource_adaptor 使用 memory_resource 介面來轉接配置器型別 Alloc。在實際進行轉接之前(使用 resource-adaptor-imp 類別模板),配置器會先被重新綁定(rebind)至 char 的值型別,因此無論原始配置器模板是使用何種值型別實例化的,對同一配置器模板進行轉接特例化時,總會得到相同的型別。
|
|
(函式庫基礎 TS) (直至 library fundamentals TS v3) |
|
|
(library fundamentals TS v3) |
resource-adaptor-imp 是一個類別模板,其成員說明如下。名稱 resource-adaptor-imp 僅為說明目的,並非標準規範。
除了滿足 Allocator 需求外,Alloc 還必須滿足下列需求:
- std::allocator_traits<Alloc>::pointer 必須等同於 Alloc::value_type*。
- std::allocator_traits<Alloc>::const_pointer 必須等同於 Alloc::value_type const*。
- std::allocator_traits<Alloc>::void_pointer 必須等同於 void*。
- std::allocator_traits<Alloc>::const_void_pointer 必須等同於 void const*。
[編輯] resource-adaptor-imp 的成員型別
| 成員型別 | 定義 |
allocator_type
|
Alloc
|
[編輯] resource-adaptor-imp 的成員函數
resource-adaptor-imp::resource-adaptor-imp
| /*resource-adaptor-imp*/() = default; |
(1) | (函式庫基礎 TS) |
| /*resource-adaptor-imp*/(const /*resource-adaptor-imp*/& other) = default; |
(2) | (函式庫基礎 TS) |
| /*resource-adaptor-imp*/(/*resource-adaptor-imp*/&& other) = default; |
(3) | (函式庫基礎 TS) |
| explicit /*resource-adaptor-imp*/(const Alloc& a2); |
(4) | (函式庫基礎 TS) |
| explicit /*resource-adaptor-imp*/(Alloc&& a2); |
(5) | (函式庫基礎 TS) |
other 所封裝的配置器中複製建構封裝的配置器。other 所封裝的配置器中移動建構封裝的配置器。a2 初始化封裝的配置器。參數
| 其他 | - | 另一個用於複製或移動的 resource-adaptor-imp 物件 |
| a2 | - | 另一個用於複製或移動的 Alloc 物件 |
resource-adaptor-imp::get_allocator
| allocator_type get_allocator() const; |
(函式庫基礎 TS) | |
傳回封裝配置器的一份複本。
resource-adaptor-imp::operator=
| /*resource-adaptor-imp*/& operator=(const /*resource-adaptor-imp*/& other) = default; |
(函式庫基礎 TS) | |
預設的複製賦值運算子。從 other 的配置器中複製賦值封裝的配置器。
resource-adaptor-imp::do_allocate
| protected: virtual void* do_allocate(std::size_t bytes, std::size_t alignment); |
(函式庫基礎 TS) | |
使用封裝配置器的 allocate 成員函數來分配記憶體。
resource-adaptor-imp::do_deallocate
| protected: virtual void do_deallocate(void *p, std::size_t bytes, std::size_t alignment); |
(函式庫基礎 TS) | |
使用封裝配置器的 deallocate 成員函數來解除分配 p 所指向的儲存空間。
p 必須是使用與封裝配置器等價的配置器之 allocate 成員函數所分配,且之後尚未被解除分配。
resource-adaptor-imp::do_is_equal
| protected: virtual bool do_is_equal(const memory_resource& other) const noexcept; |
(函式庫基礎 TS) | |
令 p 為 dynamic_cast<const /*resource-adaptor-imp*/*>(&other)。若 p 為空指標值,傳回 false。否則,使用 operator== 比較 *p 與 *this 所封裝的配置器,並傳回比較結果。