命名空間
變體
動作

std::experimental::pmr::resource_adaptor, std::pmr::experimental::resource_adaptor

出自 cppreference.com
 
 
實驗性
技術規範
檔案系統函式庫 (filesystem TS)
函式庫基礎 (library fundamentals TS)
函式庫基礎 2 (library fundamentals TS v2)
函式庫基礎 3 (library fundamentals TS v3)
平行化擴充 (parallelism TS)
平行化擴充 2 (parallelism TS v2)
並行化擴充 (concurrency TS)
並行化擴充 2 (concurrency TS v2)
概念 (concepts TS)
範圍 (ranges TS)
反射 (reflection TS)
數學特殊函數 (special functions TR)
實驗性非 TS
模式匹配
線性代數
std::execution
合約
2D 圖形
 
 
 
template< class Alloc >

using resource_adaptor = /*resource-adaptor-imp*/<
                             typename std::allocator_traits<Alloc>::

                             template rebind_alloc<char>>;
(函式庫基礎 TS)
template< class Alloc >
class /*resource-adaptor-imp*/ : public memory_resource; // 僅供說明使用
(函式庫基礎 TS)

別名模板 resource_adaptor 使用 memory_resource 介面來轉接配置器型別 Alloc。在實際進行轉接之前(使用 resource-adaptor-imp 類別模板),配置器會先被重新綁定(rebind)至 char 的值型別,因此無論原始配置器模板是使用何種值型別實例化的,對同一配置器模板進行轉接特例化時,總會得到相同的型別。

resource_adaptor 定義於命名空間 std::experimental::pmr 中,而本頁面中的基底型別 memory_resourcestd::experimental::pmr::memory_resource

(函式庫基礎 TS)
(直至 library fundamentals TS v3)

resource_adaptor 定義於命名空間 std::pmr::experimental 中,而本頁面中的基底型別 memory_resourcestd::pmr::memory_resource

(library fundamentals TS v3)

resource-adaptor-imp 是一個類別模板,其成員說明如下。名稱 resource-adaptor-imp 僅為說明目的,並非標準規範。

除了滿足 Allocator 需求外,Alloc 還必須滿足下列需求:

[編輯] 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)
1) 預設建構函式。預設建構封裝的配置器。
2) 複製建構函式。從 other 所封裝的配置器中複製建構封裝的配置器。
3) 移動建構函式。從 other 所封裝的配置器中移動建構封裝的配置器。
4) 使用 a2 初始化封裝的配置器。
5) 使用 std::move(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)

pdynamic_cast<const /*resource-adaptor-imp*/*>(&other)。若 p 為空指標值,傳回 false。否則,使用 operator== 比較 *p*this 所封裝的配置器,並傳回比較結果。

English Deutsch 日本語 中文(简体) 中文(繁體)