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 | // template<class In> |
12 | // concept indirectly_writable; |
13 | |
14 | #include <iterator> |
15 | |
16 | #include <concepts> |
17 | #include <memory> |
18 | #include <optional> |
19 | |
20 | #include "read_write.h" |
21 | |
22 | template <class Out, class T> |
23 | constexpr bool check_indirectly_writable() { |
24 | constexpr bool result = std::indirectly_writable<Out, T>; |
25 | static_assert(std::indirectly_writable<Out const, T> == result); |
26 | return result; |
27 | } |
28 | |
29 | static_assert(check_indirectly_writable<value_type_indirection, int>()); |
30 | static_assert(check_indirectly_writable<value_type_indirection, double>()); |
31 | static_assert(!check_indirectly_writable<value_type_indirection, double*>()); |
32 | |
33 | static_assert(!check_indirectly_writable<read_only_indirection, int>()); |
34 | static_assert(!check_indirectly_writable<proxy_indirection, int>()); |
35 | |
36 | static_assert(!check_indirectly_writable<int, int>()); |
37 | static_assert(!check_indirectly_writable<missing_dereference, missing_dereference::value_type>()); |
38 | |
39 | static_assert(!check_indirectly_writable<void*, int>()); |
40 | static_assert(!check_indirectly_writable<void const*, int>()); |
41 | static_assert(!check_indirectly_writable<void volatile*, int>()); |
42 | static_assert(!check_indirectly_writable<void const volatile*, int>()); |
43 | static_assert(!check_indirectly_writable<void*, double>()); |
44 | static_assert(check_indirectly_writable<void**, int*>()); |
45 | static_assert(!check_indirectly_writable<void**, int>()); |
46 | |
47 | static_assert(check_indirectly_writable<int*, int>()); |
48 | static_assert(!check_indirectly_writable<int const*, int>()); |
49 | static_assert(check_indirectly_writable<int volatile*, int>()); |
50 | static_assert(!check_indirectly_writable<int const volatile*, int>()); |
51 | static_assert(check_indirectly_writable<int*, double>()); |
52 | static_assert(check_indirectly_writable<int**, int*>()); |
53 | static_assert(!check_indirectly_writable<int**, int>()); |
54 | |