File: iterator

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (134 lines) | stat: -rw-r--r-- 4,460 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP_EXPERIMENTAL_ITERATOR
#define _LIBCPP_EXPERIMENTAL_ITERATOR

/*
namespace std {
  namespace experimental {
    inline namespace fundamentals_v2 {

    template <class DelimT, class charT = char, class traits = char_traits<charT>>
        class ostream_joiner {
        public:
         typedef charT                        char_type;
         typedef traits                       traits_type;
         typedef basic_ostream<charT, traits> ostream_type;
         typedef output_iterator_tag          iterator_category;
         typedef void                         value_type;
         typedef void                         difference_type;
         typedef void                         pointer;
         typedef void                         reference;

         ostream_joiner(ostream_type& s, const DelimT& delimiter);
         ostream_joiner(ostream_type& s, DelimT&& delimiter);

         template<typename T>
         ostream_joiner& operator=(const T& value);

         ostream_joiner& operator*() noexcept;
         ostream_joiner& operator++() noexcept;
         ostream_joiner& operator++(int) noexcept;
   private:
      ostream_type* out_stream;   // exposition only
      DelimT delim;               // exposition only
      bool first_element;         // exposition only
   };

  template <class charT, class traits, class DelimT>
    ostream_joiner<decay_t<DelimT>, charT, traits>
    make_ostream_joiner(basic_ostream<charT, traits>& os, DelimT&& delimiter);

    } // inline namespace fundamentals_v2
  } // namespace experimental
} // namespace std

*/

#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
#  include <__cxx03/experimental/iterator>
#else
#  include <__config>
#  include <__memory/addressof.h>
#  include <__ostream/basic_ostream.h>
#  include <__string/char_traits.h>
#  include <__type_traits/decay.h>
#  include <__utility/forward.h>
#  include <__utility/move.h>
#  include <iterator>

#  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#    pragma GCC system_header
#  endif

_LIBCPP_PUSH_MACROS
#  include <__undef_macros>

#  if _LIBCPP_STD_VER >= 14

_LIBCPP_BEGIN_NAMESPACE_LFTS

template <class _Delim, class _CharT = char, class _Traits = char_traits<_CharT>>
class ostream_joiner {
public:
  typedef _CharT char_type;
  typedef _Traits traits_type;
  typedef basic_ostream<char_type, traits_type> ostream_type;
  typedef output_iterator_tag iterator_category;
  typedef void value_type;
  typedef void difference_type;
  typedef void pointer;
  typedef void reference;

  _LIBCPP_HIDE_FROM_ABI ostream_joiner(ostream_type& __os, _Delim&& __d)
      : __output_iter_(std::addressof(__os)), __delim_(std::move(__d)), __first_(true) {}

  _LIBCPP_HIDE_FROM_ABI ostream_joiner(ostream_type& __os, const _Delim& __d)
      : __output_iter_(std::addressof(__os)), __delim_(__d), __first_(true) {}

  template <typename _Tp>
  _LIBCPP_HIDE_FROM_ABI ostream_joiner& operator=(const _Tp& __v) {
    if (!__first_)
      *__output_iter_ << __delim_;
    __first_ = false;
    *__output_iter_ << __v;
    return *this;
  }

  _LIBCPP_HIDE_FROM_ABI ostream_joiner& operator*() _NOEXCEPT { return *this; }
  _LIBCPP_HIDE_FROM_ABI ostream_joiner& operator++() _NOEXCEPT { return *this; }
  _LIBCPP_HIDE_FROM_ABI ostream_joiner& operator++(int) _NOEXCEPT { return *this; }

private:
  ostream_type* __output_iter_;
  _Delim __delim_;
  bool __first_;
};

template <class _CharT, class _Traits, class _Delim>
_LIBCPP_HIDE_FROM_ABI ostream_joiner<__decay_t<_Delim>, _CharT, _Traits>
make_ostream_joiner(basic_ostream<_CharT, _Traits>& __os, _Delim&& __d) {
  return ostream_joiner<__decay_t<_Delim>, _CharT, _Traits>(__os, std::forward<_Delim>(__d));
}

_LIBCPP_END_NAMESPACE_LFTS

#  endif // _LIBCPP_STD_VER >= 14

_LIBCPP_POP_MACROS

#  if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
#    include <cstddef>
#    include <iosfwd>
#    include <type_traits>
#  endif
#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)

#endif // _LIBCPP_EXPERIMENTAL_ITERATOR