|
10 | 10 | #include <type_traits> |
11 | 11 |
|
12 | 12 | #include "preview/__core/inline_variable.h" |
| 13 | +#include "preview/__concepts_v2/detail/config.h" |
13 | 14 | #include "preview/__concepts_v2/detail/forward_declare.h" |
14 | 15 | #include "preview/__type_traits/conjunction.h" |
15 | 16 | #include "preview/__type_traits/is_invocable.h" |
16 | 17 | #include "preview/__type_traits/is_specialization.h" |
17 | 18 | #include "preview/__type_traits/negation.h" |
18 | 19 |
|
19 | | -namespace preview { |
20 | | -namespace concepts { |
| 20 | +// Use shorter namespace to reduce error message length |
| 21 | +PREVIEW_CONCEPT_LEXICAL_NAMESPACE_OPEN |
21 | 22 |
|
22 | 23 | template<typename Constraints, typename... Info> |
23 | 24 | struct constraints_not_satisfied : std::false_type {}; |
@@ -54,40 +55,41 @@ using concat_error_t = typename concat_error<CNS1, CNS2>::type; |
54 | 55 | // TODO: Optimize |
55 | 56 | struct expand_error_fn { |
56 | 57 | template<typename Constraint, typename... Info> |
57 | | - constexpr auto operator()(constraints_not_satisfied<Constraint, Info...> e) const noexcept { |
58 | | - return call(e, is_invocable<expand_error_fn, Constraint>{}); |
| 58 | + auto operator()(constraints_not_satisfied<Constraint, Info...> e) const noexcept { |
| 59 | + return call(e, preview::is_invocable<expand_error_fn, Constraint>{}); |
59 | 60 | } |
60 | 61 |
|
61 | 62 | // Ignore already expanded error |
62 | 63 | template<typename Constraint, std::size_t I, std::size_t N, typename... Why, typename... Rest> |
63 | | - constexpr auto operator()(constraints_not_satisfied<Constraint, at<I, N>, because<Why...>, Rest...> e) const noexcept { |
| 64 | + auto operator()(constraints_not_satisfied<Constraint, at<I, N>, because<Why...>, Rest...> e) const noexcept { |
64 | 65 | return e; |
65 | 66 | } |
66 | 67 | // This case doesn't exist yest |
67 | 68 | template<typename Constraint, typename... Why, typename... Rest> |
68 | | - constexpr auto operator()(constraints_not_satisfied<Constraint, because<Why...>, Rest...> e) const noexcept { |
| 69 | + auto operator()(constraints_not_satisfied<Constraint, because<Why...>, Rest...> e) const noexcept { |
69 | 70 | return e; |
70 | 71 | } |
71 | 72 |
|
72 | 73 | // direct-wrapper of type_traits (e.g., integral = is_integral_v) |
73 | | - template<typename Derived, typename Base, std::enable_if_t<conjunction< |
74 | | - derived_from_bool_constant<Base>, |
75 | | - negation<is_concept<Base>>, |
76 | | - negation<derived_from_template<Base, constraints_not_satisfied>> |
| 74 | + template<typename Derived, typename Base, std::enable_if_t<preview::conjunction< |
| 75 | + std::is_base_of<std::false_type, Derived>, |
| 76 | + preview::concepts::derived_from_bool_constant<Base>, |
| 77 | + preview::negation<preview::concepts::is_concept<Base>>, |
| 78 | + preview::negation<preview::concepts::derived_from_template<Base, constraints_not_satisfied>> |
77 | 79 | >::value, int> = 0> |
78 | | - constexpr auto operator()(concept_base<Derived, Base>) const noexcept { |
| 80 | + auto operator()(preview::concepts::concept_base<Derived, Base>) const noexcept { |
79 | 81 | // TODO: Simplify |
80 | 82 | return constraints_not_satisfied<Derived, at<0, 1>, because<Base, is_false>>{}; |
81 | 83 | } |
82 | 84 |
|
83 | 85 | private: |
84 | 86 | template<typename Error, typename... Info> |
85 | | - constexpr auto call(constraints_not_satisfied<Error, Info...>, std::true_type) const noexcept { |
| 87 | + auto call(constraints_not_satisfied<Error, Info...>, std::true_type) const noexcept { |
86 | 88 | auto e = (*this)(Error{}); |
87 | 89 | return constraints_not_satisfied<Error, Info..., because<decltype(e)>>{}; |
88 | 90 | } |
89 | 91 | template<typename Error, typename... Info> |
90 | | - constexpr auto call(constraints_not_satisfied<Error, Info...> e, std::false_type) const noexcept { |
| 92 | + auto call(constraints_not_satisfied<Error, Info...> e, std::false_type) const noexcept { |
91 | 93 | return e; |
92 | 94 | } |
93 | 95 | }; |
@@ -315,7 +317,6 @@ struct constraints_not_satisfied< |
315 | 317 | and_, C3, at<I3, N3>, because<Why3...>, |
316 | 318 | Rest... > : std::false_type {}; |
317 | 319 |
|
318 | | -} // namespace concepts |
319 | | -} // namespace preview |
| 320 | +PREVIEW_CONCEPT_LEXICAL_NAMESPACE_CLOSE |
320 | 321 |
|
321 | 322 | #endif // PREVIEW_CONCEPTS_V2_DETAIL_CONSTRAINTS_NOT_SATISFIED_H_ |
0 commit comments