So, I wrote something like this
#include <iostream>
using namespace std;
void f(int32_t i)
{
cout << "int32: " << i << endl;
}
void f(int16_t i)
{
cout << "int16: " << i << endl;
}
void f(int8_t i)
{
cout << "int8: " << i << endl;
}
void f(uint32_t i)
{
cout << "uint32: " << i << endl;
}
void f(uint16_t i)
{
cout << "uint16: " << i << endl;
}
int main() {
uint8_t i = 0u;
f(i);
return 0;
}
And it printed
int32: 0
I'm a bit confused:
-
Is this well-defined behaviour, or is it implementation specific?
-
What are the rules that determine which overload is used here and to what type the variable is converted?
Aucun commentaire:
Enregistrer un commentaire