I was writing some code in C++ with templates, and there was a parameter like uint16_t >> uint16_t
, but the compiler deduced T = int
.
There is also an example:
#include <cstdint>
template<class Type> struct S;
void foo() {
S<decltype(uint16_t(1) >> uint16_t(1))>();
}
Where the compiler (x86-64 gcc 10.3) gave
<source>: In function 'void foo()':
<source>:4:45: error: invalid use of incomplete type 'struct S<int>'
4 | S<decltype(uint16_t(1) >> uint16_t(1))>();
|
But why is uint16_t(1) >> uint16_t(1)
an int
?
(I learnt this method of getting the type in this post)