2 Comments
User's avatar
Yacob Cohen-Arazi's avatar

It's a good point and unfortunately very little known feature. Meyers book also talks about it. BTW, you could overload build() with & and &&. i.e. qualify & and && at the end of the decl. so && will be used with an rvalue and & will be used with an lvalue. I think in the case above we might need to std::forward since inside the function, holder is lvalue.

Expand full comment
Taras Tsugrii's avatar

yep, but I absolutely love it. It gives a little bit of lifetime management normally enjoyed by Rust developers to us.

Expand full comment