Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there variations in the C++ STL standard?

Tags:

c++

stl

I have always been religiously using SGI's Standard Template Library Programmer's Guide (STLPG) as a reference manual whenever I implement something in C++ using the STL. Up until yesterday it has never failed me but yesterday I was working with std::vector at work and was pair programming with a colleague of mine who told me to use the assign method. I did not recognize this method which is unusual for me so I started digging through the std::vector part of the STLPG and there is no mention of any assign methods. My colleague pointed me to cpluplus.com's page on std::vector and lo and behold there it was along with a couple of other methods, such as at, that I also had never seen.

This confused me terrible so I went medieval on the problem and dug into */usr/include/c++/4.1.2/bits/stl_vector.h* which is copyright Hewlett-Packard Company 1994 and Silicon Graphics Computer Systems, Inc. 1996 and it contains implementations of both assign and at without any special commentary mentioning why they are omitted in the most recent copyright holders own documentation.

Is there anyone more seasoned than myself who could illuminate the community as to why these discrepancies exist and which online reference manual can I trust to be compliant with all modern STL implementation?

like image 672
David Holm Avatar asked Apr 08 '11 07:04

David Holm


1 Answers

I usually use the C++ Reference, mainly because its Googles first hit if you search for something like c++ std vector. But I have also found the information presented there accurate.

When in doubt I reference the latest working draft of the C++ Standard. (e.g. to answer your initial question chapter 23.3.6 [vector]) Of course this is then C++0x, which might not be fully supported yet, so you might want to check an older draft (i.e. the last one before C++03 was released).

like image 93
Fabio Fracassi Avatar answered Oct 12 '22 10:10

Fabio Fracassi