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