Talk:C++/STL
Add topicDescription of the STL containers
[edit source]The current description of the STL containers is too brief to be of much use to a C++ beginner, at least to one who began with this course, since they may not have taken a data structures course. So, I think it would be better if we had something like:
Vectors (the container)
[edit source](Include here the implementation of the container, as:)
template <class Type, class Allocator = allocator<T> > class vector;
(Then follow up with description of the container, including special features, for vectors, the bounds-checking; for deques, the efficiency in modifications at both ends)
Vectors are an extension of the C array, in that they use contiguous storage space. However, a vector is variable-sized and can grow as more and more elements are added. And, unlike arrays, vector also implement a form of bounds-checking, where the member function
at()
throws anout_of_range
exception when a position outside the range is accessed.(Followed by a list of functions and operators. The array-subscript operator [] is available only for vectors and deques, so they should be included in the list, if available.)
A section could be included, discussing the advantages and disadvantage of each container.
I'm in two minds about including constructors. Anyway, the lessons section should include an example for each constructor available.
What do you think? Murukeshm 16:37, 15 October 2009 (UTC)
- It's currently a stub-class article. Since it's obvious there is missing content, go ahead and add it. --Sigma 7 02:09, 20 October 2009 (UTC)
Alternate Lesson Approach?
[edit source]Effectively using the STL could easily be a course itself. Would it make sense to reduce this page to simply demonstrate several practical uses of each type of major STL component, and then a very, very quick summary of the other available STL templates?
Turning this page into a giant reference page on all the STL classes seems redundant and not very practical for teaching a beginner 'the big picture'.
For example, maybe an outline like this:
- STL Examples
- STL string
- std::string example
- STL Containers
- std::vector<> to store ints
- STL Iterators
- std::list<> to store ints
- STL Algorithms
- std::sort()
- std::find_if()
- STL Adapters
- std::binder1st()
- STL string
- STL Complex Example
- Combine std::map, std::string, iterators, and algorithms
- STL overview
- Brief description of what else the library can do