Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/c++/v1/experimental/iterator is written in an unsupported language. File is not indexed.

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_EXPERIMENTAL_ITERATOR
0011 #define _LIBCPP_EXPERIMENTAL_ITERATOR
0012 
0013 /*
0014 namespace std {
0015   namespace experimental {
0016     inline namespace fundamentals_v2 {
0017 
0018     template <class DelimT, class charT = char, class traits = char_traits<charT>>
0019         class ostream_joiner {
0020         public:
0021          typedef charT                        char_type;
0022          typedef traits                       traits_type;
0023          typedef basic_ostream<charT, traits> ostream_type;
0024          typedef output_iterator_tag          iterator_category;
0025          typedef void                         value_type;
0026          typedef void                         difference_type;
0027          typedef void                         pointer;
0028          typedef void                         reference;
0029 
0030          ostream_joiner(ostream_type& s, const DelimT& delimiter);
0031          ostream_joiner(ostream_type& s, DelimT&& delimiter);
0032 
0033          template<typename T>
0034          ostream_joiner& operator=(const T& value);
0035 
0036          ostream_joiner& operator*() noexcept;
0037          ostream_joiner& operator++() noexcept;
0038          ostream_joiner& operator++(int) noexcept;
0039    private:
0040       ostream_type* out_stream;   // exposition only
0041       DelimT delim;               // exposition only
0042       bool first_element;         // exposition only
0043    };
0044 
0045   template <class charT, class traits, class DelimT>
0046     ostream_joiner<decay_t<DelimT>, charT, traits>
0047     make_ostream_joiner(basic_ostream<charT, traits>& os, DelimT&& delimiter);
0048 
0049     } // inline namespace fundamentals_v2
0050   } // namespace experimental
0051 } // namespace std
0052 
0053 */
0054 
0055 #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
0056 #  include <__cxx03/experimental/iterator>
0057 #else
0058 #  include <__config>
0059 #  include <__memory/addressof.h>
0060 #  include <__ostream/basic_ostream.h>
0061 #  include <__string/char_traits.h>
0062 #  include <__type_traits/decay.h>
0063 #  include <__utility/forward.h>
0064 #  include <__utility/move.h>
0065 #  include <iterator>
0066 
0067 #  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0068 #    pragma GCC system_header
0069 #  endif
0070 
0071 _LIBCPP_PUSH_MACROS
0072 #  include <__undef_macros>
0073 
0074 #  if _LIBCPP_STD_VER >= 14
0075 
0076 _LIBCPP_BEGIN_NAMESPACE_LFTS
0077 
0078 template <class _Delim, class _CharT = char, class _Traits = char_traits<_CharT>>
0079 class ostream_joiner {
0080 public:
0081   typedef _CharT char_type;
0082   typedef _Traits traits_type;
0083   typedef basic_ostream<char_type, traits_type> ostream_type;
0084   typedef output_iterator_tag iterator_category;
0085   typedef void value_type;
0086   typedef void difference_type;
0087   typedef void pointer;
0088   typedef void reference;
0089 
0090   _LIBCPP_HIDE_FROM_ABI ostream_joiner(ostream_type& __os, _Delim&& __d)
0091       : __output_iter_(std::addressof(__os)), __delim_(std::move(__d)), __first_(true) {}
0092 
0093   _LIBCPP_HIDE_FROM_ABI ostream_joiner(ostream_type& __os, const _Delim& __d)
0094       : __output_iter_(std::addressof(__os)), __delim_(__d), __first_(true) {}
0095 
0096   template <typename _Tp>
0097   _LIBCPP_HIDE_FROM_ABI ostream_joiner& operator=(const _Tp& __v) {
0098     if (!__first_)
0099       *__output_iter_ << __delim_;
0100     __first_ = false;
0101     *__output_iter_ << __v;
0102     return *this;
0103   }
0104 
0105   _LIBCPP_HIDE_FROM_ABI ostream_joiner& operator*() _NOEXCEPT { return *this; }
0106   _LIBCPP_HIDE_FROM_ABI ostream_joiner& operator++() _NOEXCEPT { return *this; }
0107   _LIBCPP_HIDE_FROM_ABI ostream_joiner& operator++(int) _NOEXCEPT { return *this; }
0108 
0109 private:
0110   ostream_type* __output_iter_;
0111   _Delim __delim_;
0112   bool __first_;
0113 };
0114 
0115 template <class _CharT, class _Traits, class _Delim>
0116 _LIBCPP_HIDE_FROM_ABI ostream_joiner<__decay_t<_Delim>, _CharT, _Traits>
0117 make_ostream_joiner(basic_ostream<_CharT, _Traits>& __os, _Delim&& __d) {
0118   return ostream_joiner<__decay_t<_Delim>, _CharT, _Traits>(__os, std::forward<_Delim>(__d));
0119 }
0120 
0121 _LIBCPP_END_NAMESPACE_LFTS
0122 
0123 #  endif // _LIBCPP_STD_VER >= 14
0124 
0125 _LIBCPP_POP_MACROS
0126 
0127 #  if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
0128 #    include <cstddef>
0129 #    include <iosfwd>
0130 #    include <type_traits>
0131 #  endif
0132 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
0133 
0134 #endif // _LIBCPP_EXPERIMENTAL_ITERATOR