| 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(); |
| 14 |
// |
| 15 |
// constexpr in C++17 |
| 16 |
// |
| 17 |
// requires the underlying iterator to be default-constructible (extension). |
| 18 |
|
| 19 |
#include <iterator> |
| 20 |
|
| 21 |
#include <type_traits> |
| 22 |
#include "test_macros.h" |
| 23 |
#include "test_iterators.h" |
| 24 |
|
| 25 |
#if TEST_STD_VER > 17 |
| 26 |
struct NoDefaultCtr : forward_iterator<int*> { |
| 27 |
NoDefaultCtr() = delete; |
| 28 |
}; |
| 29 |
|
| 30 |
LIBCPP_STATIC_ASSERT( std::is_default_constructible_v<std::move_iterator<forward_iterator<int*>>>); |
| 31 |
LIBCPP_STATIC_ASSERT(!std::is_default_constructible_v<std::move_iterator<NoDefaultCtr>>); |
| 32 |
#endif |
| 33 |
|
| 34 |
template <class It> |
| 35 |
void test() { |
| 36 |
std::move_iterator<It> r; |
| 37 |
(void)r; |
| 38 |
} |
| 39 |
|
| 40 |
int main(int, char**) { |
| 41 |
// we don't have a test iterator that is both input and default-constructible, so not testing that case |
| 42 |
test<forward_iterator<char*> >(); |
| 43 |
test<bidirectional_iterator<char*> >(); |
| 44 |
test<random_access_iterator<char*> >(); |
| 45 |
test<char*>(); |
| 46 |
|
| 47 |
#if TEST_STD_VER > 14 |
| 48 |
{ |
| 49 |
constexpr std::move_iterator<const char *> it; |
| 50 |
(void)it; |
| 51 |
} |
| 52 |
#endif |
| 53 |
|
| 54 |
return 0; |
| 55 |
} |