]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/experimental/iterator/requirements.cc
1 // Copyright (C) 2015-2021 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-do compile { target c++14 } }
20 // This is a compile-only test with minimal includes
21 #include <experimental/iterator>
22 #include <iosfwd> // No guarantee that <experimental/iterator> includes this!
24 using namespace std::experimental
;
26 template<typename Delim
, typename Char
>
29 using joiner_type
= ostream_joiner
<Delim
, Char
>;
30 using ostream_type
= std::basic_ostream
<Char
>;
31 using test_type
= decltype(make_ostream_joiner(std::declval
<ostream_type
&>(),
32 std::declval
<Delim
>()));
34 static_assert(is_same_v
<test_type
, joiner_type
>, "");
36 static_assert(is_same_v
<typename
test_type::char_type
, Char
>, "");
38 static_assert(is_same_v
<typename
test_type::traits_type
,
39 std::char_traits
<Char
>>, "");
41 static_assert(is_same_v
<typename
test_type::ostream_type
, ostream_type
>, "");
43 static_assert(is_same_v
<typename
test_type::iterator_category
,
44 std::output_iterator_tag
>, "");
46 static_assert(is_same_v
<typename
test_type::value_type
, void>, "");
47 static_assert(is_same_v
<typename
test_type::difference_type
, void>, "");
48 static_assert(is_same_v
<typename
test_type::pointer
, void>, "");
49 static_assert(is_same_v
<typename
test_type::reference
, void>, "");
52 tester
<char, char> cc
;
54 #if _GLIBCXX_USE_WCHAR_T
55 tester
<wchar_t, wchar_t> ww
;
56 tester
<int, wchar_t> iw
;
61 // Ensure that contents of <iterator> are defined by <experimental/iterator>:
62 std::reverse_iterator
<int*> ii
;
63 std::move_iterator
<int*> mi
;
64 std::istream_iterator
<int> isi
;
65 std::ostream_iterator
<int> osi(os());
66 std::istreambuf_iterator
<char> isbi
;
69 std::ostreambuf_iterator
<char> osbi(os());