Liste des Groupes | Revenir à cl c |
Am 28.08.2024 um 15:52 schrieb Thiago Adams:Suppose you take the source code for CPython, and suppose that comprises 500K lines of C source. (It was half that a decade ago so it is feasible.)
You have to deallocate only if the ownership still with the same object.If the compiler sees that it is moved the whole deallocation
This is not the case when the object is moved.
is usually opimized away for the non-exception code path.
To create view object you need a new object because destructor cannot be disabled.It's optimized away for the non-exception code-path if the compiler
sees it.
Const-objects are there not to be modified. If you've got logical
constness you can cast away the const with const_cast and move its
contents. But casting away const is unclean mostly in C and C++.excuses..In C yoU'd have to do the same. And there's only one type of cast
and you could mistakenly cast to a non-fitting type whereas in C++
you've got const_cast<> which may only differ in const-ness.
It was create latter after people realize std::string was bad.The same for std::array etc... almost everything is a fix in C++.Array is there to have iterator-debugging on sth. that looks like
a C-array. With C-arrays there's no such feature and it's harder
to find according bugs. If I use static const C-style arrays which
are directed to the DATA-ssegment I always use a span<> on it to
have iterator-debugging, whereas in C you have to take a lot of
care.
(I don't blame people creating C++ in the past, but I think now we have information sufficient to do better choices and this choices are not begin made).C is five to ten times more code for the same task.
Les messages affichés proviennent d'usenet.