while(model.condition) {
auto data = yield_data();
auto _= manipulate(model, data);
model.get_info(args);
}
I have an RAII object of type manipulate
, whose destructor undoes the mutation it causes when it falls out of scope, much like std::lock_guard
. The problem is that the user has to type auto _=
or the destructor will get called before model.get_info()
; I don't like that the user has to type auto _=
. Why would a user think to create an object that is never used?
My first idea was to make the constructor [[nodiscard]]
; but constructors have no return values. Is there a way to tell the compiler that manipulate rvalues should have lvalue lifetimes?