I think with C ++ 11 and its rvalue references you can implement the requested single line string. It reads as follows:
template<class T> T& make_dummy_out(T&& t) { return t; }
Then you can call the Limit function as follows:
double min; Limits(min, make_dummy_out(double()));
This is safe, because the lifetime of the created ad-hoc double() will be until the end of the statement, that is, after the Limits() call is completed.
Note that make_dummy_out() is basically the opposite of std::move() : while std::move() explicitly turns the lvalue link into an rvalue link, make_dummy_out() converts the rvalue link explicitly into an lvalue link. Of course, you need to declare the template function only once, and then use it to create dummy output parameters where you need it.
source share