3 ms·
Tip: insert manual newlines into verbatim/code blocks to make them more readable: Some people might ask why I chose to make the parameter of BlackBox::stor
by frankzinger 11y ago
Tip: insert manual newlines into verbatim/code blocks to make them more readable:
Some people might ask why I chose to make
the parameter of BlackBox::store an rvalue
reference rather than an lvalue reference
and force the client code to use std::move.
While it is true that an lvalue reference
would also have worked, if I did that, it
would be impossible to write code like
crate.store(std::make_unique<Gadget>(beeper, flasher));.
I also happen to think that forcing the client to use
std::move at the call sites is good rather than bad,
because it communicates the intended effect to the reader.