Namespaces
Variants

std::experimental::reflect:: get_source_line

From cppreference.net
Extensions for reflection
Concepts
Meta-object operations
Variable
FunctionParameter
Callable
Variable and Callable
Namespace and Callable
ParenthesizedExpression
FunctionCallExpression
FunctionalConversion
Variable and Function
定义于头文件 <experimental/reflect>
template < Object T >
struct get_source_line ;
(reflection TS)

提供成员常量 value ,其值等于由 T 反射的实体或类型别名的 推定行号

目录

辅助变量模板

template < class T >
constexpr auto get_source_line_v = get_source_line < T > :: value ;
(反射TS)

继承自 std:: integral_constant

成员常量

value
[static]
T 反映的实体或类型别名声明的假定行号
(公开静态成员常量)

成员函数

operator std::uint_least32_t
转换对象为 std:: uint_least32_t ,返回 value
(公开成员函数)
operator()
(C++14)
返回 value
(公开成员函数)

成员类型

类型 定义
value_type std:: uint_least32_t
type std:: integral_constant < std:: uint_least32_t , value >

示例

以下代码展示了对象或类的源代码行号。

#include<experimental/reflect>
#include<iostream>
using refl = std::experimental::reflect;
float f;
struct P{};
int main()
{
    std::cout << refl::get_source_line_v<reflexpr(f)> << '\n';
    std::cout << refl::get_source_line_v<reflexpr(P)> << '\n';
}

输出:

6
7

参见

返回此对象所表示的行号
( std::source_location 的公开成员函数)
获取与 stacktrace_entry 所表示求值操作在词法层面相关的行号
( std::stacktrace_entry 的公开成员函数)