6#ifndef MIMICPP_MATCHERS_COMMON_HPP
7#define MIMICPP_MATCHERS_COMMON_HPP
16#ifndef MIMICPP_DETAIL_IS_MODULE
19 #include <type_traits>
24 template <
typename Matcher>
28namespace mimicpp::detail::matches_hook
30 template <
typename Matcher,
typename T,
typename... Others>
32 constexpr bool matches_impl(
34 Matcher
const& matcher,
41 return custom::matcher_traits<Matcher>{}.matches(matcher, target, others...);
44 template <
typename Matcher,
typename T,
typename... Others>
46 constexpr bool matches_impl(
47 [[maybe_unused]] util::priority_tag<0>
const,
48 Matcher
const& matcher,
52 { matcher.matches(target, others...) } -> util::boolean_testable;
55 return matcher.matches(target, others...);
58 inline constexpr util::priority_tag<1> maxTag{};
62 template <
typename Matcher,
typename T,
typename... Others>
64 constexpr bool operator()(Matcher
const& matcher, T& target, Others&... others)
const
66 { matches_impl(maxTag, matcher, target, others...) } -> util::boolean_testable;
69 return matches_impl(maxTag, matcher, target, others...);
73 inline constexpr matches_fn matches{};
76namespace mimicpp::detail::describe_hook
79 template <
typename Matcher>
81 constexpr auto describe_impl([[maybe_unused]] util::priority_tag<1>
const, Matcher
const& matcher)
82 ->
decltype(custom::matcher_traits<Matcher>{}.describe(matcher))
85 custom::matcher_traits<Matcher>{}.describe(matcher)
86 } -> util::explicitly_convertible_to<std::optional<StringT>>;
89 return custom::matcher_traits<Matcher>{}.describe(matcher);
92 template <
typename Matcher>
94 constexpr auto describe_impl([[maybe_unused]] util::priority_tag<0>
const, Matcher
const& matcher)
95 ->
decltype(matcher.describe())
97 { matcher.describe() } -> util::explicitly_convertible_to<std::optional<StringT>>;
100 return matcher.describe();
103 inline constexpr util::priority_tag<1> maxTag{};
107 template <
typename Matcher>
109 constexpr auto operator()(Matcher
const& matcher)
const
110 ->
decltype(describe_impl(maxTag, matcher))
112 { describe_impl(maxTag, matcher) } -> util::explicitly_convertible_to<std::optional<StringT>>;
115 return describe_impl(maxTag, matcher);
119 inline constexpr describe_fn describe{};
131 template <
typename Matcher,
typename... Args>
132 struct is_matcher_accepting
133 :
public std::true_type
137 template <
template <
typename...>
typename is_accepting,
typename... Args>
138 struct is_matcher_accepting_helper
139 :
public is_accepting<Args...>
148 template <
typename Matcher,
typename... Args>
149 requires requires {
typename is_matcher_accepting_helper<Matcher::template is_accepting, Args...>; }
150 struct is_matcher_accepting<Matcher, Args...>
151 :
public is_matcher_accepting_helper<Matcher::template is_accepting, Args...>
166 template <
typename Matcher,
typename... Args>
172 template <
typename T,
typename First,
typename... Others>
174 && std::is_move_constructible_v<T>
175 && std::destructible<T>
177 &&
requires(T
const& matcher, First& first, Others&... others) {
#define MIMICPP_DETAIL_MODULE_EXPORT
Definition Config.hpp:19
Definition Common.hpp:173
Determines, whether B behaves as a the builtin type bool.
Definition Concepts.hpp:66
Determines, whether From can be explicitly converted to To.
Definition Concepts.hpp:34
constexpr bool is_matcher_accepting_v
Determines, whether the given Matcher accepts the specified Args.
Definition Common.hpp:167
Definition PriorityTag.hpp:24