trompeloeil icon indicating copy to clipboard operation
trompeloeil copied to clipboard

``trompeloeil_movable_mock`` only provides move-ctor

Open DNKpp opened this issue 1 year ago • 3 comments

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;

DNKpp avatar Apr 10 '24 20:04 DNKpp

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).

rollbear avatar Apr 16 '24 10:04 rollbear

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.

DNKpp avatar Apr 16 '24 11:04 DNKpp

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

rollbear avatar Apr 16 '24 11:04 rollbear