[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C++ / multiple instances / iostreams
From: |
Detlef Vollmann |
Subject: |
Re: C++ / multiple instances / iostreams |
Date: |
Thu, 22 Jul 2004 00:22:23 +0200 |
Hans Aberg wrote:
> I believe that the design criterion that BS expressed was that C++ should
> admit efficient implementations, but by no means as optimized as in C. Sed
> the book DEC++ ("Design and Evolution of C++").
No, Bjarne probably never said or wrote such. He was one of the main
proposers of the C++ Performance Report
http://www.open-std.org/jtc1/sc22/open/n3646.pdf
(I worked together with him on some parts of that report.)
There are actually cases where C++ is more efficient as C.
SCNR.
> class semantic_type {
> public:
> long number_;
> std::string text_;
> my::object object_;
>
> semantic_type() : number_(0) {}
> };
> #define YYSTYPE semantic_type
> will suffice as semantic type. One converts data using either
> dynamic_cast<T*>, in which case null pointer must be checked, or
> dynamic_cast<T&>, in which case null pointers case an exception to be
> thrown.
I don't really see how you use this, but for dynamic_cast to work the
classes must be related: the only casts that are allowed with
dynamic casts are
- downcasts
- crosscasts
- upcasts
- identity casts
(The latter two usually make no sense as dynamic_casts, but can happen
in generic code.)
Some compilers allow (and check) dynamic_casts between pointers to
unrelated classes, some even allow dynamic_cast<T *>(void *), but thats
completely implementation defined.
And (as you can also read in the Performance Report) dynamic_casts
are notorically slow in most implementations.
Detlef
--
Detlef Vollmann vollmann engineering gmbh
Linux and C++ for Embedded Systems http://www.vollmann.ch/
- Re: C++ / multiple instances / iostreams, (continued)
- Re: C++ / multiple instances / iostreams, Laurence Finston, 2004/07/18
- Re: C++ / multiple instances / iostreams, Hans Aberg, 2004/07/18
- Re: C++ / multiple instances / iostreams, Oliver Kowalke, 2004/07/18
- Re: C++ / multiple instances / iostreams, Hans Aberg, 2004/07/19
- Re: C++ / multiple instances / iostreams, Laurence Finston, 2004/07/19
- Re: C++ / multiple instances / iostreams, Hans Aberg, 2004/07/20
- Re: C++ / multiple instances / iostreams, Laurence Finston, 2004/07/20
- Message not available
- Re: C++ / multiple instances / iostreams, Hans Aberg, 2004/07/21
- Re: C++ / multiple instances / iostreams, Laurence Finston, 2004/07/21
- Re: C++ / multiple instances / iostreams, Hans Aberg, 2004/07/22
- Re: C++ / multiple instances / iostreams,
Detlef Vollmann <=
- Re: C++ / multiple instances / iostreams, Hans Aberg, 2004/07/22
- Re: C++ / multiple instances / iostreams, Detlef Vollmann, 2004/07/23
- Re: C++ / multiple instances / iostreams, Hans Aberg, 2004/07/23
- Re: C++ / multiple instances / iostreams, Detlef Vollmann, 2004/07/24
- Re: C++ / multiple instances / iostreams, Hans Aberg, 2004/07/24
- Re: C++ / multiple instances / iostreams, Detlef Vollmann, 2004/07/24
- Re: C++ / multiple instances / iostreams, Hans Aberg, 2004/07/24
- Re: C++ / multiple instances / iostreams, Detlef Vollmann, 2004/07/24
- Re: C++ / multiple instances / iostreams, Hans Aberg, 2004/07/25
- Re: C++ / multiple instances / iostreams, Detlef Vollmann, 2004/07/25