Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::source_location::column

      From cppreference.com
      <cpp‎ |utility‎ |source location
       
       
      Utilities library
       
       
      constexprstd::uint_least32_t column()constnoexcept;
      (since C++20)

      Returns an implementation-defined value representing some offset from the start of the line represented by this object (i.e., the column number). Column numbers are presumed to be 1-indexed.

      Contents

      [edit]Parameters

      (none)

      [edit]Return value

      An implementation-defined value representing some offset from the start of the line represented by this object (i.e., the column number).

      An implementation is encouraged to use0 when the column number is unknown.

      [edit]Example

      Run this code
      #include <iostream>#include <source_location> template<typename T=std::source_location>inlinevoid pos(const T& location= T::current()){std::cout<<"("<< location.line()<<':'<< location.column()<<") ";} int main(){//      ↓: column #9    pos();std::cout<<"Proxima\n";// row #18      pos();std::cout<<"Centauri\n";// row #19//        ↑: column #11}

      Possible output:

      (18:9) Proxima(19:11) Centauri

      [edit]See also

      return the line number represented by this object
      (public member function)[edit]
      return the file name represented by this object
      (public member function)[edit]
      return the name of the function represented by this object, if any
      (public member function)[edit]
      Filename and line information
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/utility/source_location/column&oldid=150208"

      [8]ページ先頭

      ©2009-2026 Movatter.jp