I have a function f
which will be called hundreds of millions of times, and I was wondering is there any runtime performance difference between:
void f()
{
int a = ...;
size_t b = static_cast<size_t>(a);
}
and
void f()
{
int a = ...;
size_t b = a;
}
I heard somwhere that static_cast
has to create a temp variable, which means it has a small cost.
I was wondering if implicit casting has the same performance impact.
Or, is static_cast
the same as reinterpret_cast
where it has 0 extra instructions?