|Implementation of static_cast<> email@example.com (2002-01-14)|
|Re: Implementation of static_cast<> firstname.lastname@example.org (Alain Miniussi) (2002-01-17)|
|Re: Implementation of static_cast<> email@example.com (2002-01-17)|
|From:||Alain Miniussi <firstname.lastname@example.org>|
|Date:||17 Jan 2002 00:29:27 -0500|
|Posted-Date:||17 Jan 2002 00:29:27 EST|
> Im curious to know the implementation of static_cast<> by the C++ compiler.
> Since it is a better version than "C" style casts...
> I assume something like:
> 1) try to get the type of the non-polymorphic object. something like "typeid()"
> 2) try to match the given pointer/type to the type of the template parameter
> 3) If success return after casting ( "C" style ? ) else return null.
That's dynamic_cast<> (applied to pointers).
static_cast<>, when it can be used, works like the C cast, the compiler just
check for some constraints on the types at compile time.
You can take a look at any C++ book for more details.
Return to the
Search the comp.compilers archives again.