std::source...ion::column(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

✨ NAME ✨

Okay bestie, this is the manual page for std::source_location::column β€” and the manual name up top is C++ Standard Libary, folded in here like a little name tag so we don’t copy that header line. πŸ’…

The NAME line is literally std::source_location::column - std::source_location::column, and honestly? No notes. Iconic. πŸŽ€


πŸ¦‹ Synopsis πŸ¦‹

constexpr std::uint_least32_t column() const noexcept;  (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. ⭐

🌼 Parameters 🌼

  • (none) β€” not a single parameter, periodt. πŸ’€

πŸ’– 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 use 0 when the column number is unknown. πŸ‘‘

🌸 Example 🌸

// Run this code

#include <iostream>
#include <source_location>

template<typename T = std::source_location>
inline void 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

πŸ”₯ See also πŸ”₯

  • line β€” return the line number represented by this object (public member function)
  • file_name β€” return the file name represented by this object (public member function)
  • function_name β€” return the name of the function represented by this object, if any (public member function)
  • Filename and line information

That’s the whole page, bestie. Source/version: http://cppreference.com; date: 2024.06.10. Now go flex that column number πŸ’…βœ¨

πŸ“¦ where this page comes from