Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::experimental::reflect::get_source_line

      From cppreference.com
      <cpp‎ |experimental‎ |reflect
       
       
       
      Extensions for reflection
      Concepts
      Meta-object operations
      Variable
      FunctionParameter
      Callable
      Variable andCallable
      Namespace andCallable
      ParenthesizedExpression
      FunctionCallExpression
      FunctionalConversion
      Variable andFunction
       
      Defined in header<experimental/reflect>
      template< Object T>
      struct get_source_line;
      (reflection TS)

      Provides the member constantvalue equal to thepresumed line number of the declaration of the entity or typedef-name reflected byT.

      Contents

      [edit] Helper variable template

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

      Inherited fromstd::integral_constant

      Member constants

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

      Member functions

      operator std::uint_least32_t
      converts the object tostd::uint_least32_t, returnsvalue
      (public member function)
      operator()
      (C++14)
      returnsvalue
      (public member function)

      Member types

      Type Definition
      value_typestd::uint_least32_t
      typestd::integral_constant<std::uint_least32_t, value>

      [edit]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:

      67

      [edit]See also

      return the line number represented by this object
      (public member function ofstd::source_location)[edit]
      gets the line number that lexically relates the evaluation represented by thestacktrace_entry
      (public member function ofstd::stacktrace_entry)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/experimental/reflect/get_source_line&oldid=127093"

      [8]ページ先頭

      ©2009-2025 Movatter.jp