Skip to content

Commit

Permalink
refactor: make WildcardMatcher a standalone class
Browse files Browse the repository at this point in the history
  • Loading branch information
DNKpp committed Apr 29, 2024
1 parent d194b85 commit 30b1c7a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
24 changes: 18 additions & 6 deletions include/mimic++/Matcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,22 @@ namespace mimicpp
};
}
};

class WildcardMatcher
{
public:
static constexpr bool matches(auto&& target) noexcept
{
return true;
}

static constexpr StringT describe(auto&& target)
{
return format::format(
"{} without constraints",
mimicpp::print(target));
}
};
}

namespace mimicpp::matches
Expand All @@ -140,15 +156,11 @@ namespace mimicpp::matches
*
*\{
*/

/**
* \brief The wildcard matcher, always matching.
*/
inline static const PredicateMatcher _{
AlwaysTruePredicate{},
"{} without constraints",
std::tuple{}
};
inline constexpr WildcardMatcher _{};

/**
* \brief Tests, whether the target compares equal to the expected value.
Expand Down
10 changes: 0 additions & 10 deletions include/mimic++/Utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,6 @@ namespace mimicpp
{
};

class AlwaysTruePredicate
{
public:
[[nodiscard]]
constexpr bool operator ()([[maybe_unused]] auto&&...) const noexcept
{
return true;
}
};

[[nodiscard]]
constexpr bool is_same_source_location(
const std::source_location& lhs,
Expand Down

0 comments on commit 30b1c7a

Please sign in to comment.