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 // reverse_iterator 13 14 // reference operator*() const; 15 16 // Be sure to respect LWG 198: 17 // http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#198 18 // LWG 198 was superseded by LWG 2360 19 // http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2360 20 21 #include <iterator> 22 #include <cassert> 23 24 class A 25 { 26 int data_; 27 public: A()28 A() : data_(1) {} ~A()29 ~A() {data_ = -1;} 30 operator ==(const A & x,const A & y)31 friend bool operator==(const A& x, const A& y) 32 {return x.data_ == y.data_;} 33 }; 34 35 template <class It> 36 void test(It i,typename std::iterator_traits<It>::value_type x)37test(It i, typename std::iterator_traits<It>::value_type x) 38 { 39 std::reverse_iterator<It> r(i); 40 assert(*r == x); 41 } 42 main()43int main() 44 { 45 A a; 46 test(&a+1, A()); 47 } 48