brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · 3e00ce2 Raw
68 lines · c
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-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCPP___CXX03___ITERATOR_OSTREAM_ITERATOR_H11#define _LIBCPP___CXX03___ITERATOR_OSTREAM_ITERATOR_H12 13#include <__cxx03/__config>14#include <__cxx03/__fwd/ostream.h>15#include <__cxx03/__fwd/string.h>16#include <__cxx03/__iterator/iterator.h>17#include <__cxx03/__iterator/iterator_traits.h>18#include <__cxx03/__memory/addressof.h>19#include <__cxx03/cstddef>20 21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#  pragma GCC system_header23#endif24 25_LIBCPP_BEGIN_NAMESPACE_STD26 27_LIBCPP_SUPPRESS_DEPRECATED_PUSH28template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT> >29class _LIBCPP_TEMPLATE_VIS ostream_iterator : public iterator<output_iterator_tag, void, void, void, void> {30  _LIBCPP_SUPPRESS_DEPRECATED_POP31 32public:33  typedef output_iterator_tag iterator_category;34  typedef void value_type;35  typedef void difference_type;36  typedef void pointer;37  typedef void reference;38  typedef _CharT char_type;39  typedef _Traits traits_type;40  typedef basic_ostream<_CharT, _Traits> ostream_type;41 42private:43  ostream_type* __out_stream_;44  const char_type* __delim_;45 46public:47  _LIBCPP_HIDE_FROM_ABI ostream_iterator(ostream_type& __s) _NOEXCEPT48      : __out_stream_(std::addressof(__s)),49        __delim_(nullptr) {}50  _LIBCPP_HIDE_FROM_ABI ostream_iterator(ostream_type& __s, const _CharT* __delimiter) _NOEXCEPT51      : __out_stream_(std::addressof(__s)),52        __delim_(__delimiter) {}53  _LIBCPP_HIDE_FROM_ABI ostream_iterator& operator=(const _Tp& __value) {54    *__out_stream_ << __value;55    if (__delim_)56      *__out_stream_ << __delim_;57    return *this;58  }59 60  _LIBCPP_HIDE_FROM_ABI ostream_iterator& operator*() { return *this; }61  _LIBCPP_HIDE_FROM_ABI ostream_iterator& operator++() { return *this; }62  _LIBCPP_HIDE_FROM_ABI ostream_iterator& operator++(int) { return *this; }63};64 65_LIBCPP_END_NAMESPACE_STD66 67#endif // _LIBCPP___CXX03___ITERATOR_OSTREAM_ITERATOR_H68