Liste des Groupes | Revenir à cl c |
Am 27.08.2024 um 11:32 schrieb David Brown:90% of statistics are plucked from the air, including that one.
On 27/08/2024 10:36, Bonita Montero wrote:C++ is efficient and abstract in one.Any simple one-line claim here is clearly going to be wrong.90% of the C++-abstractions are zero-cost abstractons.
What part of "or both" in my comment caused you such confusion?C++ code can be efficient, or abstract, or both, or neither.Of course it can. Imagine functional programming with a std::sort.
It's abstract since you won't have to deal with the details of the
sort and supply only a comparison function object, but it's still
optimally performant.
As I said, you have no idea what you are talking about in the context of low-level programming. People use C++ without exceptions on embedded systems, resource-constrained systems, high-reliability systems, and low-level code.You have to accept exceptions with C++ since there are a lot of places
where C++ throws a bad_alloc or system_error.Incorrect. Like most low-level or systems programmers using C++, I have exceptions disabled and never use them.You won't be able to change the runtime's behaviour with that. The
runtime trows bad_alloc or system_error everywhere and if you disable
exceptions the application simply terminates if this is thrown.
Again, you demonstrate your total ignorance of the topic.Incorrect.I just measured the tim of a ...
virtual int fn( int, int )
... which adds only two ints. The overhead is about one nanosecond
on my Zen4-CPU. And usually you do complex tasks inside the virtual
function so that the call itself doens't participate much in the
overall computation time.
The vast majority of processors produced and sold do not have any kind of branch prediction.Virtual function overhead will sometimes be worth the cost, and in some circumstances it can be less than more manual dispatch methods. But it is not cost-free, and the overhead can most certainly be relevant if it is used inappropriately.If the destination of the dispatch varies the overhead is nearly the
same as with static dispatch since most of the time takes the mispre-
dicted branch.
Les messages affichés proviennent d'usenet.