Modernize example of combining matchers. As of C++14 an ordinary function can have an `auto` return type. PiperOrigin-RevId: 826617761 Change-Id: I2ceecc8430643c0ac7843fb216b5a117cfe10ab3
diff --git a/docs/gmock_cook_book.md b/docs/gmock_cook_book.md index 9e59b4c..22ad021 100644 --- a/docs/gmock_cook_book.md +++ b/docs/gmock_cook_book.md
@@ -900,15 +900,16 @@ Matchers are function objects, and parametrized matchers can be composed just like any other function. However because their types can be long and rarely -provide meaningful information, it can be easier to express them with C++14 -generic lambdas to avoid specifying types. For example, +provide meaningful information, it can be easier to express them with template +parameters and `auto`. For example, ```cpp using ::testing::Contains; using ::testing::Property; -inline constexpr auto HasFoo = [](const auto& f) { - return Property("foo", &MyClass::foo, Contains(f)); +template <typename SubMatcher> +inline constexpr auto HasFoo(const SubMatcher& sub_matcher) { + return Property("foo", &MyClass::foo, Contains(sub_matcher)); }; ... EXPECT_THAT(x, HasFoo("blah"));