[libcxx] r329031 - Implement P0430R2 - File system library on non-POSIX systems.
Eric Fiselier via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 2 16:35:24 PDT 2018
Author: ericwf
Date: Mon Apr 2 16:35:24 2018
New Revision: 329031
URL: http://llvm.org/viewvc/llvm-project?rev=329031&view=rev
Log:
Implement P0430R2 - File system library on non-POSIX systems.
This patch implements P0430R2, who's largest change is adding the path::format
enumeration for supporting path format conversions in path constructors.
However, since libc++'s filesystem only really supports POSIX like systems,
there are no real changes needed. This patch simply adds the format enum
and then ignores it when it's passed to constructors.
Added:
libcxx/trunk/test/std/experimental/filesystem/fs.enum/enum.path.format.pass.cpp
Modified:
libcxx/trunk/include/experimental/filesystem
libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.construct/source.pass.cpp
libcxx/trunk/www/cxx1z_status.html
Modified: libcxx/trunk/include/experimental/filesystem
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/filesystem?rev=329031&r1=329030&r2=329031&view=diff
==============================================================================
--- libcxx/trunk/include/experimental/filesystem (original)
+++ libcxx/trunk/include/experimental/filesystem Mon Apr 2 16:35:24 2018
@@ -721,24 +721,31 @@ public:
typedef _VSTD::string_view __string_view;
static _LIBCPP_CONSTEXPR value_type preferred_separator = '/';
+ enum class _LIBCPP_ENUM_VIS format : unsigned char {
+ auto_format,
+ native_format,
+ generic_format
+ };
+
// constructors and destructor
_LIBCPP_INLINE_VISIBILITY path() _NOEXCEPT {}
_LIBCPP_INLINE_VISIBILITY path(const path& __p) : __pn_(__p.__pn_) {}
_LIBCPP_INLINE_VISIBILITY path(path&& __p) _NOEXCEPT : __pn_(_VSTD::move(__p.__pn_)) {}
_LIBCPP_INLINE_VISIBILITY
- path(string_type&& __s) _NOEXCEPT : __pn_(_VSTD::move(__s)) {}
+ path(string_type&& __s, format = format::auto_format) _NOEXCEPT
+ : __pn_(_VSTD::move(__s)) {}
template <
class _Source,
class = _EnableIfPathable<_Source, void>
>
- path(const _Source& __src) {
+ path(const _Source& __src, format = format::auto_format) {
_SourceCVT<_Source>::__append_source(__pn_, __src);
}
template <class _InputIt>
- path(_InputIt __first, _InputIt __last) {
+ path(_InputIt __first, _InputIt __last, format = format::auto_format) {
typedef typename iterator_traits<_InputIt>::value_type _ItVal;
_PathCVT<_ItVal>::__append_range(__pn_, __first, __last);
}
@@ -747,9 +754,11 @@ public:
template <class _Source,
class = _EnableIfPathable<_Source, void>
>
- path(const _Source& __src, const locale& __loc);
+ path(const _Source& __src, const locale& __loc,
+ format = format::auto_format);
template <class _InputIt>
- path(_InputIt __first, _InputIt _last, const locale& __loc);
+ path(_InputIt __first, _InputIt _last, const locale& __loc,
+ format = format::auto_format);
_LIBCPP_INLINE_VISIBILITY
~path() = default;
Modified: libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.construct/source.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.construct/source.pass.cpp?rev=329031&r1=329030&r2=329031&view=diff
==============================================================================
--- libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.construct/source.pass.cpp (original)
+++ libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.construct/source.pass.cpp Mon Apr 2 16:35:24 2018
@@ -29,8 +29,8 @@
#include "filesystem_test_helper.hpp"
-template <class CharT>
-void RunTestCase(MultiStringType const& MS) {
+template <class CharT, class ...Args>
+void RunTestCaseImpl(MultiStringType const& MS, Args... args) {
using namespace fs;
const char* Expect = MS;
const CharT* TestPath = MS;
@@ -41,44 +41,52 @@ void RunTestCase(MultiStringType const&
// StringTypes
{
const std::basic_string<CharT> S(TestPath);
- path p(S);
+ path p(S, args...);
assert(p.native() == Expect);
assert(p.string<CharT>() == TestPath);
assert(p.string<CharT>() == S);
}
{
const std::basic_string_view<CharT> S(TestPath);
- path p(S);
+ path p(S, args...);
assert(p.native() == Expect);
assert(p.string<CharT>() == TestPath);
assert(p.string<CharT>() == S);
}
// Char* pointers
{
- path p(TestPath);
+ path p(TestPath, args...);
assert(p.native() == Expect);
assert(p.string<CharT>() == TestPath);
}
{
- path p(TestPath, TestPathEnd);
+ path p(TestPath, TestPathEnd, args...);
assert(p.native() == Expect);
assert(p.string<CharT>() == TestPath);
}
// Iterators
{
using It = input_iterator<const CharT*>;
- path p(It{TestPath});
+ path p(It{TestPath}, args...);
assert(p.native() == Expect);
assert(p.string<CharT>() == TestPath);
}
{
using It = input_iterator<const CharT*>;
- path p(It{TestPath}, It{TestPathEnd});
+ path p(It{TestPath}, It{TestPathEnd}, args...);
assert(p.native() == Expect);
assert(p.string<CharT>() == TestPath);
}
}
+template <class CharT, class ...Args>
+void RunTestCase(MultiStringType const& MS) {
+ RunTestCaseImpl<CharT>(MS);
+ RunTestCaseImpl<CharT>(MS, fs::path::format::auto_format);
+ RunTestCaseImpl<CharT>(MS, fs::path::format::native_format);
+ RunTestCaseImpl<CharT>(MS, fs::path::format::generic_format);
+}
+
void test_sfinae() {
using namespace fs;
{
Added: libcxx/trunk/test/std/experimental/filesystem/fs.enum/enum.path.format.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.enum/enum.path.format.pass.cpp?rev=329031&view=auto
==============================================================================
--- libcxx/trunk/test/std/experimental/filesystem/fs.enum/enum.path.format.pass.cpp (added)
+++ libcxx/trunk/test/std/experimental/filesystem/fs.enum/enum.path.format.pass.cpp Mon Apr 2 16:35:24 2018
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// <experimental/filesystem>
+
+// class path;
+// enum class format;
+
+#include "filesystem_include.hpp"
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main() {
+ typedef fs::path::format E;
+ static_assert(std::is_enum<E>::value, "");
+
+ // Check that E is a scoped enum by checking for conversions.
+ typedef std::underlying_type<E>::type UT;
+ static_assert(!std::is_convertible<E, UT>::value, "");
+
+ LIBCPP_ONLY(static_assert(std::is_same<UT, unsigned char>::value, "")); // Implementation detail
+
+ static_assert(
+ E::auto_format != E::native_format &&
+ E::auto_format != E::generic_format &&
+ E::native_format != E::generic_format,
+ "Expected enumeration values are not unique");
+}
Modified: libcxx/trunk/www/cxx1z_status.html
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=329031&r1=329030&r2=329031&view=diff
==============================================================================
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Mon Apr 2 16:35:24 2018
@@ -149,7 +149,7 @@
<tr><td><a href="https://wg21.link/P0270R3">P0270R3</a></td><td>CWG</td><td>Removing C dependencies from signal handler wording</td><td>Kona</td><td></td><td></td></tr>
<tr><td><a href="https://wg21.link/P0298R3">P0298R3</a></td><td>CWG</td><td>A byte type definition</td><td>Kona</td><td>Complete</td><td>5.0</td></tr>
<tr><td><a href="https://wg21.link/P0317R1">P0317R1</a></td><td>LWG</td><td>Directory Entry Caching for Filesystem</td><td>Kona</td><td></td><td></td></tr>
- <tr><td><a href="https://wg21.link/P0430R2">P0430R2</a></td><td>LWG</td><td>File system library on non-POSIX-like operating systems</td><td>Kona</td><td></td><td></td></tr>
+ <tr><td><a href="https://wg21.link/P0430R2">P0430R2</a></td><td>LWG</td><td>File system library on non-POSIX-like operating systems</td><td>Kona</td><td>Complete</td><td>7.0</td></tr>
<tr><td><a href="https://wg21.link/P0433R2">P0433R2</a></td><td>LWG</td><td>Toward a resolution of US7 and US14: Integrating template deduction for class templates into the standard library</td><td>Kona</td><td><i>In progress</i></td><td>7.0</td></tr>
<tr><td><a href="https://wg21.link/P0452R1">P0452R1</a></td><td>LWG</td><td>Unifying <numeric> Parallel Algorithms</td><td>Kona</td><td></td><td></td></tr>
<tr><td><a href="https://wg21.link/P0467R2">P0467R2</a></td><td>LWG</td><td>Iterator Concerns for Parallel Algorithms</td><td>Kona</td><td></td><td></td></tr>
More information about the cfe-commits
mailing list