From 21c38f261f2f6751b815992c6a33f6ef33f607ef Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Thu, 28 Jan 2016 04:15:35 +0000 Subject: Left a file out of r259014 llvm-svn: 259015 --- libcxx/include/experimental/iterator | 114 +++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 libcxx/include/experimental/iterator (limited to 'libcxx/include/experimental/iterator') diff --git a/libcxx/include/experimental/iterator b/libcxx/include/experimental/iterator new file mode 100644 index 00000000000..da593febe2b --- /dev/null +++ b/libcxx/include/experimental/iterator @@ -0,0 +1,114 @@ +// -*- C++ -*- +//===----------------------------- iterator -------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_ITERATOR +#define _LIBCPP_EXPERIMENTAL_ITERATOR + +/* +namespace std { + namespace experimental { + inline namespace fundamentals_v2 { + + template > + class ostream_joiner { + public: + typedef charT char_type; + typedef traits traits_type; + typedef basic_ostream 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 + 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 + ostream_joiner, charT, traits> + make_ostream_joiner(basic_ostream& os, DelimT&& delimiter); + + } // inline namespace fundamentals_v2 + } // namespace experimental +} // namespace std + +*/ + +#include + +#if _LIBCPP_STD_VER > 11 + +#include + +_LIBCPP_BEGIN_NAMESPACE_LFTS + +template > +class ostream_joiner { +public: + + typedef _CharT char_type; + typedef _Traits traits_type; + typedef basic_ostream 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& __os, _Delim&& __d) + : __out(_VSTD::addressof(__os)), __delim(_VSTD::move(__d)), __first(true) {} + + ostream_joiner(ostream_type& __os, const _Delim& __d) + : __out(_VSTD::addressof(__os)), __delim(__d), __first(true) {} + + + template + ostream_joiner& operator=(const _Tp& __v) + { + if (!__first) + *__out << __delim; + __first = false; + *__out << __v; + return *this; + } + + ostream_joiner& operator*() _NOEXCEPT { return *this; } + ostream_joiner& operator++() _NOEXCEPT { return *this; } + ostream_joiner& operator++(int) _NOEXCEPT { return *this; } + +private: + ostream_type* __out; + _Delim __delim; + bool __first; +}; + + +template +ostream_joiner::type, _CharT, _Traits> +make_ostream_joiner(basic_ostream<_CharT, _Traits>& __os, _Delim && __d) +{ return ostream_joiner::type, _CharT, _Traits>(__os, _VSTD::forward<_Delim>(__d)); } + +_LIBCPP_END_NAMESPACE_LFTS + +#endif /* _LIBCPP_STD_VER > 11 */ + +#endif // _LIBCPP_EXPERIMENTAL_ITERATOR -- cgit v1.2.3