@@ -737,7 +737,14 @@ namespace __detail
/// @{
/// @relates std::filesystem::path
+#if __cpp_concepts >= 201907L
+ // Workaround for PR libstdc++/106201
+ inline void
+ swap(same_as<path> auto& __lhs, same_as<path> auto& __rhs) noexcept
+ { __lhs.swap(__rhs); }
+#else
inline void swap(path& __lhs, path& __rhs) noexcept { __lhs.swap(__rhs); }
+#endif
size_t hash_value(const path& __p) noexcept;
@@ -537,7 +537,14 @@ namespace __detail
/// @relates std::experimental::filesystem::path @{
/// Swap overload for paths
- inline void swap(path& __lhs, path& __rhs) noexcept { __lhs.swap(__rhs); }
+#if __cpp_concepts >= 201907L
+ // Workaround for PR libstdc++/106201
+ inline void
+ swap(same_as<path> auto& __lhs, same_as<path> auto& __rhs) noexcept
+ { __lhs.swap(__rhs); }
+#else
+ inline void swap(path& __lhs, path& __rhs) noexcept { __lhs.swap(__rhs); }
+#endif
/// Compute a hash value for a path
size_t hash_value(const path& __p) noexcept;
new file mode 100644
@@ -0,0 +1,14 @@
+// { dg-options "-std=gnu++20" }
+// { dg-do compile { target c++20 } }
+// { dg-require-filesystem-ts "" }
+
+// PR libstdc++/106201 constraint recursion in path(Source const&) constructor.
+
+#include <filesystem>
+#include <iterator>
+#include <concepts>
+namespace fs = std::filesystem;
+using I = std::counted_iterator<fs::directory_iterator>;
+static_assert( std::swappable<I> );
+using R = std::counted_iterator<fs::recursive_directory_iterator>;
+static_assert( std::swappable<R> );
new file mode 100644
@@ -0,0 +1,14 @@
+// { dg-options "-std=gnu++20" }
+// { dg-do compile { target c++20 } }
+// { dg-require-filesystem-ts "" }
+
+// PR libstdc++/106201 constraint recursion in path(Source const&) constructor.
+
+#include <experimental/filesystem>
+#include <iterator>
+#include <concepts>
+namespace fs = std::experimental::filesystem;
+using I = std::counted_iterator<fs::directory_iterator>;
+static_assert( std::swappable<I> );
+using R = std::counted_iterator<fs::recursive_directory_iterator>;
+static_assert( std::swappable<R> );