Imagine I have this function template:
template<auto& ... FLAGS>
void function(const char *c_str) {
std::stringstream strs;
//((strs << FLAGS)...); // <-- how do I do this?
strs << c_str;
.
.
.
}
Consider that the function template is going to be used like this:
function<std::dec, std::left>("123");
how to apply the operator <<
on each parameter from the parameter pack (with the object strs
)?
I have already found a workaround with introducing a helper function:
void unpack(const auto& ...){};
And in the original function template:
unpack((strs << FLAGS)...);
But I was wondering if there is a better way to this!