Monday, November 30, 2009

Unique()

Calling unique() on a vector containing {1,2,1,2} results in {1,2,1,2}.
Reference: Effective STL by Scott Meyers. Addison-Wesley, 2001. p. 148.

Saturday, November 28, 2009

Associative Containers

For associative containers, the find member functions are O(logn), and the find algorithms are
O(n).
Reference: Effective STL by Scott Meyers, Addison-Wesley, 2001. p. 190.

Thursday, November 26, 2009

STL Header File Names

All STL containers are declared in header files of the same name except for multimap and multiset.
Reference: Effective STL by Scott Meyers. Addison-Wesley, 2001., p.209.

Tuesday, November 24, 2009

Compiler implicitly declared functions

When the compiler implicitly declares default constructors, copy constructors, copy assignment operators, and destructors; they are implicitly declared inlined.
Reference: Exceptional C++ Style by Herb Sutter, Addison-Wesley, 2004., p. 143-145.

Sunday, November 22, 2009

POD

The int type is a trivial case of a POD (Plain Old Data).PODs contribute to the compatibility between C and C++.

Friday, November 20, 2009

Deques

Deques are not required to be implemented as C-style arrays as vectors are.
Reference: Exceptional C++ Style by Herb Sutter, Addison-Wesley, 2004., p. 159.

Wednesday, November 18, 2009

Inlined Functions

A compiler can inline functions that you did not declare inline (i.e. by using 'inline' in the declaration or by providing the body in the class declaration).
Reference: Exceptional C++ Style by Herb Sutter, Addison-Wesley, 2004., p. 193.

Monday, November 16, 2009

Inlined Functions

A compiler can refuse to inline a function that you declared inline.
Reference: Exceptional C++ Style by Herb Sutter, Addison-Wesley, 2004., p. 193.

Saturday, November 14, 2009

Inline Functions

A compiler can inline a function in one place and not in another.

Reference: "Exceptional C++ Style" by Herb Sutter, Addison-Wesley, 2004. p. 193.

Friday, November 13, 2009

Static Class Member Variables

When you have a static class member variable, there is only one copy of the variable in the whole program. If you have member function with a static variable, there is also only one copy of the variable in the whole program.