[libcxx-commits] [PATCH] D64818: [libcxx] Construct path using a instance of std::locale

Jean Guegant via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jul 16 13:43:36 PDT 2019


jguegant created this revision.
jguegant added reviewers: mclow.lists, EricWF, ldionne.
Herald added subscribers: libcxx-commits, dexonsmith, christof.
jguegant edited the summary of this revision.

This patch tries to provide the two missing constructors for **std::filesystem::path** using an instance of **std::locale** to convert the source.

Given that the source needs to be converted using the **codecvt<wchar_­t, char, mbstate_­t>** facet of the **std::locale** at first, these two constructors:

1. Can only take a **char** source.
2. Need to have different path than the current two other constructors taking a source.

After converting to a **wchar_t** source using the **codecvt**, we need to convert a second time to store the result. The standard is unclear on how the second conversion should happen:

  Otherwise a conversion is performed using the codecvt<wchar_­t, char, mbstate_­t> facet of loc, and then a second conversion to the current ordinary encoding.

I interpreted this as the second conversion can be executed however we want, meaning that I can reuse the facilities from the two constructors that accept any kind of source.

For the tests, this patch contains both exhaustive testing using an already existing list of paths but also a check that the first conversion is indeed using **codecvt<wchar_­t, char, mbstate_­t>** to avoid any regression in the internal logic.


Repository:
  rCXX libc++

https://reviews.llvm.org/D64818

Files:
  libcxx/include/__locale
  libcxx/include/filesystem
  libcxx/test/std/input.output/filesystems/class.path/path.member/path.construct/source_and_locale.pass.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64818.210158.patch
Type: text/x-patch
Size: 13723 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190716/57298f8b/attachment-0001.bin>


More information about the libcxx-commits mailing list