std::source_location::column - cppreference.com (original) (raw)
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.
[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 use 0 when the column number is unknown.
[edit] Example
#include #include template 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