Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / include / __iterator / ostream_iterator.h
blob85edebabeb1e1055187491a3d923717d0fe2be47
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___ITERATOR_OSTREAM_ITERATOR_H
11 #define _LIBCPP___ITERATOR_OSTREAM_ITERATOR_H
13 #include <__config>
14 #include <__fwd/ostream.h>
15 #include <__fwd/string.h>
16 #include <__iterator/iterator.h>
17 #include <__iterator/iterator_traits.h>
18 #include <__memory/addressof.h>
19 #include <cstddef>
21 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22 # pragma GCC system_header
23 #endif
25 _LIBCPP_BEGIN_NAMESPACE_STD
27 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
28 template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT> >
29 class _LIBCPP_TEMPLATE_VIS ostream_iterator
30 #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
31 : public iterator<output_iterator_tag, void, void, void, void>
32 #endif
34 _LIBCPP_SUPPRESS_DEPRECATED_POP
35 public:
36 typedef output_iterator_tag iterator_category;
37 typedef void value_type;
38 #if _LIBCPP_STD_VER >= 20
39 typedef ptrdiff_t difference_type;
40 #else
41 typedef void difference_type;
42 #endif
43 typedef void pointer;
44 typedef void reference;
45 typedef _CharT char_type;
46 typedef _Traits traits_type;
47 typedef basic_ostream<_CharT, _Traits> ostream_type;
49 private:
50 ostream_type* __out_stream_;
51 const char_type* __delim_;
52 public:
53 _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s) _NOEXCEPT
54 : __out_stream_(_VSTD::addressof(__s)), __delim_(nullptr) {}
55 _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s, const _CharT* __delimiter) _NOEXCEPT
56 : __out_stream_(_VSTD::addressof(__s)), __delim_(__delimiter) {}
57 _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value)
59 *__out_stream_ << __value;
60 if (__delim_)
61 *__out_stream_ << __delim_;
62 return *this;
65 _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator*() {return *this;}
66 _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator++() {return *this;}
67 _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator++(int) {return *this;}
70 _LIBCPP_END_NAMESPACE_STD
72 #endif // _LIBCPP___ITERATOR_OSTREAM_ITERATOR_H