c++ style casts vs c style

c++ style casts vs c style

Post by Michael Campbe » Fri, 23 Feb 1996 04:00:00



I'm interested in c++ style casts; is there a canonical list which shows which
compilers allow this?

--


      [  Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm  ]
      [  Moderation policy: http://www.connobj.com/cpp/guide.htm  ]

 
 
 

1. Casting C-Style versus C++ cast functions

Should the use of the C++ casting functions be mandated over the use of
C-style casting in all situations?

I understand the need for dynamic_cast and when it should be used, I think
it's great and it offers considerable value.  I know when to use
reinterpret_cast for function pointers.  I also understand that I can use
the C-Style casting form for converting native data types and enumerations
(being careful to note any truncation, etc.)

However, I am struggling with const_cast and static_cast.  The context would
be an application where I'm forced to live with a signature that is
essentially wrong in declaring an argument as const when it should not have
been.  Is it "evil" for me to use the C-style casting?  I know I can use the
C++ casting functions, but I guess it seems a bother.  I've read that
cloning the object would be a workaround, but this just seems like overkill
in my situation.

My perspective on this situation and that of using static_cast, is that the
compiler essentially does some checking at compile time, but at run-time it
just moves the value of the pointer anyway, it doesn't seem to do any
validation.  I know I'd be losing this up-front checking.  If I (and the
team) know what we're doing and can be trusted (I know, I know,...); is it
so wrong to use C-Style casting in a case like I've described.

thanks for your help and opinions!


      [ about comp.lang.c++.moderated. First time posters: do this! ]

2. printer cartridges for Tandy DMP-430

3. Newbie problem with include files (old style vs new style)

4. HELP SQL Loader

5. value style vs. storage style

6. HP to Buy Compaq?

7. static_cast vs. C-style cast

8. I was afraid this was gonna happen someday.

9. static_cast vs C-style casting

10. C-style cast vs. static_cast

11. How does C++ interpret c-style casting?

12. Casting style in C++ ?

13. function style casts in C++