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