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 によって反映されるエンティティまたはtypedef名の宣言のものです。

目次

翻訳のポイント: - HTMLタグ、属性、 内のテキストは翻訳せず保持 - C++固有の用語("Helper variable template"、"std::integral_constant")は翻訳せず保持 - 一般的な技術文書の用語を適切に日本語化("Contents"→"目次"、"Inherited from"→"からの継承"など) - プロフェッショナルな技術文書としての正確性を維持

ヘルパー変数テンプレート

template < class T >
constexpr auto get_source_line_v = get_source_line < T > :: value ;
(リフレクションTS)

std:: integral_constant から継承

メンバ定数

value
[static]
T によって反映されるエンティティまたはtypedef名の宣言の推定行番号
(public static member constant)

メンバ関数

operator std::uint_least32_t
std:: uint_least32_t に変換し、 value を返す
(public member function)
operator()
(C++14)
value を返す
(public member function)

メンバ型

定義
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 の公開メンバ関数)