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. Advertisements

  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. Advertisements

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:
    627
    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:
    2,133
    Janusz Szpilewski
    Jan 29, 2004
  3. exits funnel
    Replies:
    2
    Views:
    670
    exits funnel
    Feb 25, 2004
  4. Busin
    Replies:
    2
    Views:
    1,005
    Andrey Tarasevich
    Jun 28, 2004
  5. GianGuz
    Replies:
    13
    Views:
    24,521
    Paavo Helde
    Dec 21, 2004
  6. Replies:
    10
    Views:
    779
    Tobias Blomkvist
    Jul 26, 2005
  7. Bo Peng
    Replies:
    11
    Views:
    1,326
    Victor Bazarov
    Oct 20, 2006
  8. junyangzou
    Replies:
    13
    Views:
    479
Loading...