#include <bits/stl_algobase.h>
#include <bits/quoted_string.h>
#include <bits/locale_conv.h>
+#if __cplusplus == 201402L
+# include <experimental/string_view>
+#endif
#if defined(_WIN32) && !defined(__CYGWIN__)
# define _GLIBCXX_FILESYSTEM_IS_WINDOWS 1
_GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_BEGIN_NAMESPACE_CXX11
+#if __cplusplus == 201402L
+ using std::experimental::basic_string_view;
+#elif __cplusplus > 201402L
+ using std::basic_string_view;
+#endif
+
/**
* @ingroup filesystem
* @{
static __is_encoded_char<_CharT>
__is_path_src(const basic_string<_CharT, _Traits, _Alloc>&, int);
+#if __cplusplus >= 201402L
+ template<typename _CharT, typename _Traits>
+ static __is_encoded_char<_CharT>
+ __is_path_src(const basic_string_view<_CharT, _Traits>&, int);
+#endif
+
template<typename _Unknown>
static std::false_type
__is_path_src(const _Unknown&, ...);
_S_range_end(const basic_string<_CharT, _Traits, _Alloc>& __str)
{ return __str.data() + __str.size(); }
+#if __cplusplus >= 201402L
+ template<typename _CharT, typename _Traits>
+ static const _CharT*
+ _S_range_begin(const basic_string_view<_CharT, _Traits>& __str)
+ { return __str.data(); }
+
+ template<typename _CharT, typename _Traits>
+ static const _CharT*
+ _S_range_end(const basic_string_view<_CharT, _Traits>& __str)
+ { return __str.data() + __str.size(); }
+#endif
+
template<typename _Tp,
typename _Iter = decltype(_S_range_begin(std::declval<_Tp>())),
typename _Val = typename std::iterator_traits<_Iter>::value_type>
path& operator+=(const string_type& __x);
path& operator+=(const value_type* __x);
path& operator+=(value_type __x);
+#if __cplusplus >= 201402L
+ path& operator+=(basic_string_view<value_type> __x);
+#endif
template<typename _Source>
_Path<_Source>&
int compare(const path& __p) const noexcept;
int compare(const string_type& __s) const;
int compare(const value_type* __s) const;
+#if __cplusplus >= 201402L
+ int compare(const basic_string_view<value_type> __s) const;
+#endif
// decomposition
return *this;
}
+#if __cplusplus >= 201402L
+ inline path&
+ path::operator+=(basic_string_view<value_type> __x)
+ {
+ _M_pathname.append(__x.data(), __x.size());
+ _M_split_cmpts();
+ return *this;
+ }
+#endif
+
template<typename _CharT>
inline path::_Path<_CharT*, _CharT*>&
path::operator+=(_CharT __x)
inline int
path::compare(const value_type* __s) const { return compare(path(__s)); }
+#if __cplusplus >= 201402L
+ inline int
+ path::compare(basic_string_view<value_type> __s) const
+ { return compare(path(__s)); }
+#endif
+
inline path
path::filename() const { return empty() ? path() : *--end(); }
--- /dev/null
+// { dg-options "-lstdc++fs -std=gnu++1z" }
+// { dg-do run { target c++1z } }
+// { dg-require-filesystem-ts "" }
+
+// Copyright (C) 2016 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 8.4.1 path constructors [path.construct]
+
+#include <experimental/filesystem>
+#include <string_view>
+#include <string>
+#include <testsuite_fs.h>
+
+using std::experimental::filesystem::path;
+using __gnu_test::compare_paths;
+
+void
+test01()
+{
+ for (std::string s : __gnu_test::test_paths)
+ {
+ path p1 = s;
+ std::string_view sv(s);
+ path p2 = sv;
+ compare_paths(p1, p2);
+
+#if _GLIBCXX_USE_WCHAR_T
+ std::wstring ws(s.begin(), s.end());
+ path p3 = ws;
+ std::wstring_view wsv(ws);
+ path p4 = wsv;
+ compare_paths(p1, p4);
+#endif
+ }
+}
+
+int
+main()
+{
+ test01();
+}