Open hugary1995 opened 3 weeks ago
Current min clang 10.0.1 and min (redhat) gcc 8.5.0 don't like a conversion function to path. The error messages are like
note: while substituting deduced template arguments into function template 'path' [with _Source = FileName, _Require = (no value)]
print_filename(f);
^
/opt/compiler-explorer/gcc-9.3.0/lib/gcc/x86_64-linux-gnu/9.3.0/../../../../include/c++/9.3.0/bits/fs_path.h:93:7: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
__is_path_src(const basic_string<_CharT, _Traits, _Alloc>&, int);
^
/opt/compiler-explorer/gcc-9.3.0/lib/gcc/x86_64-linux-gnu/9.3.0/../../../../include/c++/9.3.0/bits/fs_path.h:101:7: note: candidate function [with _Unknown = FileName]
__is_path_src(const _Unknown&, ...);
clang 12.0.1 and above seems to have fixed this bug.
Motivation
FileName
subclassesstd::string
, and so it will be two layers of implicit conversion fromFileName
tostd::filesystem::path
. Functions acceptingstd::filesystem::path
will not takeFileName
, which seems counter-intuitive to me.Design
Add the implicit conversion. But we need to be careful with the modification to the macro though, as we don't want other string-derived types like
VariableName
to be implicitly convertible to path.Impact
Happier coders. We can do
instead of