increment.pass.cpp (754B)
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++(); 15 // ostream_iterator& operator++(int); 16 17 #include <iterator> 18 #include <sstream> 19 #include <cassert> 20 21 int main() 22 { 23 std::ostringstream os; 24 std::ostream_iterator<int> i(os); 25 std::ostream_iterator<int>& iref1 = ++i; 26 assert(&iref1 == &i); 27 std::ostream_iterator<int>& iref2 = i++; 28 assert(&iref2 == &i); 29 }