From fbdee68f21577322f6b87870f93ef57f52648ae0 Mon Sep 17 00:00:00 2001 From: Steffen Schuemann Date: Sat, 21 Sep 2019 16:46:00 +0200 Subject: [PATCH] refs #27, Squashed commit of the following: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit aabbf8f3d880dcd0aeaa97f014d91d54dfa24ed4 Author: Steffen Schümann Date: Sat Sep 21 16:22:25 2019 +0200 refs #27, ghc::filesystem::path::preferred_seperator fix for VS2015 commit 03b437cefb39746127b34ce6c9d47df7209a27c7 Merge: cbe0c61 589219b Author: Steffen Schümann Date: Fri Sep 20 13:42:31 2019 +0200 Merge branch 'master' into feature-27-mingw-preferred_separator commit cbe0c61492f3a6817f03343bb16d73211625a9cb Author: Steffen Schuemann Date: Sat Aug 24 22:20:10 2019 +0200 Test for workaround of static constexpr issue --- include/ghc/filesystem.hpp | 36 +++++++++++++++++++++++++----------- test/filesystem_test.cpp | 9 +++++++++ 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index 7af17ab..a1badad 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -192,24 +192,38 @@ class GHC_FS_API_CLASS not_implemented_exception : public std::logic_error } }; -// 30.10.8 class path -class GHC_FS_API_CLASS path +template +class path_helper_base { public: + using value_type = char_type; #ifdef GHC_OS_WINDOWS -#ifdef GHC_WIN_WSTRING_STRING_TYPE -#define GHC_USE_WCHAR_T - using value_type = std::wstring::value_type; -#else - using value_type = std::string::value_type; -#endif - using string_type = std::basic_string; static constexpr value_type preferred_separator = '\\'; #else - using value_type = std::string::value_type; - using string_type = std::basic_string; static constexpr value_type preferred_separator = '/'; #endif +}; + +template +constexpr char_type path_helper_base::preferred_separator; + +// 30.10.8 class path +class GHC_FS_API_CLASS path +#if defined(GHC_OS_WINDOWS) && defined(GHC_WIN_WSTRING_STRING_TYPE) +#define GHC_USE_WCHAR_T + : private path_helper_base +{ +public: + using path_helper_base::value_type; +#else + : private path_helper_base +{ +public: + using path_helper_base::value_type; +#endif + using string_type = std::basic_string; + using path_helper_base::preferred_separator; + // 30.10.10.1 enumeration format /// The path format in wich the constructor argument is given. enum format { diff --git a/test/filesystem_test.cpp b/test/filesystem_test.cpp index 7e0570c..939dce8 100644 --- a/test/filesystem_test.cpp +++ b/test/filesystem_test.cpp @@ -345,6 +345,15 @@ TEST_CASE("fs::detail::toUtf8", "[filesystem][fs.detail.utf8]") } #endif +TEST_CASE("30.10.8.1 path::preferred_separator", "[filesystem][path][fs.path.generic]") +{ +#ifdef GHC_OS_WINDOWS + CHECK(fs::path::preferred_separator == '\\'); +#else + CHECK(fs::path::preferred_separator == '/'); +#endif +} + #ifndef GHC_OS_WINDOWS TEST_CASE("30.10.8.1 path(\"//host\").has_root_name()", "[filesystem][path][fs.path.generic]") {