eranpeer / FakeIt

C++ mocking made easy. A simple yet very expressive, headers only library for c++ mocking.
MIT License
1.22k stars 170 forks source link

Add back support for explicit template for *Return(obj). #337

Open FranckRJ opened 1 month ago

FranckRJ commented 1 month ago

The syntax .Return<type>(obj) to force the object to be copied and .Return<type&>(obj) to force the object to be captured by reference have been removed by #330 be caused it caused issues with the new implementation of .Return(obj), and because it was not a real documented feature (but more a by-product of the implementation), I supposed no one was relying on it.

It turns out that some people use this feature (see https://github.com/eranpeer/FakeIt/issues/200#issuecomment-972461734 and https://github.com/eranpeer/FakeIt/pull/336#issuecomment-2108062764), not only to change the behavior of .Return(obj), but also to have a consistent behavior, i.e. having .Return(obj) do the same thing regardless of if the mocked function return a reference or an object.

What should be done: