brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · f7de32d Raw
53 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++1110// UNSUPPORTED: no-localization11 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++() noexcept18//     returns *this;19 20#include <experimental/iterator>21#include <iostream>22#include <cassert>23 24#include "test_macros.h"25 26namespace exper = std::experimental;27 28template <class Delim, class CharT, class Traits>29void 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 35int 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#ifndef TEST_HAS_NO_WIDE_CHARACTERS40    { exper::ostream_joiner<std::wstring> oj(std::cout, std::wstring(L"10")); test(oj); }41#endif42    { exper::ostream_joiner<int>          oj(std::cout, 11);                  test(oj); }43 44#ifndef TEST_HAS_NO_WIDE_CHARACTERS45    { exper::ostream_joiner<char, wchar_t>         oj(std::wcout, '8');                 test(oj); }46    { exper::ostream_joiner<std::string, wchar_t>  oj(std::wcout, std::string("9"));    test(oj); }47    { exper::ostream_joiner<std::wstring, wchar_t> oj(std::wcout, std::wstring(L"10")); test(oj); }48    { exper::ostream_joiner<int, wchar_t>          oj(std::wcout, 11);                  test(oj); }49#endif50 51  return 0;52}53