std::experimental::source_location::line
From cppreference.com
 
 
 < cpp | experimental | source location 
 
 
 C++ 
 Feature test macros (C++20)
 Concepts library (C++20)
 Metaprogramming library (C++11)
 Ranges library (C++20)
 Filesystem library (C++17)
 Concurrency support library (C++11)
 Execution control library (C++26)
Experimental 
 Filesystem library (filesystem TS)
 Library fundamentals (library fundamentals TS)
 Library fundamentals 2 (library fundamentals TS v2)
 Library fundamentals 3 (library fundamentals TS v3)
 Extensions for parallelism (parallelism TS)
 Extensions for parallelism 2 (parallelism TS v2)
 Extensions for concurrency (concurrency TS)
 Extensions for concurrency 2 (concurrency TS v2)
 Concepts (concepts TS)
 Ranges (ranges TS)
 Reflection (reflection TS)
 Mathematical special functions (special functions TR)
std::experimental::source_location 
 
 Creation
 Field Access
source_location::line
constexpr std::uint_least32_t line() const noexcept;
 
 (library fundamentals TS v2) 
Returns the line number represented by this object.
Contents
[edit] Parameters
(none)
[edit] Return value
The line number represented by this object.
[edit] Example
Run this code
#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"); }
Output:
18) ++ 19) Hello, 20) C++20! 21) --
[edit] See also
C++ documentation  for Filename and line information