how static_cast and dynamic_cast implemented?

Y

Yuming Ma

all,

curious what's the implementation and compiling details of these two and
other C++ cast operators such as const_cast and reinterpret_cast...they
look like templated class with constructor checking the typeid of the
input object and return the target object...

thanks,

yuming,
 
J

Jeff Schwab

Yuming said:
curious what's the implementation and compiling details of these two and
other C++ cast operators such as const_cast and reinterpret_cast...they
look like templated class with constructor checking the typeid of the
input object and return the target object...

No, they're done at compile-time, not run-time. Since they're built
into the language, they're not actually templated classes. However, I
wouldn't think they'd be hard to implement as function templates with
constraints. I wonder, why weren't they made library elements? Hm...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top