Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <iterator> |
| 11 | |
| 12 | // move_iterator |
| 13 | |
| 14 | // Test nested types: |
| 15 | |
Howard Hinnant | 712522c | 2010-08-22 00:29:01 +0000 | [diff] [blame] | 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; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 24 | // }; |
| 25 | |
| 26 | #include <iterator> |
| 27 | #include <type_traits> |
| 28 | |
| 29 | #include "../../../iterators.h" |
| 30 | |
| 31 | template <class It> |
| 32 | void |
| 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), ""); |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 41 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 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 | |
| 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 | } |