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 12 // template<class T> 13 // concept semiregular = see below; 14 15 #include <concepts> 16 17 #include <deque> 18 #include <forward_list> 19 #include <list> 20 #include <map> 21 #include <memory> 22 #include <optional> 23 #include <stdexcept> 24 #include <tuple> 25 #include <unordered_map> 26 #include <vector> 27 28 #include "type_classification/semiregular.h" 29 30 static_assert(std::semiregular<int>); 31 static_assert(std::semiregular<int volatile>); 32 static_assert(std::semiregular<int*>); 33 static_assert(std::semiregular<int const*>); 34 static_assert(std::semiregular<int volatile*>); 35 static_assert(std::semiregular<int volatile const*>); 36 static_assert(std::semiregular<int (*)()>); 37 38 struct S {}; 39 static_assert(std::semiregular<S>); 40 static_assert(std::semiregular<int S::*>); 41 static_assert(std::semiregular<int (S::*)()>); 42 static_assert(std::semiregular<int (S::*)() noexcept>); 43 static_assert(std::semiregular<int (S::*)() &>); 44 static_assert(std::semiregular<int (S::*)() & noexcept>); 45 static_assert(std::semiregular<int (S::*)() &&>); 46 static_assert(std::semiregular<int (S::*)() && noexcept>); 47 static_assert(std::semiregular<int (S::*)() const>); 48 static_assert(std::semiregular<int (S::*)() const noexcept>); 49 static_assert(std::semiregular<int (S::*)() const&>); 50 static_assert(std::semiregular<int (S::*)() const & noexcept>); 51 static_assert(std::semiregular<int (S::*)() const&&>); 52 static_assert(std::semiregular<int (S::*)() const && noexcept>); 53 static_assert(std::semiregular<int (S::*)() volatile>); 54 static_assert(std::semiregular<int (S::*)() volatile noexcept>); 55 static_assert(std::semiregular<int (S::*)() volatile&>); 56 static_assert(std::semiregular<int (S::*)() volatile & noexcept>); 57 static_assert(std::semiregular<int (S::*)() volatile&&>); 58 static_assert(std::semiregular<int (S::*)() volatile && noexcept>); 59 static_assert(std::semiregular<int (S::*)() const volatile>); 60 static_assert(std::semiregular<int (S::*)() const volatile noexcept>); 61 static_assert(std::semiregular<int (S::*)() const volatile&>); 62 static_assert(std::semiregular<int (S::*)() const volatile & noexcept>); 63 static_assert(std::semiregular<int (S::*)() const volatile&&>); 64 static_assert(std::semiregular<int (S::*)() const volatile && noexcept>); 65 66 static_assert(std::semiregular<std::vector<int> >); 67 static_assert(std::semiregular<std::deque<int> >); 68 static_assert(std::semiregular<std::forward_list<int> >); 69 static_assert(std::semiregular<std::list<int> >); 70 static_assert(std::semiregular<std::shared_ptr<std::unique_ptr<int> > >); 71 static_assert(std::semiregular<std::optional<std::vector<int> > >); 72 static_assert(std::semiregular<std::vector<int> >); 73 static_assert(std::semiregular<std::vector<std::unique_ptr<int> > >); 74 75 static_assert(std::semiregular<has_volatile_member>); 76 static_assert(std::semiregular<has_array_member>); 77 78 // Not objects 79 static_assert(!std::semiregular<void>); 80 static_assert(!std::semiregular<int&>); 81 static_assert(!std::semiregular<int const&>); 82 static_assert(!std::semiregular<int volatile&>); 83 static_assert(!std::semiregular<int const volatile&>); 84 static_assert(!std::semiregular<int&&>); 85 static_assert(!std::semiregular<int const&&>); 86 static_assert(!std::semiregular<int volatile&&>); 87 static_assert(!std::semiregular<int const volatile&&>); 88 static_assert(!std::semiregular<int()>); 89 static_assert(!std::semiregular<int (&)()>); 90 static_assert(!std::semiregular<int[5]>); 91 92 // Not copyable 93 static_assert(!std::semiregular<std::unique_ptr<int> >); 94 static_assert(!std::semiregular<int const>); 95 static_assert(!std::semiregular<int const volatile>); 96 static_assert(std::semiregular<const_copy_assignment const>); 97 static_assert(!std::semiregular<volatile_copy_assignment volatile>); 98 static_assert(std::semiregular<cv_copy_assignment const volatile>); 99 static_assert(!std::semiregular<no_copy_constructor>); 100 static_assert(!std::semiregular<no_copy_assignment>); 101 static_assert(!std::semiregular<no_copy_assignment_mutable>); 102 static_assert(!std::semiregular<derived_from_noncopyable>); 103 static_assert(!std::semiregular<has_noncopyable>); 104 static_assert(!std::semiregular<has_const_member>); 105 static_assert(!std::semiregular<has_cv_member>); 106 static_assert(!std::semiregular<has_lvalue_reference_member>); 107 static_assert(!std::semiregular<has_rvalue_reference_member>); 108 static_assert(!std::semiregular<has_function_ref_member>); 109 static_assert(!std::semiregular<deleted_assignment_from_const_rvalue>); 110 111 // Not default_initialzable 112 static_assert(!std::semiregular<std::runtime_error>); 113 static_assert( 114 !std::semiregular<std::tuple<std::runtime_error, std::overflow_error> >); 115 static_assert(!std::semiregular<std::nullopt_t>); 116 static_assert(!std::semiregular<no_copy_constructor>); 117 static_assert(!std::semiregular<no_copy_assignment>); 118 static_assert(std::is_copy_assignable_v<no_copy_assignment_mutable>); 119 static_assert(!std::semiregular<no_copy_assignment_mutable>); 120 static_assert(!std::semiregular<derived_from_noncopyable>); 121 static_assert(!std::semiregular<has_noncopyable>); 122 123 static_assert(!std::semiregular<no_default_ctor>); 124 static_assert(!std::semiregular<derived_from_non_default_initializable>); 125 static_assert(!std::semiregular<has_non_default_initializable>); 126 127 static_assert(!std::semiregular<deleted_default_ctor>); 128 static_assert(!std::semiregular<derived_from_deleted_default_ctor>); 129 static_assert(!std::semiregular<has_deleted_default_ctor>); 130 main(int,char **)131int main(int, char**) { return 0; } 132