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 // move_iterator
13
14 // Test nested types:
15
16 // template <InputIterator Iter>
17 // class move_iterator {
18 // public:
19 // typedef Iter iterator_type;
20 // typedef Iter::difference_type difference_type;
21 // typedef Iterator pointer;
22 // typedef Iter::value_type value_type;
23 // typedef value_type&& reference;
24 // };
25
26 #include <iterator>
27 #include <type_traits>
28
29 #include "test_iterators.h"
30
31 template <class It>
32 void
test()33 test()
34 {
35 typedef std::move_iterator<It> R;
36 typedef std::iterator_traits<It> T;
37 static_assert((std::is_same<typename R::iterator_type, It>::value), "");
38 static_assert((std::is_same<typename R::difference_type, typename T::difference_type>::value), "");
39 static_assert((std::is_same<typename R::pointer, typename T::pointer>::value), "");
40 static_assert((std::is_same<typename R::value_type, typename T::value_type>::value), "");
41 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
42 static_assert((std::is_same<typename R::reference, typename R::value_type&&>::value), "");
43 #else
44 static_assert((std::is_same<typename R::reference, typename T::reference>::value), "");
45 #endif
46 static_assert((std::is_same<typename R::iterator_category, typename T::iterator_category>::value), "");
47 }
48
main()49 int main()
50 {
51 test<input_iterator<char*> >();
52 test<forward_iterator<char*> >();
53 test<bidirectional_iterator<char*> >();
54 test<random_access_iterator<char*> >();
55 test<char*>();
56 }
57