I've decided to read source code of STL,is there any material about it?
Since c++ has changed a lot in the past ten years,I suspect that books written
ten years ago are still useful for learning generic progromming.
I don't want to lost in details of algorithms,since i am not expecting being a expert at data structures and algorithms,So i am wondering whether it's a good choice to read STL source code.
any suggestion?
> So i am wondering whether it's a good choice to read STL source code.
Read standard library source code shipped with an implementation? Not a good choice for learning how to use the library.
To get an idea of what it is, start with the simplest parts (where you will not be overwhelmed by low level details about the platform and the innards of the compiler). Algorithms and function objects are good places to start.
I've decided to read source code of STL,is there any material about it?
Assuming you're referring to the C++ standard library (based on "c++ has changed a lot in the past ten years") and not the HP/SGI library called "STL", which was abandoned over a decade ago, there is no "source code of STL". There is a set of requirements to the interface and to the runtime complexity of the standard library (including the containers library, the algorithm library, and the functional library, which were once heavily based on the interfaces of STL the library), and each C++ compiler vendor finds its own way to satisfy them.
As JLBorges pointed out, it's not a good way to learn to use it, but there is occasional merit in looking up the source code of a standard library implementation. Personally, I find libc++ to be most clearly written: http://llvm.org/svn/llvm-project/libcxx/trunk/include/
Another one that's online browsable is GNU stdlibc++: http://gcc.gnu.org/viewcvs/gcc/trunk/libstdc%2B%2B-v3/include/ although it's burdened with backwards compatibility and lacks a few components of modern C++ (e.g. the codecvt header)
I've known how to use standary library very well.Now i wanna learn some technologies about generic progrmming,for example,in the adjacent_find,
the realistic implementation code as declaration may be something like that:
template<typename Iter>
Enable_if<Forward_iterator<Iter>(),Iter>adjacent_find( Iter first, Iter last );
I care about generic progrmming neither using STL nor data structures and algotithms ,but i find myself got lost in details of implementation of sophisticated data structures and algorithms easily when reading these codes.
Is some STL implementation worth reading?what about SGI STL?
> i wanna learn some technologies about generic progrmming
> Is some STL implementation worth reading?what about SGI STL?
IMHO, books may be a better way to get introduced to generic progrmming techniques. Looking at the actual source code for a standard library implementation could be something that you could do in parallel.