| Defined in header <meta>
|
||
consteval std::source_location source_location_of( std::meta::info r );
|
(since C++26) | |
Where possible, returns a source location of what r represents.
Formally:
- if
rrepresents a (scalar) value, a type other than class or enumeration type, the global namespace, or a data member description, returns a value-initializedstd::source_location. - Otherwise, returns an implementation-defined value.
If r represents an entity with a definition that is reachable from the evaluation context, the implementation is encouraged to return a value corresponding to a definition.
Parameters
| r | - | a reflection value |
Return value
A source location of what r represents, as described above.
Example
Run this code
#include <meta>
#include <iostream>
#include <source_location>
int main()
{
std::cout << '#' << source_location_of(^^main).line()
<< ' ' << source_location_of(^^main).function_name()
<< '\n';
}
Possible output:
#5 int main()
See also
[static] |
constructs a new source_location corresponding to the location of the call site (public static member function of std::source_location)
|