LWG 3171: restore stream insertion for filesystem::directory_entry
authorJonathan Wakely <jwakely@redhat.com>
Tue, 18 Dec 2018 16:57:36 +0000 (16:57 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Tue, 18 Dec 2018 16:57:36 +0000 (16:57 +0000)
* include/bits/fs_dir.h (operator<<): Overload for directory_entry,
as per LWG 3171.
* testsuite/27_io/filesystem/directory_entry/lwg3171.cc: New test.

From-SVN: r267238

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/fs_dir.h

index 5378bc386323845e039b6dcec36c3f321cc11001..d9747e8bb07ef6c5d7e9b713ecd5f79e47032aba 100644 (file)
@@ -1,5 +1,9 @@
 2018-12-18  Jonathan Wakely  <jwakely@redhat.com>
 
+       * include/bits/fs_dir.h (operator<<): Overload for directory_entry,
+       as per LWG 3171.
+       * testsuite/27_io/filesystem/directory_entry/lwg3171.cc: New test.
+
        * src/filesystem/std-dir.cc (filesystem::_Dir::advance): Move new
        path instead of copying.
 
index 2f81a1709e445b3534e46c34984e519f2ccdc8d1..90bdf7305f8b22e3d33ac41c528dd0f0d1654586 100644 (file)
@@ -300,6 +300,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
     friend class directory_iterator;
     friend class recursive_directory_iterator;
 
+    // _GLIBCXX_RESOLVE_LIB_DEFECTS
+    // 3171. LWG 2989 breaks directory_entry stream insertion
+    template<typename _CharT, typename _Traits>
+      friend basic_ostream<_CharT, _Traits>&
+      operator<<(basic_ostream<_CharT, _Traits>& __os,
+                const directory_entry& __d)
+      { return __os << __d.path(); }
+
     directory_entry(const filesystem::path& __p, file_type __t)
     : _M_path(__p), _M_type(__t)
     { }