Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:53

0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009 
0010 #ifndef _LIBCPP___ITERATOR_OSTREAM_ITERATOR_H
0011 #define _LIBCPP___ITERATOR_OSTREAM_ITERATOR_H
0012 
0013 #include <__config>
0014 #include <__cstddef/ptrdiff_t.h>
0015 #include <__fwd/ostream.h>
0016 #include <__fwd/string.h>
0017 #include <__iterator/iterator.h>
0018 #include <__iterator/iterator_traits.h>
0019 #include <__memory/addressof.h>
0020 
0021 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0022 #  pragma GCC system_header
0023 #endif
0024 
0025 _LIBCPP_BEGIN_NAMESPACE_STD
0026 
0027 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
0028 template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT> >
0029 class _LIBCPP_TEMPLATE_VIS ostream_iterator
0030 #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
0031     : public iterator<output_iterator_tag, void, void, void, void>
0032 #endif
0033 {
0034   _LIBCPP_SUPPRESS_DEPRECATED_POP
0035 
0036 public:
0037   typedef output_iterator_tag iterator_category;
0038   typedef void value_type;
0039 #if _LIBCPP_STD_VER >= 20
0040   typedef ptrdiff_t difference_type;
0041 #else
0042   typedef void difference_type;
0043 #endif
0044   typedef void pointer;
0045   typedef void reference;
0046   typedef _CharT char_type;
0047   typedef _Traits traits_type;
0048   typedef basic_ostream<_CharT, _Traits> ostream_type;
0049 
0050 private:
0051   ostream_type* __out_stream_;
0052   const char_type* __delim_;
0053 
0054 public:
0055   _LIBCPP_HIDE_FROM_ABI ostream_iterator(ostream_type& __s) _NOEXCEPT
0056       : __out_stream_(std::addressof(__s)),
0057         __delim_(nullptr) {}
0058   _LIBCPP_HIDE_FROM_ABI ostream_iterator(ostream_type& __s, const _CharT* __delimiter) _NOEXCEPT
0059       : __out_stream_(std::addressof(__s)),
0060         __delim_(__delimiter) {}
0061   _LIBCPP_HIDE_FROM_ABI ostream_iterator& operator=(const _Tp& __value) {
0062     *__out_stream_ << __value;
0063     if (__delim_)
0064       *__out_stream_ << __delim_;
0065     return *this;
0066   }
0067 
0068   _LIBCPP_HIDE_FROM_ABI ostream_iterator& operator*() { return *this; }
0069   _LIBCPP_HIDE_FROM_ABI ostream_iterator& operator++() { return *this; }
0070   _LIBCPP_HIDE_FROM_ABI ostream_iterator& operator++(int) { return *this; }
0071 };
0072 
0073 _LIBCPP_END_NAMESPACE_STD
0074 
0075 #endif // _LIBCPP___ITERATOR_OSTREAM_ITERATOR_H