Suppose I have a 2D vector template class:
template<typename T> class Vec2 { T x, y;
I would expect the result of the sum between a Vec2<double> and a Vec2<int> be Vec2<double> , but C ++ will not do this by default.
Am I thinking wrong?
Should I try to implement this behavior?
And how do I implement this? One way may be overridden by any operator, so that the advanced type of computed using the auto and decltype or do it yourself, for example, to promote , but this way - it is anything but trivial and not even let me use boost.operators to facilitate my work . Other offers?
source share