名稱空間
變體
操作

std::experimental::reflect::Object

來自 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 Object = /* 參見下文 */;
(反射 TS)

當且僅當 T 是元物件型別時,Object 概念才滿足。

[編輯] 示例

#include <experimental/reflect>
 
namespace reflect = std::experimental::reflect;
 
template<reflect::Object M>
struct meta_t {
    template<reflect::Object M1>
    friend constexpr bool operator==(meta_t, meta_t<M1>) noexcept
    {
        return reflect::reflects_same_v<M, M1>;
    }
    template<reflect::Object M1>
    friend constexpr bool operator!=(meta_t, meta_t<M1>) noexcept
    {
        return !reflect::reflects_same_v<M, M1>;
    }
};
 
template<reflect::Object M>
constexpr meta_t<M> meta{};
 
int main()
{
    static_assert(meta<reflexpr(int)> == meta<reflexpr(signed int)>, "");
    // meta<int>; // error: int is not a meta-object type
}