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
22template <class Out, class T>
23constexpr 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
29static_assert(check_indirectly_writable<value_type_indirection, int>());
30static_assert(check_indirectly_writable<value_type_indirection, double>());
31static_assert(!check_indirectly_writable<value_type_indirection, double*>());
32
33static_assert(!check_indirectly_writable<read_only_indirection, int>());
34static_assert(!check_indirectly_writable<proxy_indirection, int>());
35
36static_assert(!check_indirectly_writable<int, int>());
37static_assert(!check_indirectly_writable<missing_dereference, missing_dereference::value_type>());
38
39static_assert(!check_indirectly_writable<void*, int>());
40static_assert(!check_indirectly_writable<void const*, int>());
41static_assert(!check_indirectly_writable<void volatile*, int>());
42static_assert(!check_indirectly_writable<void const volatile*, int>());
43static_assert(!check_indirectly_writable<void*, double>());
44static_assert(check_indirectly_writable<void**, int*>());
45static_assert(!check_indirectly_writable<void**, int>());
46
47static_assert(check_indirectly_writable<int*, int>());
48static_assert(!check_indirectly_writable<int const*, int>());
49static_assert(check_indirectly_writable<int volatile*, int>());
50static_assert(!check_indirectly_writable<int const volatile*, int>());
51static_assert(check_indirectly_writable<int*, double>());
52static_assert(check_indirectly_writable<int**, int*>());
53static_assert(!check_indirectly_writable<int**, int>());
54

source code of libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.writable/indirectly_writable.compile.pass.cpp