File indexing completed on 2026-05-03 08:13:53
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef _LIBCPP___ITERATOR_OSTREAMBUF_ITERATOR_H
0011 #define _LIBCPP___ITERATOR_OSTREAMBUF_ITERATOR_H
0012
0013 #include <__config>
0014 #include <__cstddef/ptrdiff_t.h>
0015 #include <__fwd/ios.h>
0016 #include <__fwd/ostream.h>
0017 #include <__fwd/streambuf.h>
0018 #include <__iterator/iterator.h>
0019 #include <__iterator/iterator_traits.h>
0020 #include <iosfwd> // for forward declaration of ostreambuf_iterator
0021
0022 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0023 # pragma GCC system_header
0024 #endif
0025
0026 _LIBCPP_BEGIN_NAMESPACE_STD
0027
0028 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
0029 template <class _CharT, class _Traits>
0030 class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator
0031 #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
0032 : public iterator<output_iterator_tag, void, void, void, void>
0033 #endif
0034 {
0035 _LIBCPP_SUPPRESS_DEPRECATED_POP
0036
0037 public:
0038 typedef output_iterator_tag iterator_category;
0039 typedef void value_type;
0040 #if _LIBCPP_STD_VER >= 20
0041 typedef ptrdiff_t difference_type;
0042 #else
0043 typedef void difference_type;
0044 #endif
0045 typedef void pointer;
0046 typedef void reference;
0047 typedef _CharT char_type;
0048 typedef _Traits traits_type;
0049 typedef basic_streambuf<_CharT, _Traits> streambuf_type;
0050 typedef basic_ostream<_CharT, _Traits> ostream_type;
0051
0052 private:
0053 streambuf_type* __sbuf_;
0054
0055 public:
0056 _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator(ostream_type& __s) _NOEXCEPT : __sbuf_(__s.rdbuf()) {}
0057 _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator(streambuf_type* __s) _NOEXCEPT : __sbuf_(__s) {}
0058 _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator& operator=(_CharT __c) {
0059 if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sputc(__c), traits_type::eof()))
0060 __sbuf_ = nullptr;
0061 return *this;
0062 }
0063 _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator& operator*() { return *this; }
0064 _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator& operator++() { return *this; }
0065 _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator& operator++(int) { return *this; }
0066 _LIBCPP_HIDE_FROM_ABI bool failed() const _NOEXCEPT { return __sbuf_ == nullptr; }
0067
0068 #if _LIBCPP_HAS_LOCALIZATION
0069 template <class _Ch, class _Tr>
0070 friend _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator<_Ch, _Tr> __pad_and_output(
0071 ostreambuf_iterator<_Ch, _Tr> __s, const _Ch* __ob, const _Ch* __op, const _Ch* __oe, ios_base& __iob, _Ch __fl);
0072 #endif
0073 };
0074
0075 _LIBCPP_END_NAMESPACE_STD
0076
0077 #endif