Home | History | Annotate | Download | only in ostream.joiner.ops
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 // UNSUPPORTED: c++98, c++03, c++11
     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 exp = std::experimental;
     27 
     28 template <class Delim, class CharT, class Traits>
     29 void test ( exp::ostream_joiner<Delim, CharT, Traits> &oj ) {
     30     static_assert((noexcept(*oj)), "" );
     31     exp::ostream_joiner<Delim, CharT, Traits> &ret = *oj;
     32     assert( &ret == &oj );
     33     }
     34 
     35 int main () {
     36 
     37     { exp::ostream_joiner<char>         oj(std::cout, '8');                 test(oj); }
     38     { exp::ostream_joiner<std::string>  oj(std::cout, std::string("9"));    test(oj); }
     39     { exp::ostream_joiner<std::wstring> oj(std::cout, std::wstring(L"10")); test(oj); }
     40     { exp::ostream_joiner<int>          oj(std::cout, 11);                  test(oj); }
     41 
     42     { exp::ostream_joiner<char, wchar_t>         oj(std::wcout, '8');                 test(oj); }
     43     { exp::ostream_joiner<std::string, wchar_t>  oj(std::wcout, std::string("9"));    test(oj); }
     44     { exp::ostream_joiner<std::wstring, wchar_t> oj(std::wcout, std::wstring(L"10")); test(oj); }
     45     { exp::ostream_joiner<int, wchar_t>          oj(std::wcout, 11);                  test(oj); }
     46     }
     47