As I'm implenting templated classes for small math vectors, I encounter one problem.
For the arithmetic operations, the return type of T1 lhs + T2 rhs
is std::common_type<T1, T2>::type.
But what is the return type for the following (for example T1 signed and T2 unsigned or the contrary, or T1 char and T2 unsigned long long int etc...) :
T1 lhs & T2 rhs ?
T1 lhs | T2 rhs ?
T1 lhs ^ T2 rhs ?
T1 lhs << T2 rhs ?
T1 lhs >> T2 rhs ?
Thank you very much.
I assume you are going to implement a compoment-wise bitwise operations on vectors. Essentially bitwise operations are integer operations and i see no reason why not to make their result as std::common_type<T1, T2>::type
.
The result of shifts does not depend on the right operand. Just use T1 for it.
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