Quote:Original post by AndiDog
Sounds quite logical :) but why should I use C++ std::list if I am too stupid to code my own *simple* list template class?
Well, if you can't get it right yourself, and you don't use the standard version, what are you going to use instead? You need *something*... :)
And if you *can* get it right yourself... why spend the time on it when there's something provided for you that (a) is as efficient as it realistically can be for what it does and (b) is - well - *provided for you*? :) (Obviously, the standards committee can't write your program for you; but certain concepts - like storing a sequence of objects of the same type in a "container" - are so common that they put together robust yet low-overhead solutions for those problems.)
Of course, you do still get to use your brain here - to choose between std::list, std::vector and std::deque. They implement different strategies for holding a sequence of items, because none is best for all situations (and there isn't really a good way to take the best of each, either - you pretty much have to choose each time).
Note that if you got the idea to make your own list on account of some formal CS education, that - well, CS education generally sucks in that regard :) Profs love to teach linked lists, but people could graduate from these programs not even knowing there are other ways (i.e. the strategies implemented by std::vector and std::deque), because they aren't encouraged to *think* about such things. Certainly they don't teach them directly - no, lists are just too "elegant" to bother with anything else :S