aboutsummaryrefslogtreecommitdiffstats
path: root/googlemock/include/gmock/gmock-matchers.h
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2020-01-31 12:03:06 -0500
committerAndy Getz <durandal@google.com>2020-02-07 13:34:42 -0500
commit572e261b607585d7044ad3321f9530d5c14a2564 (patch)
tree71908c4d9b8481ea9f6e6289e90b69aff820e2aa /googlemock/include/gmock/gmock-matchers.h
parent7bc671b8e0de264e58bb479535dc66f3be70ee4f (diff)
downloadgoogletest-572e261b607585d7044ad3321f9530d5c14a2564.tar.gz
googletest-572e261b607585d7044ad3321f9530d5c14a2564.tar.bz2
googletest-572e261b607585d7044ad3321f9530d5c14a2564.zip
Googletest export
Fix use of reserved names. Minimize code duplication needed for explict-vs-nonexplicit constructor. PiperOrigin-RevId: 292555014
Diffstat (limited to 'googlemock/include/gmock/gmock-matchers.h')
-rw-r--r--googlemock/include/gmock/gmock-matchers.h28
1 files changed, 9 insertions, 19 deletions
diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h
index 22211210..473b3aa8 100644
--- a/googlemock/include/gmock/gmock-matchers.h
+++ b/googlemock/include/gmock/gmock-matchers.h
@@ -462,28 +462,18 @@ class MatcherBaseImpl {
}
};
-// Template specialization for Matcher with 1 parameter.
-template <template <typename...> class Derived, typename T>
-class MatcherBaseImpl<Derived<T>> {
- public:
- explicit MatcherBaseImpl(T param) : param_(std::move(param)) {}
-
- template <typename F>
- operator ::testing::Matcher<F>() const { // NOLINT(runtime/explicit)
- return ::testing::Matcher<F>(
- new typename Derived<T>::template gmock_Impl<F>(param_));
- }
-
- private:
- const T param_;
-};
-
-// Template specialization for Matcher with multiple parameters.
+// Template specialization for Matcher with parameters.
template <template <typename...> class Derived, typename... Ts>
class MatcherBaseImpl<Derived<Ts...>> {
public:
- MatcherBaseImpl(Ts... params)
- : params_(std::move(params)...) {} // NOLINT(runtime/explicit)
+ // Mark the constructor explicit for single argument T to avoid implicit
+ // conversions.
+ template <typename E = std::enable_if<sizeof...(Ts) == 1>,
+ typename E::type* = nullptr>
+ explicit MatcherBaseImpl(Ts... params) : params_(std::move(params)...) {}
+ template <typename E = std::enable_if<sizeof...(Ts) != 1>,
+ typename = typename E::type>
+ MatcherBaseImpl(Ts... params) : params_(std::move(params)...) {} // NOLINT
template <typename F>
operator ::testing::Matcher<F>() const { // NOLINT(runtime/explicit)