Wednesday, June 30, 2010

Predefined Function Objects

The following are predefined C++ function objects:
        negate<type>()
        plus<type>()
        minus<type>()
        multiplies<type>()
        divides<type>()
        modulus<type>()
        equal_to<type>()
        not_equal_to<type>()
        less<type>()
        greater<type>()
        less_equal<type>()
        greater_equal<type>()
        logical_not<type>()
        logical_and<type>()
        logical_or<type>()

Reference: The C++ Standard Library: A Tutorial and Reference by Nicolas M. Josuttis. Addison-Wesley, 1999, p. 305.

Tuesday, June 29, 2010

Predefined Function Objects

The predefined function objects are declared in the <functional>
include file.

Reference: The C++ Standard Library: A Tutorial and Reference by Nicolai M. Josuttis. Addison-Wesley, 1999, p. 305.

Saturday, June 26, 2010

Internationalization

"i18n" stands for internationalization. The "18" stands for the number of letters between 'i' and 'n'.

Reference: "The C++ Standard Library" by Nicolai M. Josuttis. Addison-Wesley, 1999, p. 685.

Thursday, June 24, 2010

Enum

Given:
  enum MyEnum
  
  {

    zero,
    minus_ten = -10,
    mystery
  };

mystery equals -9.

Tuesday, June 22, 2010

The for_each() Algorithm

The for_each algorithm can take a range and a function object as parameters. It will apply the function object to each item in the range.
The for_each algorithm returns the function_object. It is the only algorithm that does this. You can query the returned function object to get its state.

Sunday, June 20, 2010

String Size and Length

For any string s, s.size() == s.length()

Reference: The C++ Standard Library: A Tutorial and Reference by Nicolai M. Josuttis. Addison-Wesley, 1999, p. 476.

Saturday, June 19, 2010

String of Zeroes

If a string s, only contains 10 bytes of zero, then s.length() == 10.

Reference: The C++ Standard Library: A Tutorial and Reference by Nicolai M. Josuttis. Addison-Wesley, 1999, p. 476.