Skip to content

Commit 4042d57

Browse files
chris-durandsalkinium
authored andcommitted
Remove all stream operators
1 parent f2b0626 commit 4042d57

File tree

10 files changed

+0
-250
lines changed

10 files changed

+0
-250
lines changed

include/backward/backward_warning.h

-4
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@
4040
A list of valid replacements is as follows:
4141
4242
Use: Instead of:
43-
<sstream>, basic_stringbuf <strstream>, strstreambuf
44-
<sstream>, basic_istringstream <strstream>, istrstream
45-
<sstream>, basic_ostringstream <strstream>, ostrstream
46-
<sstream>, basic_stringstream <strstream>, strstream
4743
<unordered_set>, unordered_set <ext/hash_set>, hash_set
4844
<unordered_set>, unordered_multiset <ext/hash_set>, hash_multiset
4945
<unordered_map>, unordered_map <ext/hash_map>, hash_map

include/bits/stl_algo.h

-5
Original file line numberDiff line numberDiff line change
@@ -725,11 +725,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
725725
return __result;
726726
}
727727

728-
template<typename _CharT, typename _Size>
729-
__enable_if_t<__is_char<_CharT>::__value, _CharT*>
730-
__copy_n_a(istreambuf_iterator<_CharT, char_traits<_CharT>>,
731-
_Size, _CharT*);
732-
733728
template<typename _InputIterator, typename _Size, typename _OutputIterator>
734729
_GLIBCXX20_CONSTEXPR
735730
_OutputIterator

include/bits/stl_algobase.h

-29
Original file line numberDiff line numberDiff line change
@@ -428,35 +428,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
428428
}
429429
};
430430

431-
// Helpers for streambuf iterators (either istream or ostream).
432-
// NB: avoid including <iosfwd>, relatively large.
433-
template<typename _CharT>
434-
struct char_traits;
435-
436-
template<typename _CharT, typename _Traits>
437-
class istreambuf_iterator;
438-
439-
template<typename _CharT, typename _Traits>
440-
class ostreambuf_iterator;
441-
442-
template<bool _IsMove, typename _CharT>
443-
typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
444-
ostreambuf_iterator<_CharT, char_traits<_CharT> > >::__type
445-
__copy_move_a2(_CharT*, _CharT*,
446-
ostreambuf_iterator<_CharT, char_traits<_CharT> >);
447-
448-
template<bool _IsMove, typename _CharT>
449-
typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
450-
ostreambuf_iterator<_CharT, char_traits<_CharT> > >::__type
451-
__copy_move_a2(const _CharT*, const _CharT*,
452-
ostreambuf_iterator<_CharT, char_traits<_CharT> >);
453-
454-
template<bool _IsMove, typename _CharT>
455-
typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
456-
_CharT*>::__type
457-
__copy_move_a2(istreambuf_iterator<_CharT, char_traits<_CharT> >,
458-
istreambuf_iterator<_CharT, char_traits<_CharT> >, _CharT*);
459-
460431
template<bool _IsMove, typename _II, typename _OI>
461432
_GLIBCXX20_CONSTEXPR
462433
inline _OI

include/bits/unique_ptr.h

-16
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#include <bits/functional_hash.h>
4040
#if __cplusplus > 201703L
4141
# include <compare>
42-
# include <ostream>
4342
#endif
4443

4544
namespace std _GLIBCXX_VISIBILITY(default)
@@ -974,21 +973,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
974973
// @} relates unique_ptr
975974
#endif // C++14
976975

977-
#if __cplusplus > 201703L && __cpp_concepts
978-
// _GLIBCXX_RESOLVE_LIB_DEFECTS
979-
// 2948. unique_ptr does not define operator<< for stream output
980-
/// Stream output operator for unique_ptr
981-
template<typename _CharT, typename _Traits, typename _Tp, typename _Dp>
982-
inline basic_ostream<_CharT, _Traits>&
983-
operator<<(basic_ostream<_CharT, _Traits>& __os,
984-
const unique_ptr<_Tp, _Dp>& __p)
985-
requires requires { __os << __p.get(); }
986-
{
987-
__os << __p.get();
988-
return __os;
989-
}
990-
#endif // C++20
991-
992976
// @} group pointer_abstractions
993977

994978
#if __cplusplus >= 201703L

include/complex

-89
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
#include <bits/cpp_type_traits.h>
4343
#include <ext/type_traits.h>
4444
#include <cmath>
45-
#include <sstream>
4645

