diff --git a/docs/gmock_cheat_sheet.md b/docs/gmock_cheat_sheet.md index f2b5ab12..12e41044 100644 --- a/docs/gmock_cheat_sheet.md +++ b/docs/gmock_cheat_sheet.md @@ -400,6 +400,12 @@ messages, you can use: | `Property(property_name, &class::property, m)` | The same as the two-parameter version, but provides a better error message. +**Notes:** + +* 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 diff --git a/docs/gmock_cook_book.md b/docs/gmock_cook_book.md index 26a140eb..5e7cbfe3 100644 --- a/docs/gmock_cook_book.md +++ b/docs/gmock_cook_book.md @@ -1216,9 +1216,11 @@ For example: Note that in `Property(&Foo::baz, ...)`, method `baz()` must take no argument -and be declared as `const`. +and be declared as `const`. 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. -BTW, `Field()` and `Property()` can also match plain pointers to objects. For +`Field()` and `Property()` can also match plain pointers to objects. For instance, ```cpp