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 // <iterator> 12 13 // move_sentinel 14 15 // constexpr explicit move_sentinel(S s); 16 17 #include <iterator> 18 #include <cassert> 19 test()20constexpr bool test() 21 { 22 // The underlying sentinel is an integer. 23 { 24 static_assert(!std::is_convertible_v<int, std::move_sentinel<int>>); 25 std::move_sentinel<int> m(42); 26 assert(m.base() == 42); 27 } 28 29 // The underlying sentinel is a pointer. 30 { 31 static_assert(!std::is_convertible_v<int*, std::move_sentinel<int*>>); 32 int i = 42; 33 std::move_sentinel<int*> m(&i); 34 assert(m.base() == &i); 35 } 36 37 // The underlying sentinel is a user-defined type with an explicit default constructor. 38 { 39 struct S { 40 explicit S() = default; 41 constexpr explicit S(int j) : i(j) {} 42 int i = 3; 43 }; 44 static_assert(!std::is_convertible_v<S, std::move_sentinel<S>>); 45 std::move_sentinel<S> m(S(42)); 46 assert(m.base().i == 42); 47 } 48 return true; 49 } 50 main(int,char **)51int main(int, char**) 52 { 53 test(); 54 static_assert(test()); 55 56 return 0; 57 } 58