diff --git a/docs/reference/matchers.md b/docs/reference/matchers.md index 243e3f95..16397ef2 100644 --- a/docs/reference/matchers.md +++ b/docs/reference/matchers.md @@ -171,6 +171,11 @@ messages, you can use: | `Property(&class::property, m)` | `argument.property()` (or `argument->property()` when `argument` is a plain pointer) matches matcher `m`, where `argument` is an object of type _class_. The method `property()` must take no argument and be declared as `const`. | | `Property(property_name, &class::property, m)` | The same as the two-parameter version, but provides a better error message. +{: .callout .warning} +Warning: Don't use `Property()` against member functions that you do not own, +because taking addresses of functions is fragile and generally not part of the +contract of the function. + **Notes:** * You can use `FieldsAre()` to match any type that supports structured @@ -189,10 +194,6 @@ messages, you can use: EXPECT_THAT(s, FieldsAre(42, "aloha")); ``` -* Don't use `Property()` against member functions that you do not own, because - taking addresses of functions is fragile and generally not part of the - contract of the function. - ## Matching the Result of a Function, Functor, or Callback | Matcher | Description | diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index e979544c..e5ee543f 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -4453,6 +4453,10 @@ inline PolymorphicMatcher> Field( // matches 'matcher'. For example, // Property(&Foo::str, StartsWith("hi")) // matches a Foo object x if and only if x.str() starts with "hi". +// +// Warning: Don't use `Property()` against member functions that you do not +// own, because taking addresses of functions is fragile and generally not part +// of the contract of the function. template inline PolymorphicMatcher>