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// <iterator>
11
12// class ostream_iterator
13
14// ostream_iterator& operator=(const T& value);
15
16#include <iterator>
17#include <sstream>
18#include <cassert>
19
20#if defined(__clang__)
21#pragma clang diagnostic ignored "-Wliteral-conversion"
22#endif
23
24#ifdef _MSC_VER
25#pragma warning(disable: 4244) // conversion from 'X' to 'Y', possible loss of data
26#endif
27
28int main()
29{
30    {
31        std::ostringstream outf;
32        std::ostream_iterator<int> i(outf);
33        i = 2.4;
34        assert(outf.str() == "2");
35    }
36    {
37        std::ostringstream outf;
38        std::ostream_iterator<int> i(outf, ", ");
39        i = 2.4;
40        assert(outf.str() == "2, ");
41    }
42    {
43        std::wostringstream outf;
44        std::ostream_iterator<int, wchar_t> i(outf);
45        i = 2.4;
46        assert(outf.str() == L"2");
47    }
48    {
49        std::wostringstream outf;
50        std::ostream_iterator<int, wchar_t> i(outf, L", ");
51        i = 2.4;
52        assert(outf.str() == L"2, ");
53    }
54}
55