Little problem with STL

hi,

I’m playing with SDL, and I’ve a little problem with STD :slight_smile:

I’m using a vector, and when I push back, there’s no problem, but when I
want to push_front, the compiler said me : “no matching function for call
to…”.

Anyone has an idea?

thanx

shimrod wrote:

I’m using a vector, and when I push back, there’s no problem, but
when I want to push_front, the compiler said me : “no matching
function for call to…”.

This is nothing to do with the SDL libraries, so you’re asking in the
wrong place.

The answer is that std::vectors simply don’t have a push_front function
as it would be inefficient. If you need to insert at the front, use the
insert() member (and pay the efficiency penalty) or consider using an
std::deque or std::list.

Visit http://www.sgi.com/tech/stl/ for STL documentation.
And go to http://www.gamedev.net/community/forums (for example) to ask
questions like these.–
Kylotan
http://pages.eidosnet.co.uk/kylotan

I’m playing with SDL, and I’ve a little problem with STD :slight_smile:

There are antibiotics to clear that sort of thing up, but you should
tell Ms. SDL that she should get checked by a doctor, too, in case she’s
the cause of your STD problem.

(Sorry, I couldn’t resist. What I meant to say was, “STL problems are off
topic for this list.”)

–ryan.

std::vector does not have a push_front method. In fact, such a method
probably wouldn’t be a good idea for a std::vector.

Perhaps you should give std::list a try.

Determining which STL object to use for a given problem can be fun. ;>
I’d recommend reading Scott Meyer’s “Effective STL” before doing any
serious STL programming.

Browsing comp.lang.c++ probably wouldn’t be a bad idea either (and
definitely a much better place to post STL related questions).

Finally, if you need a quick STL reference, check out these two sites:

http://www.sgi.com/tech/stl/
http://www.cppreference.com/

nathanOn Mon, 2003-06-09 at 15:31, shimrod wrote:

hi,

I’m playing with SDL, and I’ve a little problem with STD :slight_smile:

I’m using a vector, and when I push back, there’s no problem, but when I
want to push_front, the compiler said me : “no matching function for call
to…”.

Anyone has an idea?

thanx


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl