名稱空間
變體
操作

std::experimental::reflect::ObjectSequence

來自 cppreference.com
 
 
實驗性
技術規範
檔案系統庫 (檔案系統 TS)
庫基礎 (庫基礎 TS)
庫基礎 2 (庫基礎 TS v2)
庫基礎 3 (庫基礎 TS v3)
並行性擴充套件 (並行性 TS)
並行性擴充套件 2 (並行性 TS v2)
併發性擴充套件 (併發性 TS)
併發擴充套件 2 (併發 TS v2)
概念 (概念 TS)
範圍 (範圍 TS)
反射 (反射 TS)
數學特殊函式 (特殊函式 TR)
實驗性非 TS
模式匹配
線性代數
std::execution
契約
2D 圖形
 
反射擴充套件
概念
元物件操作
Variable
FunctionParameter
Callable
VariableCallable
NamespaceCallable
ParenthesizedExpression
FunctionCallExpression
FunctionalConversion
VariableFunction
 
定義於標頭檔案 <experimental/reflect>
template< class T >
concept ObjectSequence = Object<T> && /* 參見下方 */;
(反射 TS)

ObjectSequence 概念由元物件序列型別滿足。

元物件序列型別是一種元物件型別,它透過生成序列的元物件操作獲得,例如 get_data_members。元物件序列型別的每個元素都是一個元物件型別。

[編輯] 示例

#include<cmath>
#include<experimental/reflect>
#include<tuple>
#include<type_traits>
 
namespace reflect = std::experimental::reflect;
 
template<reflect::Typed... Ms>
using tuple_from_seq_t = std::tuple<reflect::get_reflected_type_t<
    reflect::get_type_t<Ms>>...>;
 
template<reflect::Record T>
using collect_tuple = reflect::unpack_sequence_t<
    tuple_from_seq_t,
    reflect::get_data_members_t<T>>;
 
int main()
{
    static_assert(reflect::ObjectSequence<
                      reflect::get_data_members<reflexpr(std::div_t)>>, "");
    static_assert(std::is_same<collect_tuple<reflexpr(std::div_t)>,
                               std::tuple<int, int>>::value, "");
}

[編輯] 參閱