I was wondering whether … was considered an operator in C++11. And if it’s the case, what’s its precedence?
For instance consider this pretty bad example and assume ... is an operator.
template<typename T, typename...Args>
void foo(T _elm, Args... _args)
{
bar(something,_args...);
}
How can I know whether bar
will be run with its first parameter being something
and args...
expanded, or if its gonna be run on the result of operator,(something, _args...)
? (bonus question: can operators be overloaded with variadic templates ?)
I was wondering whether … was considered an operator in C++11
No, ...
is definitely not considered an operator in C++ 11. If you remember, it was also used in the previous standard in error handling
catch(...)
and though I am not sure how the ...
is analysed and parsed internally, it is definitely not treated as an operator.
Can operators be overloaded with variadic templates ?
I'm not sure, but I don't think so. Operators have to take a specified set of parameters like:
int operator + (int param1, my_obj param2);
I don't think it would work with variadic templates.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With