Thread View: comp.std.c++
1 messages
1 total messages
Started by bs
Mon, 05 Feb 1996 23:30
Re: Observations on templates
Author: bs
Date: Mon, 05 Feb 1996 23:30
Date: Mon, 05 Feb 1996 23:30
43 lines
2350 bytes
2350 bytes
Article 15951 of comp.std.c++: John Max Skaller <maxtal@suphys.physics.su.oz.au> writes > Eugene Radchenko wrote: > > Why don't use, for instance, cast_d instead od > > dynamic_cast (ugh). > > This is quite deliberate. Bjarne dislikes casts. So do I. > He didn't invent new style casts (and RTTI) for your convenience, > he invented them to make sure no one else did. Hmmm. That is a bit strong. I find casts of all sorts overused. There is almost always a better way to write code than one that involves an explicit type conversion. However, IMO some casts are essential. Some uses of dynamic_cast are examples of code that cannot be written conveniently without help from the language; see D&E for examples. Please remember that you don't always have source code available so that you can modify classes to avoid the need for RTTI,and even where it is available you sometimes prefer not to touch it to minimize maintainance. > Long names were deliberately chosen to discourage use of casts. That, to make emphasize the seriousness of the operation done with a cast, and to make sure that casts are relatively easy to find in a program (``to make casts stand out like a sore thumb''). One think I have come to dislike about C-style casts is that they are almost invisible in code. Since they don't look like much, people get fooled into thinking they don't do much. Also, (T)e is a shorthand for several logically different operations (type conversion, reinterpretation of a bitpattern, casting away const, class hierarchy navigation) and you need to know the type T, the type of e, and the rules of C++ rather well to know which. - Bjarne [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is summarized in http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads