In the code below, if here()
stops being consteval
(either full RT, or constexpr
), then line()
is the line of invocation of f()
inside main()
. But with consteval
it's the definition of f()
. Where does this discrepancy come from?
#include <experimental/source_location>
#include <iostream>
consteval std::experimental::source_location here(
std::experimental::source_location loc = std::experimental::source_location::current())
{
return loc;
}
void f(const std::experimental::source_location& a = here())
{
std::cout << a.line() << std::endl; // will either print 17, or 10
}
int main()
{
f();
}