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 // UNSUPPORTED: c++03, c++11, c++14, c++17 10 11 // constexpr common_iterator(I i); 12 13 #include <iterator> 14 #include <cassert> 15 16 #include "test_iterators.h" 17 18 template<class It> test()19constexpr bool test() { 20 using CommonIt = std::common_iterator<It, sentinel_wrapper<It>>; 21 int a[] = {1,2,3}; 22 It it = It(a); 23 CommonIt lv = CommonIt(it); 24 assert(&*lv == a); 25 CommonIt rv = CommonIt(std::move(it)); 26 assert(&*rv == a); 27 28 return true; 29 } 30 main(int,char **)31int main(int, char**) { 32 test<cpp17_input_iterator<int*>>(); 33 test<forward_iterator<int*>>(); 34 test<bidirectional_iterator<int*>>(); 35 test<random_access_iterator<int*>>(); 36 test<contiguous_iterator<int*>>(); 37 test<int*>(); 38 test<const int*>(); 39 40 static_assert(test<cpp17_input_iterator<int*>>()); 41 static_assert(test<forward_iterator<int*>>()); 42 static_assert(test<bidirectional_iterator<int*>>()); 43 static_assert(test<random_access_iterator<int*>>()); 44 static_assert(test<contiguous_iterator<int*>>()); 45 static_assert(test<int*>()); 46 static_assert(test<const int*>()); 47 48 return 0; 49 } 50