I overload an operator twice with the same parameter list. but with different return type:
T& operator()(par_list){blablabla}
const T& operator()(par
You can't overload a function/method based on return type. I would expect the compiler to throw an error here. What you can do is specify the method itself as a const
method, using
const T& operator()(par_list) const {blahblah}
The const
qualifier not only means this can be called on a const
receiver, but it also is used in the overload resolution. This happens because it affects the implicit *this
parameter that's passed to the method; a const
method uses a const
qualifier on *this
, and const
qualifiers are taken into account during overload resolution.