views:

163

answers:

3

After learning good amount of c++, i'm now into STL containers and algorithms template library, my major concerns are,

1) Is this library same across different platforms like MS, linux n other os?

2) will quality or efficiency of program c++ module decrease with more use of STL containers and algorithms, i think i can't customize it to all needs.

3) Is this template library good to use in linux system programming, kernel modules?

4) lastly can i use this in programming contests, because it relives a lot of coding and pressure off shoulders.

+5  A: 

1) Is this library same across different platforms like MS, linux n other os?

No. Except the standardized interface, the implementations are all different for each compiler suite, and sometimes they also provide custom extensions such as hash_map.

2) will quality or efficiency of program c++ module decrease with more use of STL containers and algorithms, i think i can't customize it to all needs.

I don't think so. The quality and efficiency should be much better than cooking one up by your own, unless you have very special needs.

3) Is this template library good to use in linux system programming, kernel modules?

Better use C for the kernel.

4) lastly can i use this in programming contests, because it relives a lot of coding and pressure off shoulders.

Depends on the rules of the contests.

KennyTM
+4  A: 

1) Standard (interface) is the same. Implementation is different.

2) Quality or efficiency of your program depends only on your skills. STL provides you benefits you can use and misuse.

3) Not for kernel modules, yes for user mode applications.

4) Normally C++ contests allow STL.

AlexKR
+3  A: 

1) API same. Limiting behavior specified in the standard (e.g. O(n) ). Implementation vendor specific. Means you can rely on the scaling of your app.

2) As long as you have to ask this questions, the quality and efficiency of your code is likey to improve by using the STL.

3) Not in the kernel.

4) C++ constests should allow STL.

snies
Actually , I once had an improvement by switching from vector to C-Style array.
Improvement in what? Performance? Did you profile Debug or Release builds?
FredOverflow
The constraints in the standard are upper limits, but there are cases where a particular STL implementation can produce faster code (algorithmically faster code) than others. The example is: `vector<vector<int> >::push_back`, when increasing capacity from `N`, g++ implementation will call the `vector<int>` copy constructor `N` times for a total of `O(N*M)` operations (`M` is the size of the internal vector). Dinkumware implementation (in VS) will create empty `vector<int>` in a new larger container and perform `N` optimized swap operations with a cost of `O(N)`.
David Rodríguez - dribeas
FredOverflow : Performance - Release - VTune