
On Sun, May 25, 2025 at 11:10 PM Jean-Louis Leroy via Boost < boost@lists.boost.org> wrote:
As I often use GMock I would prefer same pattern here, return type, name, args this is example from GMock docs(ignore override): MOCK_METHOD(void, Forward, (int distance), (override));
Same as YOMM2:
declare_method(void, poke, (virtual_<Animal&>, std::ostream&));
define_method(void, poke, (Dog& dog, std::ostream& os)) { os << "bark"; }
So why did I change it to this?
BOOST_OPENMETHOD(poke, (virtual_ptr<Animal>, std::ostream&), void);
BOOST_OPENMETHOD_OVERRIDE( poke, (virtual_ptr<Dog> dog, std::ostream& os), void) { os << "bark"; }
That's because the YOMM2 syntax does not work well with return types that contain commas, like `std::tuple<int, float>`, forcing you to use tricks like typedefs or `BOOST_IDENTITY_TYPE`. The new syntax requires that the method name be an identifier, so we know for sure that the first macro argument is the entire thing, not a bit of it (e.g., not `std::tuple<int`). The second is wrapped in parentheses.
This is actually strong argument, comma thing is quite obnoxious with GMock, not to mention that last time I hit it compiler error message was useless. So you have convinced me. :)
It is a valid function type, as in `std::function<int(char, float)>`
I meant when you declare function in C++ you can do: auto my_sum(int, int) -> int int my_sum(int, int) but you can not do: my_sum int(int, int)