4746
// Get rid of a macro possibly defined in <complex.h>
4847
#undef complex
@@ -494,73 +493,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
494493
#endif
495494
//@}
496495

497-
/// Extraction operator for complex values.
498-
template<typename _Tp, typename _CharT, class _Traits>
499-
basic_istream<_CharT, _Traits>&
500-
operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)
501-
{
502-
bool __fail = true;
503-
_CharT __ch;
504-
if (__is >> __ch)
505-
{
506-
if (_Traits::eq(__ch, __is.widen('(')))
507-
{
508-
_Tp __u;
509-
if (__is >> __u >> __ch)
510-
{
511-
const _CharT __rparen = __is.widen(')');
512-
if (_Traits::eq(__ch, __rparen))
513-
{
514-
__x = __u;
515-
__fail = false;
516-
}
517-
else if (_Traits::eq(__ch, __is.widen(',')))
518-
{
519-
_Tp __v;
520-
if (__is >> __v >> __ch)
521-
{
522-
if (_Traits::eq(__ch, __rparen))
523-
{
524-
__x = complex<_Tp>(__u, __v);
525-
__fail = false;
526-
}
527-
else
528-
__is.putback(__ch);
529-
}
530-
}
531-
else
532-
__is.putback(__ch);
533-
}
534-
}
535-
else
536-
{
537-
__is.putback(__ch);
538-
_Tp __u;
539-
if (__is >> __u)
540-
{
541-
__x = __u;
542-
__fail = false;
543-
}
544-
}
545-
}
546-
if (__fail)
547-
__is.setstate(ios_base::failbit);
548-
return __is;
549-
}
550-
551-
/// Insertion operator for complex values.
552-
template<typename _Tp, typename _CharT, class _Traits>
553-
basic_ostream<_CharT, _Traits>&
554-
operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x)
555-
{
556-
basic_ostringstream<_CharT, _Traits> __s;
557-
__s.flags(__os.flags());
558-
__s.imbue(__os.getloc());
559-
__s.precision(__os.precision());
560-
__s << '(' << __x.real() << ',' << __x.imag() << ')';
561-
return __os << __s.str();
562-
}
563-
564496
// Values
565497
#if __cplusplus >= 201103L
566498
template<typename _Tp>
@@ -1527,27 +1459,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
15271459
complex<double>::complex(const complex<long double>& __z)
15281460
: _M_value(__z.__rep()) { }
15291461

1530-
// Inhibit implicit instantiations for required instantiations,
1531-
// which are defined via explicit instantiations elsewhere.
1532-
// NB: This syntax is a GNU extension.
1533-
#if _GLIBCXX_EXTERN_TEMPLATE
1534-
extern template istream& operator>>(istream&, complex<float>&);
1535-
extern template ostream& operator<<(ostream&, const complex<float>&);
1536-
extern template istream& operator>>(istream&, complex<double>&);
1537-
extern template ostream& operator<<(ostream&, const complex<double>&);
1538-
extern template istream& operator>>(istream&, complex<long double>&);
1539-
extern template ostream& operator<<(ostream&, const complex<long double>&);
1540-
1541-
#ifdef _GLIBCXX_USE_WCHAR_T
1542-
extern template wistream& operator>>(wistream&, complex<float>&);
1543-
extern template wostream& operator<<(wostream&, const complex<float>&);
1544-
extern template wistream& operator>>(wistream&, complex<double>&);
1545-
extern template wostream& operator<<(wostream&, const complex<double>&);
1546-
extern template wistream& operator>>(wistream&, complex<long double>&);
1547-
extern template wostream& operator<<(wostream&, const complex<long double>&);
1548-
#endif
1549-
#endif
1550-
15511462
// @} group complex_numbers
15521463

15531464
_GLIBCXX_END_NAMESPACE_VERSION

include/iterator

-3
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@
6161
#include <bits/stl_iterator_base_types.h>
6262
#include <bits/stl_iterator_base_funcs.h>
6363
#include <bits/stl_iterator.h>
64-
#include <iosfwd>
65-
#include <bits/stream_iterator.h>
66-
#include <bits/streambuf_iterator.h>
6764
#include <bits/range_access.h>
6865

6966
#if __cplusplus >= 201402L && ! defined _GLIBCXX_DEBUG // PR libstdc++/70303

include/memory

-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
#if __cplusplus >= 201103L
7272
# include <exception> // std::exception
7373
# include <typeinfo> // std::type_info in get_deleter
74-
# include <iosfwd> // std::basic_ostream
7574
# include <ext/atomicity.h>
7675
# include <bits/functexcept.h>
7776
# include <bits/stl_function.h> // std::less

