3 ms·
So, one issue is that source_location is not a valid non-type template parameter as it is not a structural type. But you can trivially make one yourself if you
by gpderetta 3y ago
So, one issue is that source_location is not a valid non-type template parameter as it is not a structural type. But you can trivially make one yourself if you chose an upper bound on the filename (and function name) size.
The second issue is that it seems that default values for non-type template parameters are not evaluated at the instantiation location, but at the definition location, so you need to make the template parameter explicit. This is the best I could come up with:
log<o>("hello", "world") // at example.cpp:30
which prints[1]:
app/example.cpp:30: hello world
[1] https://godbolt.org/z/z1eGc6cM4 https://godbolt.org/z/z1eGc6cM4