template<typename _InputIterator,
typename _Require = __detail::_Path2<_InputIterator>>
path(_InputIterator __first, _InputIterator __last, format = auto_format)
- : _M_pathname(_S_convert(__first, __last))
+ : _M_pathname(_S_convert(__detail::__string_from_range(__first, __last)))
{ _M_split_cmpts(); }
template<typename _Source,
__detail::_Path2<_InputIterator>&
append(_InputIterator __first, _InputIterator __last)
{
- _M_append(_S_convert(__first, __last));
+ _M_append(_S_convert(__detail::__string_from_range(__first, __last)));
return *this;
}
__detail::_Path2<_InputIterator>&
concat(_InputIterator __first, _InputIterator __last)
{
- _M_concat(_S_convert(__first, __last));
+ _M_concat(_S_convert(__detail::__string_from_range(__first, __last)));
return *this;
}
static auto
_S_convert(const _EcharT* __first, const _EcharT* __last);
- template<typename _Iter>
- static auto
- _S_convert(_Iter __first, _Iter __last)
- { return _S_convert(__detail::__string_from_range(__first, __last)); }
-
static string_type
_S_convert_loc(const char* __first, const char* __last,
const std::locale& __loc);
--- /dev/null
+// { dg-options "-fchar8_t" }
+// { dg-do run { target c++17 } }
+
+#include <filesystem>
+#include <testsuite_hooks.h>
+#include <testsuite_iterators.h>
+
+using __gnu_test::input_iterator_wrapper;
+using __gnu_test::input_container;
+
+void test01()
+{
+ const char8_t src[] = u8"/long/path/to/a/file/to/avoid/small/string";
+ input_container<const char8_t> c1(src); // includes null terminator
+ std::filesystem::path p1(c1.begin()); // read up to null terminator
+ VERIFY( p1.u8string() == src );
+
+ std::u8string_view sv = src;
+ input_container<const char8_t> c2(sv.data(), sv.data() + sv.size());
+ std::filesystem::path p2(c2.begin(), c2.end()); // PR libstdc++/102592
+ VERIFY( p2.u8string() == src );
+ VERIFY( p1 == p2 );
+}
+
+int main()
+{
+ test01();
+}