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