Browse DevX
Sign up for e-mail newsletters from DevX

Search the Tips
Tip Bank > C++ > STL


1-20 of 87     Previous     Next
Using the Standard Library Algorithms with Arrays
by Kevin Spiteri
Pointers may be used as iterators when using the standard library algorithms found in <algorithm>.
Porting itoa Windows STL Code to Linux
by Elsayed Elghadban
This tip can help you port your code from Windows to Linux when your code uses the default itoa implementation in the STL.
Porting Code from Windows to Linux
by Elsayed Elghadban
This tip provides a substitute for the __strrev function, because it's not available under Linux.
Using the ostream_iterator()
by Saurabh Ramya
This iterator works in conjunction with STL algorithms, allowing you to perform a variety of actions besides merely reading the elements of a container.
Using Insert Iterators
by Saurabh Ramya
Insert iterators come in very handy when you need to populate a container using an STL algorithm which uses an assignment operator to fill in the data.
Using STL Binders
by Saurabh Ramya
Learn how to use STL binders to use binary function objects as unary function objects in many STL algorithms which need them.
Favor the Function Object to the Function Pointer in STL Algorithms
by Saurabh Ramya
Many of the STL algorithms have two versions, with one version taking one less parameter than what the second version takes. Learn the difference between the function pointer and the function object and why one is more effective than the other.
Returning from main()
by Mohan Bisht
This tip describes the exceptions and their workarounds for returning from main().
Generate Permutations for a Given Set of Numbers
by Karthik Kumar
Use the STL Library function next_permutation to generate permutations for s given set of numbers.
Include Templates
by Danny Kalev
Unlike ordinary classes and functions, which you declare in a header file and define in a separate .cpp file, a template
Serializing a Polymorphic Object
by Danny Kalev
A polymorphic object has one or more virtual functions. When you serialize such an object to a file so that it can be reconstituted later, the deserialization might rewrite its vptr and cause ...
Parenthesize Macro Arguments
by Danny Kalev
It's a good idea to parenthesize every macro argument. For ...
Namespaces and the C Standard Library
by Danny Kalev
The C++ Standard requires that the C standard library be declared in namespace std, just as the C++ Standard Library. Thus, if you #include <cstdio> and call printf(), you should use a ...
Where are std::min() and std::max()?
by Danny Kalev
The Standard Library defines the two template functions std::min() and std::max() in the <algorithm> header. In general, you should use these template functions for calculating the min and ...
<iostream.h> or <iostream>?
by Danny Kalev
Although the <iostream.h> library was deprecated for several years, many C++ users still use it in new code instead of using the newer, standard compliant <iostream> library. What are the ...
std::vector Iterators
by Danny Kalev
To create an iterator of a vector, you have to use a vector specialization. In the following examples, I create two vector iterators: one for the specialization vector <int> and another for ...
The remove_if() algorithm
by Danny Kalev
The remove_if() algorithms (defined in the standard header <algorithm>) has the following ...
Function Object Bases
by Danny Kalev
To simplify the process of writing custom function objects, the Standard Library provides two classes that serve as base classes of such objects: std::unary_function and std::binary_function. ...
The remove() Algorithm
by Danny Kalev
The Standard Library defines the std::remove() algorithm, which moves desired elements to the front of a container and returns an iterator pointing to the end of the sequence of the desired ...
Generating a Unique Filename
by Danny Kalev
To generate a unique filename that won't conflict with any other files that exist in the current directory, use the tmpnam() function declared in <stdio.h> as ...
1-20 of 87     Previous     Next
Thanks for your registration, follow us on our social networks to keep up-to-date