1. Proposal
This paper proposes that source_location from Library Fundamentals V3 [N4758] be adopted into the C++20 standard.
Note: A proposal [P0555R0] in 2017 to make use of 
2. A few design changes
During an early review of this papers, some interest in a few design changes arose:
2.1. Enforcing a size for source_location 
   No consensus in San Diego
A note states:
[ Note: The intent of source_location is to have a small size and efficient copying. — end note ]
However, there seems to be some interest for having 
While, as pointed out by Niall, it’s unlikely the two languages will have directly interoperable mechanisms,
having a guaranteed size for 
Barring that, 
For completeness, such modification could be achieved by adding one level of indirection:
struct __source_location_data { /* implementation defined */ }; struct source_location { private : const __source_location_data * __data ; }; 
Alternatively, source_location could return a const reference:
struct source_location { constexpr const source_location & current () noexcept ; }; 
The authors strongly prefer the first solution as we think retaining value semantics is important. It is also important to note that, while not implemented, the first solution has been considered and is deemed realistically implementable by both GCC and Clang developers (Jonathan Wakely, Eric Fiselier).
2.2. Removing current () 
   No consensus in San Diego
If LEWG elects to keep value semantics, the authors would like to propose that the 
void log ( auto && message , std :: source_location sc = std :: source_location :: current ()); //or void log ( auto && message , std :: source_location sc = {}); 
3. User-constructed source_location
In San Diego, it was suggested to add the following constructorSo that source_location can be constructed by users and other libraries (stacktrace ?) However,consteval source_location ( uint_least32_t line , uint_least32_t column , const char * filename , const char * function ); 
consteval filename function 
Therefore we suggested that this could be the subject of a separate paper to explore these lifetime issues
4. Proposed Wording
The following wording correspond to the wording as in [N4758] (Library fundamental), with the exception of making source_location::current() an immediate function as decided by LEWG in San Diego.
Notes To The Editor:
-  The <source_location> header in Library fundamental is part of a "Reflection" library that does not yet exist and may need to be created
or be placed elsewhere. 
-  The <source_location> header should be added to the list of freestanding headers 
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 ; }; } // namespace std 
 
static consteval source_location current () noexcept ; - Returns:
-  When invoked by a function call (C++17 §8.2.2 ) whosepostfix-expression is a (possibly parenthesized)id-expression namingcurrent source_location #line C++17 §19.4 ) in the same manner as for__LINE__ __FILE__ 
- Remarks:
- When a
brace-or-equal-initializer is used to initialize a non-static data member, any calls tocurrent [ Note: When used as a default argument ( C++17 §11.3.6 ), the value of thesource_location current [ Example: struct s { source_location member = source_location :: current (); int other_member ; s ( source_location loc = source_location :: current ()) : member ( loc ) // values of member will be from call-site {} s ( int blather ) : // values of member should be hereabouts other_member ( blather ) {} s ( double ) // values of member should be hereabouts {} }; void f ( source_location a = source_location :: current ()) { source_location b = source_location :: current (); // values in b represent this line } void g () { f (); // f ’s first argument corresponds to this line of code source_location c = source_location :: current (); f ( c ); // f ’s first argument gets the same values as c , above } — end example ] 
constexpr source_location () noexcept ; - Effects:
- Constructs an object of class source_location 
- Remarks:
- The values are implementation-defined.
constexpr uint_least32_t line () const noexcept ; - Returns:
- The presumed line number (C++17 §19.8 ) represented by this object.
constexpr uint_least32_t column () const noexcept ; - Returns:
- An implementation-defined value representing some offset from the start of the line represented by this object.
constexpr const char * file_name () const noexcept ; - Returns:
-  The presumed name of the current source file (C++17 §19.8 ) represented by this object as an NTBS.
constexpr const char * function_name () const noexcept ; - Returns:
- If this object represents a position in the body of a function, returns an implementation-defined NTBS that should correspond to the function name. Otherwise, returns an empty string.
5. Feature macro
Similarly to the original [n4417] wording, we recommend the feature test macro__cpp_lib_source_location 6. Acknowledgments
The authors would like to thanks the people who reviewed early version of this proposal, notably Peter Dimov, Jonathan Wakely Arthur O’Dwyer and Geoffrey Romer. We would also like to thank Herb Sutter and Niall Douglas for their insightful remarks on std::error and errors handling in general.