Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

C++

Name: Anonymous 2009-01-18 9:04

for (list<T*>::iterator i = l.begin(); i != l.end(); i = l.erase(i))
    delete *i;


I R SMART

Name: Anonymous 2009-01-18 9:13

for is a great tool

Name: Anonymous 2009-01-18 9:22

; i = l.erase(i)

I like this.

Name: Anonymous 2009-01-18 9:26

Name: Anonymous 2009-01-18 9:39

There's an overload of erase that returns an iterator pointer?

Name: Anonymous 2009-01-18 9:48

>>5
Oh wow. Both overloads return iterator pointers of the next element. In which case, I present a challenger:

l.clear();

Name: Anonymous 2009-01-18 9:52

>>5
The erase() function either deletes the element at location loc, or deletes the elements between start and end (including start but not including end). The return value is the element after the last element erased.

Name: Anonymous 2009-01-18 10:02

If I'd have to store pointers in a list, I'd rather store smart pointers, or derive a list class like this:
class TList : public list<T*>
{
public:
    iterator erase(iterator loc)
    {
        delete *loc;
        return list<T*>::erase(loc);
    }
};

Also make your owns versions of clear, remove, erase with boundaries etc.

Name: Anonymous 2009-01-18 10:08

One word, garbage collection, thread over.

Name: Anonymous 2009-01-18 10:22

One word, smart pointers, thread resumed.

Name: Anonymous 2009-01-18 10:25

One word, cyclic references, thread over.

Name: Anonymous 2009-01-18 10:46

One word. C++ IS FOR FAGS. NO EXCEPTIONS THREAD OVER

Name: Anonymous 2009-01-18 11:51

One word, bump.

Also, smart pointers over garbage collection anytime.

Name: Anonymous 2009-01-18 11:54

Ah, for. The poor man's DO macro.

Name: Anonymous 2009-01-18 12:39

>>14
EXPLAIN

Name: Anonymous 2009-01-18 12:40

>>13
Fuck yes, I love boost, I love STL and bind and std::accumulate AND I FUCKING LOVE SHARED_PTR

Name: Anonymous 2009-01-18 16:03

>>16
WHY, BOOST HEATHEN?

Name: Anonymous 2009-01-18 16:15

STL is AIDS

Name: Anonymous 2009-01-18 16:36

>>18
I know, and I've raged at it more than once.
But I still kinda like it though, especially those wonderful containers, priority_queue fit this one problem in my gameserver perfectly.

Name: Anonymous 2009-01-18 20:52

>>15
It's similar to DO except shittier.

Name: Anonymous 2009-01-18 22:22

>>11
One word, cycle collectors, thread over.

Name: Trollbot9000 2009-07-01 11:08

this particular problem although 1 of the  text below 38.

Name: Anonymous 2009-07-01 17:23

>>16
shared_ptr is actually reference counting.
One word, cyclic references, real GCs wins.

Name: Anonymous 2009-07-02 0:16

THE FORCED IMPLEMENTATION OF REFERENCE COUNTING

Don't change these.
Name: Email:
Entire Thread Thread List