Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reason for not using the STL? [duplicate]

Tags:

c++

stl

Possible Duplicate:
To STL or !STL, that is the question

Are there cases where one should avoid the use of the C++ STL in his / her project?

like image 712
Woops Avatar asked Feb 03 '11 14:02

Woops


People also ask

Which STL does not allow duplicates?

So, the conclusion, use std::unordered_set or std::unordered_map (if you need the key-value feature). And you don't need to check before doing the insertion, these are unique-key containers, they don't allow duplicates.

Is using STL good?

You should use STL, because it is well tested and optimized.

Why do we use STL?

The STL exemplifies generic programming rather than object-oriented programming, and derives its power and flexibility from the use of templates, rather than inheritance and polymorphism. It also avoids new and delete for memory management in favor of allocators for storage allocation and deallocation.

What are the 3 main components of the STL?

STL is a library consisting of containers, algorithms, and iterators. As STL consists of a collection of template classes, it's a generalized library that is independent of data types.


2 Answers

When you choose to use a framework like Qt you might consider using lists, vectors, etc from Qt rather that the STL. Not using STL in this case saves you from having to convert from STL to the Qt equivalents when you need to use them in your GUI.

This is debatable and not everyone wants to use everything from Qt

from http://doc.qt.nokia.com/latest/containers.html

These container classes are designed to be lighter, safer, and easier to use than the STL containers. If you are unfamiliar with the STL, or prefer to do things the "Qt way", you can use these classes instead of the STL classes.

like image 137
Dirk Avatar answered Sep 30 '22 15:09

Dirk


If you cannot use RTTI and/or exceptions, you might experience that parts of STL won't work. This is the case e.g. for native Android apps. So if it doesn't give you what you need, it's a reason not to use it!

like image 26
Philipp Avatar answered Sep 30 '22 15:09

Philipp