| //===----------------------------------------------------------------------===// |
| // |
| // The LLVM Compiler Infrastructure |
| // |
| // This file is dual licensed under the MIT and the University of Illinois Open |
| // Source Licenses. See LICENSE.TXT for details. |
| // |
| //===----------------------------------------------------------------------===// |
| |
| // <iterator> |
| |
| // reverse_iterator |
| |
| // reference operator*() const; |
| |
| // Be sure to respect LWG 198: |
| // http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#198 |
| // LWG 198 was superseded by LWG 2360 |
| // http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2360 |
| |
| #include <iterator> |
| #include <cassert> |
| |
| class A |
| { |
| int data_; |
| public: |
| A() : data_(1) {} |
| ~A() {data_ = -1;} |
| |
| friend bool operator==(const A& x, const A& y) |
| {return x.data_ == y.data_;} |
| }; |
| |
| template <class It> |
| void |
| test(It i, typename std::iterator_traits<It>::value_type x) |
| { |
| std::reverse_iterator<It> r(i); |
| assert(*r == x); |
| } |
| |
| int main() |
| { |
| A a; |
| test(&a+1, A()); |
| } |