diff --git a/README.md b/README.md index 82b57ae..8c38bb1 100644 --- a/README.md +++ b/README.md @@ -311,9 +311,11 @@ path& operator+=(basic_string_view x); int compare(basic_string_view s) const; ``` -These are not implemented, as there is no `std::basic_string_view` available in -C++11 and I did want to keep this implementation self-contained and not -write a full C++17-upgrade for C++11. +These are not implemented under C++11 and C++14, as there is no +`std::basic_string_view` available and I did want to keep this +implementation self-contained and not write a full C++17-upgrade for +C++11/14. Starting with v1.1.0 these are supported when compiling +ghc::filesystem under C++17. ### Differences in API @@ -449,6 +451,8 @@ to the expected behavior. additional simple includes are added, that can be used to forward `ghc::filesystem` declarations (`fs_fwd.hpp`) and to wrap the implementation into a single cpp (`fs_impl.hpp`) +* The `std::basic_string_view` variants of the `fs::path` api are + now supported when compiling with C++17. ### [v1.0.10](https://github.com/gulrak/filesystem/releases/tag/v1.0.10) diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index ec8982c..9f6bf30 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -190,6 +190,12 @@ public: struct _is_basic_string> : std::true_type { }; +#ifdef __cpp_lib_string_view + template + struct _is_basic_string> : std::true_type + { + }; +#endif template using path_type = typename std::enable_if::value, path>::type; @@ -237,7 +243,9 @@ public: // 30.10.8.4.4 concatenation path& operator+=(const path& x); path& operator+=(const string_type& x); - // path& operator+=(basic_string_view x); +#ifdef __cpp_lib_string_view + path& operator+=(std::basic_string_view x); +#endif path& operator+=(const value_type* x); path& operator+=(value_type x); template @@ -281,7 +289,9 @@ public: // 30.10.8.4.8 compare int compare(const path& p) const noexcept; int compare(const string_type& s) const; - // int compare(basic_string_view s) const; +#ifdef __cpp_lib_string_view + int compare(std::basic_string_view s) const; +#endif int compare(const value_type* s) const; // 30.10.8.4.9 decomposition @@ -1947,7 +1957,12 @@ GHC_INLINE path& path::operator+=(const string_type& x) return concat(x); } -// path& operator+=(basic_string_view x); +#ifdef __cpp_lib_string_view +GHC_INLINE path& path::operator+=(std::basic_string_view x) +{ + return concat(x); +} +#endif GHC_INLINE path& path::operator+=(const value_type* x) { @@ -2159,11 +2174,12 @@ GHC_INLINE int path::compare(const string_type& s) const return native().compare(path(s).native()); } -/* -int path::compare(basic_string_view s) const +#ifdef __cpp_lib_string_view +GHC_INLINE int path::compare(std::basic_string_view s) const { + return native().compare(path(s).native()); } -*/ +#endif GHC_INLINE int path::compare(const value_type* s) const {