名稱空間
變體
操作

std::experimental::ranges::value_type

來自 cppreference.com
< cpp‎ | experimental‎ | ranges
 
 
實驗性
技術規範
檔案系統庫 (檔案系統 TS)
庫基礎 (庫基礎 TS)
庫基礎 2 (庫基礎 TS v2)
庫基礎 3 (庫基礎 TS v3)
並行性擴充套件 (並行性 TS)
並行性擴充套件 2 (並行性 TS v2)
併發性擴充套件 (併發性 TS)
併發擴充套件2 (併發TS v2)
概念 (概念 TS)
範圍 (範圍 TS)
反射 (反射 TS)
數學特殊函式 (特殊函式 TR)
實驗性非 TS
模式匹配
線性代數
std::execution
契約
2D 圖形
 
 
迭代器庫
迭代器概念
間接可呼叫概念
                                                  
                                                  
                                                  
常用演算法要求
                                                  
概念工具
迭代器工具與操作
迭代器特徵
迭代器介面卡
流迭代器
 
定義於標頭檔案 <experimental/ranges/iterator>
template< class I >
struct value_type {};
(1)
template< class T >
struct value_type<T*>;
(2)
template< class I >

    requires std::is_array<I>::value

struct value_type<I> : value_type<std::decay_t<I>> {};
(3)
template< class T >
struct value_type<const T> : value_type<std::decay_t<T>> {};
(4)
template< class T >

    requires requires { typename T::value_type; }

struct value_type<T>;
(5)
template< class T >

    requires requires { typename T::element_type; }

struct value_type<T>;
(6)

計算型別 I 的關聯值型別(如果存在)。使用者可以為程式定義的型別特化 value_type

1) 主模板是一個空結構體。
2) 指標的特化。如果 T 是一個物件型別,則提供一個成員型別 type,其等於 std::remove_cv_t<T>。否則,沒有成員 type
3) 陣列型別的特化。
4) const 限定型別的特化。
5) 為定義了公共可訪問成員型別 value_type 的型別進行特化。如果 T::value_type 是一個物件型別,則提供一個成員型別 type,其等於 T::value_type。否則,沒有成員 type
6) 為定義了公共可訪問成員型別 element_type 的型別進行特化(例如,std::shared_ptr)。如果 T::element_type 是一個物件型別,則提供一個成員型別 type,其等於 std::remove_cv_t<typename T::element_type>。否則,沒有成員 type

目錄

[編輯] 輔助別名模板

template< class T >
using value_type_t = typename ranges::value_type<T>::type;
(Ranges TS)

[編輯] 注意

如果一個型別同時包含 value_type 成員和 element_type 成員,那麼特化 (5)(6) 會產生歧義。

value_type 旨在用於 Readable 型別,例如迭代器。它不打算用於範圍。

[編輯] 示例

[編輯] 參閱

指定型別透過應用運算子 * 可讀
(概念) [編輯]
收集迭代器相關型別的相容性特徵類
(別名模板)[編輯]