17 Language support library [support]

17.8 Source location [support.srcloc]

17.8.2 Class source_­location [support.srcloc.class]

17.8.2.1 General [support.srcloc.class.general]

namespace std { struct source_location { // source location construction static consteval source_location current() noexcept; constexpr source_location() noexcept; // source location field access constexpr uint_least32_t line() const noexcept; constexpr uint_least32_t column() const noexcept; constexpr const char* file_name() const noexcept; constexpr const char* function_name() const noexcept; private: uint_least32_t line_; // exposition only uint_least32_t column_; // exposition only const char* file_name_; // exposition only const char* function_name_; // exposition only }; }
The type source_­location meets the Cpp17DefaultConstructible, Cpp17CopyConstructible, Cpp17CopyAssignable, and Cpp17Destructible requirements ([utility.arg.requirements]).
Lvalues of type source_­location are swappable ([swappable.requirements]).
All of the following conditions are true:
  • is_­nothrow_­move_­constructible_­v<source_­location>
  • is_­nothrow_­move_­assignable_­v<source_­location>
  • is_­nothrow_­swappable_­v<source_­location>
[Note 1:
The intent of source_­location is to have a small size and efficient copying.
It is unspecified whether the copy/move constructors and the copy/move assignment operators are trivial and/or constexpr.
— end note]
The data members file_­name_­ and function_­name_­ always each refer to an ntbs.
The copy/move constructors and the copy/move assignment operators of source_­location meet the following postconditions: Given two objects lhs and rhs of type source_­location, where lhs is a copy/move result of rhs, and where rhs_­p is a value denoting the state of rhs before the corresponding copy/move operation, then each of the following conditions is true:
  • strcmp(lhs.file_­name(), rhs_­p.file_­name()) == 0
  • strcmp(lhs.function_­name(), rhs_­p.function_­name()) == 0
  • lhs.line() == rhs_­p.line()
  • lhs.column() == rhs_­p.column()