//===----------------------------------------------------------------------===// // // 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. // //===----------------------------------------------------------------------===// // // move_iterator // reference operator*() const; #include #include #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #include #endif 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 void test(It i, typename std::iterator_traits::value_type x) { std::move_iterator r(i); assert(*r == x); typename std::iterator_traits::value_type x2 = *r; assert(x2 == x); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES struct do_nothing { void operator()(void*) const {} }; #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES int main() { A a; test(&a, A()); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES int i; std::unique_ptr p(&i); test(&p, std::unique_ptr(&i)); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES }