E
esuvs81
Hi all. In short, is there any performance difference between:
float f = 10.0f;
int i = static_cast<int>(f);
and
float f = 10.0f;
int i = int(f);
I've been meaning to ask this for a while but just how fast is
static_cast? I had always assumed (without proof) that static_cast is
implemented as a template which just wraps a C/C++ style cast.But then
it the Josuttis book it says:
"The conversion is allowed only if a type conversion is defined"
Presumably then this test is done at compile time?
Also, if static_cast is just a wrapper around C/C++ casts then how does
it differ from reinterpret_cast? Maybe these things are compiler
dependant but any info is useful.
Thanks,
David
float f = 10.0f;
int i = static_cast<int>(f);
and
float f = 10.0f;
int i = int(f);
I've been meaning to ask this for a while but just how fast is
static_cast? I had always assumed (without proof) that static_cast is
implemented as a template which just wraps a C/C++ style cast.But then
it the Josuttis book it says:
"The conversion is allowed only if a type conversion is defined"
Presumably then this test is done at compile time?
Also, if static_cast is just a wrapper around C/C++ casts then how does
it differ from reinterpret_cast? Maybe these things are compiler
dependant but any info is useful.
Thanks,
David