> You need to know the size at compile time. std::source_location::file_name() gives you a const char* – you don’t know the size of the string. And because it has to be a function argument, it can’t be constexpr.
At least this part is not entirely correct, the following compiles in C++20:
consteval std::string_view filename(const std::source_location &loc = std::source_location::current()) {
return loc.file_name();
}
See [0]. I don't know how to go from here to a type, as the author wants, but I'll venture that there's some ungodly template metaprogramming hack that will get you there.