From 5c9367d4f1796c3a4a6d4eb74bea3a0b87f23590 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Fri, 27 Mar 2020 10:57:09 +0100 Subject: [PATCH] Small cleanup for PredicateMatcher Removed the `generic` nested namespace, so PredicateMatcher now lives in `Catch::Matchers` namespace, just like other matchers. Also cleaned up and doxygenized comments on the `Predicate` factory function for `PredicateMatcher`. --- .../matchers/catch_matchers_predicate.cpp | 2 +- .../matchers/catch_matchers_predicate.hpp | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/catch2/matchers/catch_matchers_predicate.cpp b/src/catch2/matchers/catch_matchers_predicate.cpp index be6f808f..fce37373 100644 --- a/src/catch2/matchers/catch_matchers_predicate.cpp +++ b/src/catch2/matchers/catch_matchers_predicate.cpp @@ -1,6 +1,6 @@ #include -std::string Catch::Matchers::Generic::Detail::finalizeDescription(const std::string& desc) { +std::string Catch::Matchers::Detail::finalizeDescription(const std::string& desc) { if (desc.empty()) { return "matches undescribed predicate"; } else { diff --git a/src/catch2/matchers/catch_matchers_predicate.hpp b/src/catch2/matchers/catch_matchers_predicate.hpp index dcdff771..e589d8be 100644 --- a/src/catch2/matchers/catch_matchers_predicate.hpp +++ b/src/catch2/matchers/catch_matchers_predicate.hpp @@ -16,11 +16,10 @@ namespace Catch { namespace Matchers { -namespace Generic { namespace Detail { std::string finalizeDescription(const std::string& desc); -} +} // namespace Detail template class PredicateMatcher final : public MatcherBase { @@ -42,17 +41,16 @@ public: } }; -} // namespace Generic - - // The following functions create the actual matcher objects. - // The user has to explicitly specify type to the function, because - // inferring std::function is hard (but possible) and - // requires a lot of TMP. + /** + * Creates a matcher that calls delegates `match` to the provided predicate. + * + * The user has to explicitly specify the argument type to the matcher + */ template - Generic::PredicateMatcher Predicate(Pred&& predicate, std::string const& description = "") { + PredicateMatcher Predicate(Pred&& predicate, std::string const& description = "") { static_assert(is_callable::value, "Predicate not callable with argument T"); static_assert(std::is_same>::value, "Predicate does not return bool"); - return Generic::PredicateMatcher(std::forward(predicate), description); + return PredicateMatcher(std::forward(predicate), description); } } // namespace Matchers