Skip to content

Commit 6abc15a

Browse files
committed
[libc++] Reduce dependencies on <iostream> from <random>
We included <istream> and <ostream> from <random>, but really it is sufficient to include <iosfwd> if we make sure we access ios_base members through a dependent type. This allows us to break a hard dependency of <random> on locales.
1 parent 2aad6a0 commit 6abc15a

File tree

3 files changed

+142
-95
lines changed

3 files changed

+142
-95
lines changed

libcxx/include/ios

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,33 +1035,6 @@ defaultfloat(ios_base& __str)
10351035
return __str;
10361036
}
10371037

1038-
template <class _CharT, class _Traits>
1039-
class __save_flags
1040-
{
1041-
typedef basic_ios<_CharT, _Traits> __stream_type;
1042-
typedef typename __stream_type::fmtflags fmtflags;
1043-
1044-
__stream_type& __stream_;
1045-
fmtflags __fmtflags_;
1046-
_CharT __fill_;
1047-
1048-
__save_flags(const __save_flags&);
1049-
__save_flags& operator=(const __save_flags&);
1050-
public:
1051-
_LIBCPP_INLINE_VISIBILITY
1052-
explicit __save_flags(__stream_type& __stream)
1053-
: __stream_(__stream),
1054-
__fmtflags_(__stream.flags()),
1055-
__fill_(__stream.fill())
1056-
{}
1057-
_LIBCPP_INLINE_VISIBILITY
1058-
~__save_flags()
1059-
{
1060-
__stream_.flags(__fmtflags_);
1061-
__stream_.fill(__fill_);
1062-
}
1063-
};
1064-
10651038
_LIBCPP_END_NAMESPACE_STD
10661039

10671040
#endif // _LIBCPP_IOS

libcxx/include/iosfwd

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,33 @@ typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstring
215215
template <class _Tp, class _Alloc = allocator<_Tp> >
216216
class _LIBCPP_TEMPLATE_VIS vector;
217217

218+
template <class _CharT, class _Traits>
219+
class __save_flags
220+
{
221+
typedef basic_ios<_CharT, _Traits> __stream_type;
222+
typedef typename __stream_type::fmtflags fmtflags;
223+
224+
__stream_type& __stream_;
225+
fmtflags __fmtflags_;
226+
_CharT __fill_;
227+
228+
__save_flags(const __save_flags&);
229+
__save_flags& operator=(const __save_flags&);
230+
public:
231+
_LIBCPP_INLINE_VISIBILITY
232+
explicit __save_flags(__stream_type& __stream)
233+
: __stream_(__stream),
234+
__fmtflags_(__stream.flags()),
235+
__fill_(__stream.fill())
236+
{}
237+
_LIBCPP_INLINE_VISIBILITY
238+
~__save_flags()
239+
{
240+
__stream_.flags(__fmtflags_);
241+
__stream_.fill(__fill_);
242+
}
243+
};
244+
218245
_LIBCPP_END_NAMESPACE_STD
219246

220247
#endif // _LIBCPP_IOSFWD

0 commit comments

Comments
 (0)