A template for declaring function's output parameters
This small class template out_param
can be used to indicate in the function's signature that a given reference parameter is an output parameter:
using namespace ak_toolkit;
void assign(out_param<std::string&> s, // < output parameter
std::string const& v)
{
s.get() = v;
}
It does not do any processing. The only benefit of using it is that you cannot pass a reference to a function unless you explicitly wrap it:
std::string s;
assign(out(s), "text");
This forces the function callers to be explicit about passing output arguments to it.
Before using this library for output parameters consider not using output parameters at all, as described in C++ Core Guidelines F.20 and F.21. Only if this is impossible resort to using this library to make the usage of output parameters explicit in the call site.
It is a C++11 single-header (header-only) library.
Distributed under the Boost Software License, Version 1.0.