The class std::source_location, added in C++20, provides access to information about the calling context, such as file names, function names, and line numbers. It is an improvement on predefined macros such as __FILE__ and __LINE__ because those are macros. They get expanded in the referencing context, so can't be used to automatically determine the calling context for a function.
This would be useful to us when writing error checking functions, as the location of the call to that function can be obtained using source_location rather than needing to clutter all call sites with explicit __FILE__ and __LINE__ arguments, or use error checking macros that expand into such, or having the error output either not mention the context or mention the error checking function itself as the context.
While we aren't yet using C++20, most supported compilers have already implemented it in terms of a set of compiler intrinsics, and those compiler intrinsics are available for use even without enabling C++20. Moreover, all of gcc, clang, and Visual Studio use the same names for these intrinsics.
This would be useful to us when writing error checking functions, as the location of the call to that function can be obtained using source_location rather than needing to clutter all call sites with explicit __FILE__ and __LINE__ arguments, or use error checking macros that expand into such, or having the error output either not mention the context or mention the error checking function itself as the context.
While we aren't yet using C++20, most supported compilers have already implemented it in terms of a set of compiler intrinsics, and those compiler intrinsics are available for use even without enabling C++20. Moreover, all of gcc, clang, and Visual Studio use the same names for these intrinsics.