rollbear / trompeloeil

Header only C++14 mocking framework
Boost Software License 1.0
802 stars 85 forks source link

``trompeloeil_movable_mock`` only provides move-ctor #332

Open DNKpp opened 5 months ago

DNKpp commented 5 months ago

Trompeloeil's mocks should be movable, when the bool member trompeloeil_movable_mock is set to true. But currently it is limited to move-construction; move-assignment is not supported. Is there a reason for this? Or is it just a bug? A simple fix would be just the line: expectations& operator =(expectations&&) = default; in the struct expectations definition.

Btw, as a side-note: it's never a good idea to explicitly specify noexcept on defaulted functions, as this is can and will be overriden by compilers. => expectations(expectations&&) noexcept = default;

rollbear commented 4 months ago

Is this a question from a philosophical point of view, or do you have a real world use case?

The latter seems to be a mistake (unless it was added as a work-around for some old compiler, I don't remember). I'll remove it (possibly conditionally depending on compiler).

DNKpp commented 4 months ago

Well, I often stumble across this. I sometimes simply want to setup expectations on a mock and then move it somewhere and do not care, whether it's moved somewhere else or not. The most annoying fact is, that mock types can not be used as template types, where std::movable (or any depending concept) is required.

rollbear commented 4 months ago

OK. Thanks. I'll look into it. I'm somewhat afraid that it'll open a can of worms, but I understand your situation.