Isn't "delete" so pesky to type? Wish there was a better way?

Started by
18 comments, last by Digitalfragment 9 years, 8 months ago
In C++, we know that memory management can be a large manual burden. Sometimes, though, it's just unavoidable, and we have to use new and delete.

A large part of the manual burden, of course, is actually typing delete, because it takes sooooo loooooong and is just annoying.


Thankfully, C++ has some special and little-known syntax to solve this headache! Suppose you have pointers (allocated via new, of course) named Foo, Bar, and Baz. All you need to do is this:

delete Foo, Bar, Baz;

Enjoy!

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Advertisement

You are such a troll.

And that's why I love you.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

if ( Washu == phil67rpg, fir, cthulu )
    this->eat(rope);
I'm honestly worried that some people might read that and not know that you're trolling.

If I ever see that in the wild, I'll know who to blame. smile.png

#define delete d rolleyes.gif

"The code you write when you learn a new language is shit.
You either already know that and you are wise, or you don’t realize it for many years and you are an idiot. Either way, your learning code is objectively shit." - L. Spiro

"This is called programming. The art of typing shit into an editor/IDE is not programming, it's basically data entry. The part that makes a programmer a programmer is their problem solving skills." - Serapth

"The 'friend' relationship in c++ is the tightest coupling you can give two objects. Friends can reach out and touch your privates." - frob

Memory leaks are a big problem with manual memory management.

So I propose this new syntax.


delete *;

BAM! No more worrying about leaks.

Anyone know how I can get in contact with the c++ standards committee?

Anyone know how I can get in contact with the c++ standards committee?


https://isocpp.org/

I look forward to reading your proposal paper for this game-changing feature.

Sean Middleditch – Game Systems Engineer – Join my team!


delete Foo, Bar, Baz;

Oh wow, is that the result of the 'batch-delete' proposal from the new C++14 standard? I didn't know it made it in the final release! happy.png

There's so many great features that made it into the latest C++, I haven't looked through them all.

[Edit:] After hearing about the potential speed gains, I made a quick performance test, and found that ApochPiQ's version runs almost three times faster than the old method! It must allow some additional compiler optimizations (probably using SSE4's deallocation parallelization) under the hood, since it's batch-deleting them.

I've already gotten started converting my code base over, and so far the results are very promising. Unfortunately, the latest Boost builds don't yet use it - someone really needs patch the major opensource libraries to take advantage of the new speedgains. mellow.png

I am disturbed by how legit this thread sounds.

I am disturbed by how legit this thread sounds.


No, it's quite legit. It saves two trips to the heap by sending in three addresses at a time, and heap operations are very expensive!

This topic is closed to new replies.

Advertisement