From 4894e316a8feaf1d38e64e867358107445b7dc31 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Tue, 18 Dec 2018 16:57:36 +0000 Subject: [PATCH] LWG 3171: restore stream insertion for filesystem::directory_entry * 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 | 4 ++++ libstdc++-v3/include/bits/fs_dir.h | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 5378bc38632..d9747e8bb07 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,9 @@ 2018-12-18 Jonathan Wakely + * 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. diff --git a/libstdc++-v3/include/bits/fs_dir.h b/libstdc++-v3/include/bits/fs_dir.h index 2f81a1709e4..90bdf7305f8 100644 --- a/libstdc++-v3/include/bits/fs_dir.h +++ b/libstdc++-v3/include/bits/fs_dir.h @@ -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 + 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) { } -- 2.30.2