| 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 |
// move_iterator& operator++(); |
| 14 |
// |
| 15 |
// constexpr in C++17 |
| 16 |
|
| 17 |
#include <iterator> |
| 18 |
#include <cassert> |
| 19 |
|
| 20 |
#include "test_macros.h" |
| 21 |
#include "test_iterators.h" |
| 22 |
|
| 23 |
template <class It> |
| 24 |
void |
| 25 |
test(It i, It x) |
| 26 |
{ |
| 27 |
std::move_iterator<It> r(i); |
| 28 |
std::move_iterator<It>& rr = ++r; |
| 29 |
assert(r.base() == x); |
| 30 |
assert(&rr == &r); |
| 31 |
} |
| 32 |
|
| 33 |
int main(int, char**) |
| 34 |
{ |
| 35 |
char s[] = "123"; |
| 36 |
test(cpp17_input_iterator<char*>(s), cpp17_input_iterator<char*>(s+1)); |
| 37 |
test(forward_iterator<char*>(s), forward_iterator<char*>(s+1)); |
| 38 |
test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s+1)); |
| 39 |
test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1)); |
| 40 |
test(s, s+1); |
| 41 |
|
| 42 |
#if TEST_STD_VER > 14 |
| 43 |
{ |
| 44 |
constexpr const char *p = "123456789"; |
| 45 |
typedef std::move_iterator<const char *> MI; |
| 46 |
constexpr MI it1 = std::make_move_iterator(p); |
| 47 |
constexpr MI it2 = std::make_move_iterator(p+1); |
| 48 |
static_assert(it1 != it2, ""); |
| 49 |
constexpr MI it3 = ++ std::make_move_iterator(p); |
| 50 |
static_assert(it1 != it3, ""); |
| 51 |
static_assert(it2 == it3, ""); |
| 52 |
} |
| 53 |
#endif |
| 54 |
|
| 55 |
return 0; |
| 56 |
} |