Click here to Skip to main content
15,889,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey everybody

I find the STL too complicated and cannot understand the logic of how it works.

I want to find a different library that covers things like string, array, queue, deque, list, link list, tree, huffman, prefix-suffix, stack, but I don't like the iterator concept used in many libraries.
Posted
Updated 3-Dec-09 16:26pm
v2

STL is the STANDARD library. It's part of C++. The only other library I know of, is the one Microsoft wrote as a stopgap while they worked on getting an STL implimentation. It was a short term fix, and it sucked. The concept of iterators is simply something you will need to understand. It's not very complicated at all.

The STL is part of C++. No-one is going to bother providing an alternative to a library that doesn't need fixing, and that is part of the language. The closest you can get, is boost, which EXTENDS STL, it does not replace it.

Your other alternative is to learn C# instead, which is not as powerful, but also not as complicated.
 
Share this answer
 
You seem to me to be saying that you don't understand the standard library. It is VERY logical, VERY well designed and something you will need to understand if you want to write efficient C++ code. I'd suggest you buy a good STL book and work through it, along the way you'll learn some basic computer science concepts that will help you enormously, even if you choose to write your own containers and not harness the power of STL.
 
Share this answer
 
Ok. i accept your ideal. But i want more the libraries you think they are good.
 
Share this answer
 
ok. i will research STL more.
thank all you.
and now. i have read code in stl_vector.h but i can't understand it.
anybody in here can help explain code in stl such as stl_vector.h
 
Share this answer
 
v3
As others said STL is so important if you are developing on C++. If you don't understand STL, you are not using C++.

STL code is complicated because it is expected to support a wide range of compilers while maintaining the generic nature. It uses templates heavily which can be confusing for beginners. I'd suggest you to learn template meta programming first before you take a look at STL code. Learning that will make many things in the STL code more clear to you.

Also don't look at the Microsoft's implementation of STL. Read the code which GCC has got. In that, vector.h is a facade header file and the real implementation is on stl_vector.h. On a LINUX machine it will be in /usr/include/c++/gcc_version/vector.h and /usr/include/c++/gcc_version/bits/stl_vector.h.
 
Share this answer
 
To understand the logic of how it works, the source may not be the good starting point:

1. Because it is oftem "obfucated" by a number of preprocessing definition to adapt the source itself on different usage for different compilers and environment
2. Because the order that makes things appear in the source is often due to the language syntax needs, than to the importance of the things in the context.

You will probably more successful in google "STL tutorials" and than (after you understant STL usage) try to look the sources.

A good starting may be this one:
http://www.cs.brown.edu/~jak/proglang/cpp/stltut/tut.html[^]
 
Share this answer
 
v2
Strange answers for a far from being stupid question ...
Actually this guy has good companions:

Just look here:
(Alexandrescu opinion)[^]

It explain why iterators may be considered far from ideal, but doing so, it also explain how they work.

Unortunatly, the STL is what the today C++ allows to define.
Future releases may be will be different.

Moral: don't "escape" the STL, understand it and find a bette rway to enhaence it!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900