Dan Albert | 287553d | 2017-02-16 10:47:51 -0800 | [diff] [blame] | 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 | int main() |
| 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 | { |
| 39 | std::wostringstream outf; |
| 40 | std::ostream_iterator<int, wchar_t> i(outf); |
| 41 | i = 2.4; |
| 42 | assert(outf.str() == L"2"); |
| 43 | } |
| 44 | { |
| 45 | std::wostringstream outf; |
| 46 | std::ostream_iterator<int, wchar_t> i(outf, L", "); |
| 47 | i = 2.4; |
| 48 | assert(outf.str() == L"2, "); |
| 49 | } |
| 50 | } |