include/random

-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737

3838
#include <cmath>
3939
#include <cstdlib>
40-
#include <string>
41-
#include <iosfwd>
4240
#include <limits>
4341
#include <debug/debug.h>
4442
#include <type_traits>

include/ranges

-95
Original file line numberDiff line numberDiff line change
@@ -944,101 +944,6 @@ namespace views
944944
inline constexpr _Iota iota{};
945945
} // namespace views
946946

947-
namespace __detail
948-
{
949-
template<typename _Val, typename _CharT, typename _Traits>
950-
concept __stream_extractable
951-
= requires(basic_istream<_CharT, _Traits>& is, _Val& t) { is >> t; };
952-
} // namespace __detail
953-
954-
template<movable _Val, typename _CharT, typename _Traits>
955-
requires default_initializable<_Val>
956-
&& __detail::__stream_extractable<_Val, _CharT, _Traits>
957-
class basic_istream_view
958-
: public view_interface<basic_istream_view<_Val, _CharT, _Traits>>
959-
{
960-
public:
961-
basic_istream_view() = default;
962-
963-
constexpr explicit
964-
basic_istream_view(basic_istream<_CharT, _Traits>& __stream)
965-
: _M_stream(std::__addressof(__stream))
966-
{ }
967-
968-
constexpr auto
969-
begin()
970-
{
971-
if (_M_stream != nullptr)
972-
*_M_stream >> _M_object;
973-
return _Iterator{*this};
974-
}
975-
976-
constexpr default_sentinel_t
977-
end() const noexcept
978-
{ return default_sentinel; }
979-
980-
private:
981-
basic_istream<_CharT, _Traits>* _M_stream = nullptr;
982-
_Val _M_object = _Val();
983-
984-
struct _Iterator
985-
{
986-
public:
987-
using iterator_concept = input_iterator_tag;
988-
using difference_type = ptrdiff_t;
989-
using value_type = _Val;
990-
991-
_Iterator() = default;
992-
993-
constexpr explicit
994-
_Iterator(basic_istream_view& __parent) noexcept
995-
: _M_parent(std::__addressof(__parent))
996-
{ }
997-
998-
_Iterator(const _Iterator&) = delete;
999-
_Iterator(_Iterator&&) = default;
1000-
_Iterator& operator=(const _Iterator&) = delete;
1001-
_Iterator& operator=(_Iterator&&) = default;
1002-
1003-
_Iterator&
1004-
operator++()
1005-
{
1006-
__glibcxx_assert(_M_parent->_M_stream != nullptr);
1007-
*_M_parent->_M_stream >> _M_parent->_M_object;
1008-
return *this;
1009-
}
1010-
1011-
void
1012-
operator++(int)
1013-
{ ++*this; }
1014-
1015-
_Val&
1016-
operator*() const
1017-
{
1018-
__glibcxx_assert(_M_parent->_M_stream != nullptr);
1019-
return _M_parent->_M_object;
1020-
}
1021-
1022-
friend bool
1023-
operator==(const _Iterator& __x, default_sentinel_t)
1024-
{ return __x._M_at_end(); }
1025-
1026-
private:
1027-
basic_istream_view* _M_parent = nullptr;
1028-
1029-
bool
1030-
_M_at_end() const
1031-
{ return _M_parent == nullptr || !*_M_parent->_M_stream; }
1032-
};
1033-
1034-
friend _Iterator;
1035-
};
1036-
1037-
template<typename _Val, typename _CharT, typename _Traits>
1038-
basic_istream_view<_Val, _CharT, _Traits>
1039-
istream_view(basic_istream<_CharT, _Traits>& __s)
1040-
{ return basic_istream_view<_Val, _CharT, _Traits>{__s}; }
1041-
1042947
namespace __detail
1043948
{
1044949
struct _Empty { };

include/system_error

-6
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737

3838
#include <bits/c++config.h>
3939
#include <bits/error_constants.h>
40-
#include <iosfwd>
4140
#include <stdexcept>
4241
#if __cplusplus > 201703L
4342
# include <compare>
@@ -257,11 +256,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
257256
}
258257
#endif
259258

260-
template<typename _CharT, typename _Traits>
261-
basic_ostream<_CharT, _Traits>&
262-
operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e)
263-
{ return (__os << __e.category().name() << ':' << __e.value()); }
264-
265259
// @}
266260

267261
error_condition make_error_condition(errc) noexcept;

0 commit comments

Comments
 (0)