1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // UNSUPPORTED: c++03, c++11
10 // UNSUPPORTED: libcpp-has-no-localization
11 
12 // <experimental/iterator>
13 //
14 // template <class _Delim, class _CharT = char, class _Traits = char_traits<_CharT>>
15 //   class ostream_joiner;
16 //
17 //   ostream_joiner & operator*() noexcept
18 //     returns *this;
19 
20 #include <experimental/iterator>
21 #include <iostream>
22 #include <cassert>
23 
24 #include "test_macros.h"
25 
26 namespace exper = std::experimental;
27 
28 template <class Delim, class CharT, class Traits>
test(exper::ostream_joiner<Delim,CharT,Traits> & oj)29 void test ( exper::ostream_joiner<Delim, CharT, Traits> &oj ) {
30     static_assert((noexcept(*oj)), "" );
31     exper::ostream_joiner<Delim, CharT, Traits> &ret = *oj;
32     assert( &ret == &oj );
33     }
34 
main(int,char **)35 int main(int, char**) {
36 
37     { exper::ostream_joiner<char>         oj(std::cout, '8');                 test(oj); }
38     { exper::ostream_joiner<std::string>  oj(std::cout, std::string("9"));    test(oj); }
39     { exper::ostream_joiner<std::wstring> oj(std::cout, std::wstring(L"10")); test(oj); }
40     { exper::ostream_joiner<int>          oj(std::cout, 11);                  test(oj); }
41 
42     { exper::ostream_joiner<char, wchar_t>         oj(std::wcout, '8');                 test(oj); }
43     { exper::ostream_joiner<std::string, wchar_t>  oj(std::wcout, std::string("9"));    test(oj); }
44     { exper::ostream_joiner<std::wstring, wchar_t> oj(std::wcout, std::wstring(L"10")); test(oj); }
45     { exper::ostream_joiner<int, wchar_t>          oj(std::wcout, 11);                  test(oj); }
46 
47   return 0;
48 }
49