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 | // <iterator> |
10 | |
11 | // class ostream_iterator |
12 | |
13 | // ostream_iterator(ostream_type& s, const charT* delimiter); |
14 | |
15 | #include <iterator> |
16 | #include <sstream> |
17 | #include <cassert> |
18 | |
19 | #include "test_macros.h" |
20 | |
21 | |
22 | struct MyTraits : std::char_traits<char> {}; |
23 | |
24 | typedef std::basic_ostringstream<char, MyTraits> StringStream; |
25 | typedef std::basic_ostream<char, MyTraits> BasicStream; |
26 | |
27 | void operator&(BasicStream const&) {} |
28 | |
29 | int main(int, char**) |
30 | { |
31 | { |
32 | std::ostringstream outf; |
33 | std::ostream_iterator<int> i(outf, ", " ); |
34 | assert(outf.good()); |
35 | } |
36 | #ifndef TEST_HAS_NO_WIDE_CHARACTERS |
37 | { |
38 | std::wostringstream outf; |
39 | std::ostream_iterator<double, wchar_t> i(outf, L", " ); |
40 | assert(outf.good()); |
41 | } |
42 | #endif |
43 | { |
44 | StringStream outf; |
45 | std::ostream_iterator<int, char, MyTraits> i(outf, ", " ); |
46 | assert(outf.good()); |
47 | } |
48 | |
49 | return 0; |
50 | } |
51 | |