Scroll to navigation

std::experimental::reflect::get_source_line(3) C++ Standard Libary std::experimental::reflect::get_source_line(3)

NAME

std::experimental::reflect::get_source_line - std::experimental::reflect::get_source_line

Synopsis

Defined in header <experimental/reflect> template< Object T > (reflection TS) struct get_source_line;

Provides the member constant value equal to the presumed line number of the declaration of the entity or typedef-name reflected by T.


Helper variable template

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

Inherited from std::integral_constant

Member constants

value the presumed line number of the declaration of the entity or typedef-name [static] reflected by T
(public static member constant)

Member functions

operator std::uint_least32_t converts the object to std::uint_least32_t, returns value
(public member function) operator() returns value (C++14) (public member function)

Member types

Type Definition value_type std::uint_least32_t type std::integral_constant<std::uint_least32_t, value>

Example

The following code shows the source code line of an object or a class.

// Run this code

#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'; }

Output:

6 7

See also

line return the line number represented by this object
(public member function of std::source_location)
gets the line number that lexically relates the evaluation represented by the source_line stacktrace_entry
(public member function of std::stacktrace_entry)

2026.11.10 http://cppreference.com