1// <experimental/iterator> -*- C++ -*-
3// Copyright (C) 2015-2019 Free Software Foundation, Inc.
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 3, or (at your option)
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
16// Under Section 7 of GPL version 3, you are granted additional
17// permissions described in the GCC Runtime Library Exception, version
18// 3.1, as published by the Free Software Foundation.
20// You should have received a copy of the GNU General Public License and
21// a copy of the GCC Runtime Library Exception along with this program;
22// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23// <http://www.gnu.org/licenses/>.
25/** @file experimental/iterator
26 * This is a TS C++ Library header.
30// N4336 Working Draft, C++ Extensions for Library Fundamentals, Version 2
33#ifndef _GLIBCXX_EXPERIMENTAL_ITERATOR
34#define _GLIBCXX_EXPERIMENTAL_ITERATOR 1
36#pragma GCC system_header
38#if __cplusplus >= 201402L
42#include <experimental/type_traits>
44namespace std _GLIBCXX_VISIBILITY(default)
46_GLIBCXX_BEGIN_NAMESPACE_VERSION
50inline namespace fundamentals_v2
52#define __cpp_lib_experimental_ostream_joiner 201411
54 /// Output iterator that inserts a delimiter between elements.
55 template<typename _DelimT, typename _CharT = char,
56 typename _Traits = char_traits<_CharT>>
60 typedef _CharT char_type;
61 typedef _Traits traits_type;
62 typedef basic_ostream<_CharT, _Traits> ostream_type;
63 typedef output_iterator_tag iterator_category;
64 typedef void value_type;
65 typedef void difference_type;
67 typedef void reference;
69 ostream_joiner(ostream_type& __os, const _DelimT& __delimiter)
70 noexcept(is_nothrow_copy_constructible_v<_DelimT>)
71 : _M_out(std::__addressof(__os)), _M_delim(__delimiter)
74 ostream_joiner(ostream_type& __os, _DelimT&& __delimiter)
75 noexcept(is_nothrow_move_constructible_v<_DelimT>)
76 : _M_out(std::__addressof(__os)), _M_delim(std::move(__delimiter))
79 template<typename _Tp>
81 operator=(const _Tp& __value)
90 ostream_joiner& operator*() noexcept { return *this; }
91 ostream_joiner& operator++() noexcept { return *this; }
92 ostream_joiner& operator++(int) noexcept { return *this; }
100 /// Object generator for ostream_joiner.
101 template<typename _CharT, typename _Traits, typename _DelimT>
102 inline ostream_joiner<decay_t<_DelimT>, _CharT, _Traits>
103 make_ostream_joiner(basic_ostream<_CharT, _Traits>& __os,
104 _DelimT&& __delimiter)
105 { return { __os, std::forward<_DelimT>(__delimiter) }; }
106} // namespace fundamentals_v2
107} // namespace experimental
109_GLIBCXX_END_NAMESPACE_VERSION
112#endif // __cplusplus <= 201103L
114#endif // _GLIBCXX_EXPERIMENTAL_ITERATOR