std::source_location Library in C++20

Understand the details of 'std::source_location' with an example.

std::source_location represents information about the source code. This information includes file names, line numbers, and function names. This information about the call site is very valuable for debugging, logging, or testing purposes. The class std::source_location is the better alternative than the predefined C++11 macros __FILE__ and __LINE__ and should be used instead.

std::source_location can give you the following information.

Get hands-on with 1400+ tech skills courses.