Namespaces
Variants
Views
Actions

std::experimental::reflect::get_source_line

From cppreference.com
 
 
Experimental
Technical Specification
Filesystem library (filesystem TS)
Library fundamentals (library fundamentals TS)
Library fundamentals 2 (library fundamentals TS v2)
Library fundamentals 3 (library fundamentals TS v3)
Extensions for parallelism (parallelism TS)
Extensions for parallelism 2 (parallelism TS v2)
Extensions for concurrency (concurrency TS)
Extensions for concurrency 2 (concurrency TS v2)
Concepts (concepts TS)
Ranges (ranges TS)
Reflection (reflection TS)
Mathematical special functions (special functions TR)
Experimental Non-TS
Pattern Matching
Linear Algebra
std::execution
Contracts
2D Graphics
 
Extensions for reflection
Concepts
Meta-object operations
Variable
FunctionParameter
Callable
Variable and Callable
Namespace and Callable
ParenthesizedExpression
FunctionCallExpression
FunctionalConversion
Variable and Function
 
Defined in header <experimental/reflect>
template< Object T >
struct get_source_line;
(reflection TS)

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

Contents

[edit] Helper variable template

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

Inherited from std::integral_constant

Member constants

value
[static]
the presumed line number of the declaration of the entity or typedef-name 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()
(C++14)
returns value
(public member function)

Member types

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

[edit] Example

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

#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

[edit] See also

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