how static_cast and dynamic_cast implemented?

Discussion in 'C++' started by Yuming Ma, Dec 16, 2003.

  1. Yuming Ma

    Yuming Ma Guest

    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,
    Yuming Ma, Dec 16, 2003
    #1
    1. Advertising

  2. Yuming Ma

    Jeff Schwab Guest

    Yuming Ma wrote:

    > 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...
    Jeff Schwab, Dec 17, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dan Noland

    dynamic_cast and references

    Dan Noland, Jul 29, 2003, in forum: C++
    Replies:
    0
    Views:
    492
    Dan Noland
    Jul 29, 2003
  2. Andreas Sch.

    typeid and dynamic_cast, gcc 3.3

    Andreas Sch., Jan 23, 2004, in forum: C++
    Replies:
    18
    Views:
    1,878
    Janusz Szpilewski
    Jan 29, 2004
  3. GianGuz
    Replies:
    13
    Views:
    24,047
    Paavo Helde
    Dec 21, 2004
  4. Bo Peng
    Replies:
    11
    Views:
    1,085
    Victor Bazarov
    Oct 20, 2006
  5. junyangzou
    Replies:
    13
    Views:
    257
Loading...

Share This Page