| 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | // <iterator> |
| 10 | |
| 11 | // move_iterator |
| 12 | |
| 13 | // template <InputIterator Iter> |
| 14 | // move_iterator<Iter> |
| 15 | // make_move_iterator(const Iter& i); |
| 16 | // |
| 17 | // constexpr in C++17 |
| 18 | |
| 19 | #include <iterator> |
| 20 | #include <cassert> |
| 21 | |
| 22 | #include "test_macros.h" |
| 23 | #include "test_iterators.h" |
| 24 | |
| 25 | template <class It> |
| 26 | void |
| 27 | test(It i) |
| 28 | { |
| 29 | const std::move_iterator<It> r(i); |
| 30 | assert(std::make_move_iterator(i) == r); |
| 31 | } |
| 32 | |
| 33 | int main(int, char**) |
| 34 | { |
| 35 | { |
| 36 | char s[] = "1234567890" ; |
| 37 | test(cpp17_input_iterator<char*>(s+5)); |
| 38 | test(forward_iterator<char*>(s+5)); |
| 39 | test(bidirectional_iterator<char*>(s+5)); |
| 40 | test(random_access_iterator<char*>(s+5)); |
| 41 | test(i: s+5); |
| 42 | } |
| 43 | { |
| 44 | int a[] = {1,2,3,4}; |
| 45 | TEST_IGNORE_NODISCARD std::make_move_iterator(a+4); |
| 46 | TEST_IGNORE_NODISCARD std::make_move_iterator(a); // test for LWG issue 2061 |
| 47 | } |
| 48 | |
| 49 | #if TEST_STD_VER > 14 |
| 50 | { |
| 51 | constexpr const char *p = "123456789" ; |
| 52 | constexpr auto iter = std::make_move_iterator<const char *>(p); |
| 53 | static_assert(iter.base() == p, "" ); |
| 54 | } |
| 55 | #endif |
| 56 | |
| 57 | return 0; |
| 58 | } |
| 59 | |