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& operator=(const T& value);
14
15#include <iterator>
16#include <sstream>
17#include <cassert>
18
19#include "test_macros.h"
20
21TEST_CLANG_DIAGNOSTIC_IGNORED("-Wliteral-conversion")
22TEST_MSVC_DIAGNOSTIC_IGNORED(4244) // conversion from 'X' to 'Y', possible loss of data
23
24int main(int, char**)
25{
26 {
27 std::ostringstream outf;
28 std::ostream_iterator<int> i(outf);
29 i = 2.4;
30 assert(outf.str() == "2");
31 }
32 {
33 std::ostringstream outf;
34 std::ostream_iterator<int> i(outf, ", ");
35 i = 2.4;
36 assert(outf.str() == "2, ");
37 }
38#ifndef TEST_HAS_NO_WIDE_CHARACTERS
39 {
40 std::wostringstream outf;
41 std::ostream_iterator<int, wchar_t> i(outf);
42 i = 2.4;
43 assert(outf.str() == L"2");
44 }
45 {
46 std::wostringstream outf;
47 std::ostream_iterator<int, wchar_t> i(outf, L", ");
48 i = 2.4;
49 assert(outf.str() == L"2, ");
50 }
51#endif
52
53 return 0;
54}
55

source code of libcxx/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp