Namespaces
Variants

Standard library header <source_location> (C++20)

From cppreference.net
Standard library headers

此头文件属于 utility 库的一部分。

表示源代码信息的类,如文件名、行号和函数名
(类)

概要

namespace std {
  struct source_location;
}

std::source_location

namespace std {
  struct source_location {
    // 源码位置构造
    static consteval source_location current() noexcept;
    constexpr source_location() noexcept;
    // 源码位置字段访问
    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_;               // 仅用于说明
    uint_least32_t column_;             // 仅用于说明
    const char* file_name_;             // 仅用于说明
    const char* function_name_;         // 仅用于说明
  };
}