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 
21 #if defined(TEST_COMPILER_CLANG)
22 #pragma clang diagnostic ignored "-Wliteral-conversion"
23 #endif
24 
25 #ifdef TEST_COMPILER_C1XX
26 #pragma warning(disable: 4244) // conversion from 'X' to 'Y', possible loss of data
27 #endif
28 
main(int,char **)29 int main(int, char**)
30 {
31     {
32         std::ostringstream outf;
33         std::ostream_iterator<int> i(outf);
34         i = 2.4;
35         assert(outf.str() == "2");
36     }
37     {
38         std::ostringstream outf;
39         std::ostream_iterator<int> i(outf, ", ");
40         i = 2.4;
41         assert(outf.str() == "2, ");
42     }
43     {
44         std::wostringstream outf;
45         std::ostream_iterator<int, wchar_t> i(outf);
46         i = 2.4;
47         assert(outf.str() == L"2");
48     }
49     {
50         std::wostringstream outf;
51         std::ostream_iterator<int, wchar_t> i(outf, L", ");
52         i = 2.4;
53         assert(outf.str() == L"2, ");
54     }
55 
56   return 0;
57 }
58