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 // UNSUPPORTED: libcpp-has-no-incomplete-ranges 11 12 // __non_propagating_cache(); 13 14 #include <ranges> 15 16 #include <cassert> 17 #include <type_traits> 18 19 struct HasDefault { HasDefault() = default; }; 20 struct NoDefault { NoDefault() = delete; }; 21 22 template <class T> test()23constexpr void test() { 24 using Cache = std::ranges::__non_propagating_cache<T>; 25 static_assert(std::is_nothrow_default_constructible_v<Cache>); 26 Cache cache; 27 assert(!cache.__has_value()); 28 } 29 tests()30constexpr bool tests() { 31 test<HasDefault>(); 32 test<NoDefault>(); 33 test<int>(); 34 test<char*>(); 35 return true; 36 } 37 main(int,char **)38int main(int, char**) { 39 static_assert(tests()); 40 tests(); 41 return 0; 42 } 43