gulrak / filesystem

An implementation of C++17 std::filesystem for C++11 /C++14/C++17/C++20 on Windows, macOS, Linux and FreeBSD.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

path is not implicitly constructible from UTF-8, UTF-16 or UTF-32 literals

zero9178 opened this issue · comments

Implementations of std::filesystem I have tested (libc++, libstdc++ and MSVC STL) all support the use of u8, u16 and u32 string literals to construct a path using constructor 5 described here in cppreference: https://en.cppreference.com/w/cpp/filesystem/path/path

The relevant standard text is https://eel.is/c++draft/fs.path.type.cvt I believe, though I am not well versed in the C++ Standard.

I encountered this issue with the following code:

#include <filesystem>

int main()
{
    ghc::filesystem::exists(u8"test");
}

which failed to compile in C++20 mode when I was using either Clang 12 or GCC 11 (on Windows). I believe it should also be reproducible using UTF-16 or UTF-32 literals in C++17 mode.

The same code in CE, showing all 3 STL implementations compiling the above:
https://godbolt.org/z/Gd835xxGv

Indeed, that should work while compiling with C++20 mode, and I can reproduce the issue.
Thanks for reporting, I'll look into it.

With the fix from branch feature-119-support-u8-u16-u32-literals it works for me now. (But I don't have Clang 12 or GCC 11 on Windows at hand, tested on macOS with Clang and Windows with VS2019.)

Just checked out the branch and ran your whole testsuite against both toolchains and can happily confirm that it's working and that there are no regressions either.