std::experimental::source_location::line
Min standard notice:
Returns the line number represented by this object.
# Declarations
constexpr std::uint_least32_t line() const noexcept;
(library fundamentals TS v2)
# Return value
The line number represented by this object.
# Example
#include <experimental/source_location>
#include <iostream>
#include <string_view>
using std::experimental::source_location;
inline void cur_line(
const std::string_view message = "",
const source_location& location = source_location::current())
{
std::cout
<< location.line() // <- the call-site line #
<< ") "
<< message;
}
int main()
{
cur_line("++" "\n");
cur_line(); std::cout << "Hello," "\n";
cur_line(); std::cout << "C++20!" "\n";
cur_line("--" "\n");
}