]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/experimental/iterator/ostream_joiner.cc
1 // Copyright (C) 2015-2016 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-options "-std=gnu++14" }
20 #include <experimental/iterator>
22 #include <testsuite_hooks.h>
24 #ifndef __cpp_lib_experimental_ostream_joiner
25 # error Feature-test macro is not defined.
26 #elif __cpp_lib_experimental_ostream_joiner < 201411
27 # error Feature-test macro has bad value.
30 using std::experimental::ostream_joiner
;
35 std::ostringstream os
;
36 ostream_joiner
<int> joiner
{os
, 9};
37 for (int i
: { 1, 2, 3, 4, 5 })
39 VERIFY( os
.str() == "192939495" );
45 std::ostringstream os
;
46 ostream_joiner
<char> joiner
{os
, ','};
47 for (int i
: { 1, 2, 3, 4, 5 })
52 VERIFY( os
.str() == "1,2,3,4,5" );
58 #if _GLIBCXX_USE_WCHAR_T
59 std::wostringstream os
;
60 ostream_joiner
<wchar_t, wchar_t> joiner
{os
, L
','};
61 for (int i
: { 1, 2, 3, 4, 5 })
63 VERIFY( os
.str() == L
"1,2,3,4,5" );