The Standard C++ and Boost Libraries
The Standard C++ library

The Standard C++ library

Table of Contents

API Description
IOStreams
STL
Algorithms
Containers
Function Objects
Iterators
Memory Allocation
Numerics
Utilities

 


API Description

The APIs provided by the Standard C++ library are classified as follows:

 


IOStreams

Functions Description
basic_filebuf A template class that associates the input or output sequence with a file.
basic_fstream A template class that supports reading and writing of named files or devices associated with a file descriptor.
basic_ifstream A template class that supports reading of named files or devices associated with a file descriptor.
basic_ios The common functions required by all streams are included in this base class.
basic_iostream This class assists in formatting and interpreting the sequences of characters controlled by a stream buffer.
basic_istream This class assists in reading and interpreting the input from sequences controlled by a stream buffer.
basic_istringstream This template class supports reading objects of class basic_string <charT,traits,Allocator> from an array in memory.
basic_ofstream This class supports writing into named files or other devices associated with a file descriptor.
basic_ostream This class helps in formatting and writing output to sequences controlled by a stream buffer.
basic_ostringstream This class supports writing objects of class basic_string <charT,traits,Allocator> to an array in memory.
basic_streambuf This is an abstract base class used for, deriving various stream buffers to facilitate control of character sequences.
basic_string A templatized class for handling sequences of character- like entities.
basic_stringbuf This class is used to associate the input or output sequence with a sequence of arbitrary characters.
basic_stringstream This class supports writing and reading objects of the template class basic_string<charT,traits,Alocator>to or from an array in memory.
cerr A global stream object that controls unbuffered insertions to the standard error output as a byte stream.
cin A global stream object that controls extractions from the standard input as a byte stream.
char_traits A traits class with types and operations for the basic_string container and iostream classes.
clog A global object stream that controls buffered insertions to the standard error output as a byte stream.
codecvt A code conversion facet.
codecvt_byname A facet that includes code set conversion classification facilities based on the named locales.
collate A string collation, comparison, and hashing facet.
collate_byname A string collation, comparison, and hashing facet.
cout A global stream object that controls insertions from the standard output as a byte stream.
ctype A template class that provides a facet used for character classification and case conversion.
ctype_byname A derived template class enabling character classification and case conversion facilities based on the named locale.
exception The class serves as the base class for all exceptions thrown by certain expressions in the Standard C++ Library.
filebuf A derived template class whose objects control, both the character input and output sequence of a file.
fpos The template class describes an object that can store all the information needed to restore the file-position indicator within the iostream classes.
fstream The template class describes an object that controls insertion and extraction of elements using a stream buffer of, class basic_filebuf<charT,_traits>.
has_facet A function template that tests if a particular facet is stored in a specified locale.
ifstream A template class that controls extraction of elements from a stream buffer of class basic_filebuf<charT,traits>
ios_base The class defines member functions and maintains data for classes that inherit from it.
ios A base class that defines several types and functions basic to the operation of iostreams.
iosfwd Declares forward references to several template classes used throughout, iostreams and specializes them for wide and tiny characters.
istream The class defines member functions that help in reading and interpreting input from sequences controlled by a stream buffer.
istringstream This template class supports reading objects of class basic_string <charT,traits,Allocator> from an array in memory.
istrstream Reads characters from an array in memory.
locale A polymorphic set of facets contained in a localization class.
messages A template class that describes an object that can serve as a locale facet to retrieve localized messages from a catalog of internationalized messages for a given locale.
messages_byname A derived template class that describes an object that can serve as a message facet of a given locale, enabling the retrieval of localized messages.
money_get A template class that interprets formatted monetary string inputs.
money_put A template class that interprets formatted monetary string outputs.
moneypunct A locale facet that includes formatting specifications and punctuation character for monetary values.
moneypunct_byname A named locale facet that includes formatting specifications and punctuation character for monetary values.
num_get A template class that describes an object that can serve as a locale facet to control conversions of sequences of character type to numeric values.
num_put A locale facet that allows formatted output of numbers.
numpunct A locale facet that includes formatting specifications and punctuation character for numeric values.
numpunct_byname A named locale facet that includes formatting and punctuation characters for numeric values.
ofstream A Template class that supports writing into named files or other devices associated with a file descriptor.
ostream This class helps in formatting and writing output to sequences controlled by a stream buffer.
ostrstream A class that can be used to write into an array in memory.
ostringstream This class supports writing objects of class basic_string<charT,traits,Alocator> into an array in memory.
streambuf This is an abstract base class used for, deriving various stream buffers to facilitate control of character sequences.
string A typedef for basic_string.
stringbuf An abstract base class for deriving various stream buffers to facilitate control of character sequences.
stringstream This class supports writing and reading objects of the template class basic_string<charT,traits,Alocator>to or from an array in memory.
strstream The class allows insertion and retrieval of data from an array in memory.
strstreambuf The class strstreambuf is derived from basic_streambuf specialized on type char to associate the input or the output sequence with a tiny character array, whose elements store arbitrary values.
time_get A locale facet used for formatting time.
time_get_byname A named locale facet used for formatting time.
time_put A locale facet used for formatting of output time.
time_put_byname A named locale facet used for formatting of output time.
use_facet Returns a reference to a facet of a specified type stored in a locale.
wcerr Object that is wide oriented, translating to and from the wide characters that the program manipulates internally.
wcin Controls input from a stream buffer associated with the object stdin.
wclog Controls output to a stream buffer associated with the object stderr.
wcout The object controls insertions to the standard output as a wide stream.
wfilebuf The type is a synonym for the template class basic_filebuf.
wfstream The type is a synonym for the template class basic_fstream.
wifstream The type is a synonym for the template class basic_ifstream.
wios The type is a synonym for the template class basic_ios.
wistream The type is a synonym for the template class basic_istream.
wistringstream The type is a synonym for the template class basic_istringstream.
wofstream The type is a synonym for the template class basic_ofstream.
wostream The type is a synonym for the template class basic_ostream.
wostringstream The type is a synonym for the template class basic_ostringstream.
wstreambuf The type is a synonym for the template class basic_streambuf.
wstring The type is a synonym for the template class basic_string.
wstringbuf The type is a synonym for the template class basic_stringbuf.

Give feedback on this article

 


STL

The different types of components of the STL library are as listed below:

 


Algorithms

The STL library includes a large collection of algorithms that manipulate the data stored in containers.

Mutating

Functions Description
copy Assigns the values of elements from a source range to a destination range, iterating through the source and assigning them new positions in a forward direction.
copy_backward Assigns the values of elements from a source range to a destination range, iterating through the source and assigning them new positions in a forward direction.
fill Assigns every element in the range with the same value.
fill_n Assigns every element in the range with the same value.
generate Assigns the values generated by a value-generator class to each element in a range.
generate_n Assigns the values generated by a value-generator class to each element in a range.
iter_swap Exchanges two values referred to by a pair of specified iterators.
partition Sorts a range on the condition that the elements that satisfy the predicate are placed before those that do not satisfy the predicate.
random_shuffle Randomly rearranges the elements in the range.
remove Removes from the range all elements that are equal to value.
remove_copy Copies elements that are not equal to value from one range to another range beginning at result.
remove_copy_if Copies elements from one range to another range beginning at result, except that elements for which predicate is true are not copied.
remove_if Removes from the range every element x such that predicate x is true.
replace Replaces every element in the range [first, last) equal to old_value with new_value.
replace_copy Copies every new value from one range to another range beginning with result.
replace_copy_if Copies elements from one range to another range beginning with result, except that any element for which pred is true is not copied; new_value is copied instead.
replace_if Replaces every element in the range for which predicate returns true with new_value.
reverse Reverses a range.
reverse_copy Copies elements from one range to another range beginning with result, such that the copy is a reverse of the original range.
rotate Rotates the elements in a range.
rotate_copy Rotates the elements in a range.
stable_partition Reorders the elements in the range based on the function object predicate.
swap Swaps the values.
swap_ranges Swaps each of the elements of one range with the corresponding elements of the other range.
transform Performs an operation on objects using either a single range of input iterator or two ranges of iterator.
unique Removes the consecutive duplicate values from a range and places the resulting unique values in result.
unique_copy Removes the consecutive duplicate values from a range and places the resulting unique values in result.

Non-mutating:

Functions Description
adjacent_find A function that finds the first adjacent pair of equivalent elements in a sequence.
count Returns the number of elements in a container that either satisfy the given value or condition.
count_if Returns the number of elements in a container that either satisfy the given value or condition.
equal This function compares two ranges element by element for equality or equivalence as specified by the binary predicate.
find Locates the position of the first occurrence of value in a range or sequence.
find_end Locates the last subsequence in a range.
find_first_of Locates the first occurrence within the target range.
find_if Locates the position of the first occurrence of an element in a range that satisfies a specified predicate.
for_each Applies a specified function object to each element in a forward order within a range and returns the function object.
mismatch Finds the first position where the two ranges differ.
search Searches for a sub-sequence within a sequence.
search_n Searches for a sub-sequence within a sequence.

Numeric

Functions Description
accumulate Accumulate is a generalization of summation.
adjacent_difference A function that outputs a sequence of the differences between the adjacent pair of elements in a range.
inner_product Computes the inner product of two ranges using either, the default multiplication and addition operators or, by using the specified binary operators.
partial_sum An algorithm which creates a new sequence of elements, calculated by successive partial sums of a range of values.

Sorting

Functions Description
binary_search Performs a binary search for a value on ordered container.
equal_range This function finds a pair of positions in an ordered range.
includes Tests whether the first sorted range contains all the elements contained in the second sorted range.
inplace_merge Combines the elements from two sorted ranges into one sorted range.
lexicographical_compare Returns true if the range of elements [first1, last1) is lexicographically less than the range of elements [first2, last2), and false otherwise.
lower_bound A version of binary search that returns the first position where the specified value can be inserted without violating the ordering.
make_heap Converts elements from a specified range into a heap in which the first element is the largest.
max An utility that returns the greater of its two arguments or the first argument when neither of its arguments is greater than the other.
max_element Finds the largest element in a range.
merge Combines two sorted ranges into a single sorted range.
min Compares two arguments and returns the lesser of its two arguments or the first argument if neither of its arguments is lesser than the other.
min_element Finds the smallest element in a range and returns an iterator that points to the smallest element.
next_permutation Transforms the range of elements into the lexicographically next greater permutation of the elements.
nth_element It partially orders the range of elements such that the element pointed by the iterator nth, has elements in front of it that are less than or equal to it and all the elements that follow it in the sequence are greater than or equal to it.
partial_sort Rearranges the elements in the range so that they are partially in ascending order.
partial_sort_copy Partially sorts the elements in the range and copies as many elements as possible into another range provided.
pop_heap Removes the largest element from the heap.
prev_permutation Transforms a range of elements the lexicographically next smaller permutation of the elements.
push_heap Adds a new element to heap.
set_difference Constructs a sorted range that is the set difference of the two sorted ranges and returns the end of the output range.
set_intersection Constructs a sorted range that is the intersection of the two sorted ranges.
set_symmetric_difference Constructs a sorted range that is the set symmetric difference of the two sorted ranges.
set_union Constructs a sorted range that is the union of the two sorted ranges.
sort Sorts the range in ascending order.
sort_heap Turns a heap into a sorted range.
stable_sort Sorts collections of entities.
upper_bound A version of binary search that attempts to find the element value in an ordered range.

 


Containers

Containers are objects that store other objects. They control the allocation and de-allocation of these objects through constructors, destructors, insert and erase operations. This section deals with the STL container classes.

Associative Containers

Functions Description
associative container A container that provides for fast retrieval of data, based on keys.
map This is a kind of associative container that supports unique keys (contains at most one of each key value) and provides for fast retrieval of values.
multimap This is a kind of associative container that supports equal keys (possibly contains multiple copies of the same key value) and provides for fast retrieval of values.
multiset This is a kind of associative container that supports equal keys (possibly contains multiple copies of the same key value) and provides for fast retrieval of the keys themselves.
set This is a kind of associative container that supports unique keys (contains at most one of each key value) and provides for fast retrieval of the keys themselves.

Container adaptors

Functions Description
priority_queue An adaptor that provides a restricted subset of container functionality: it provides insertion of elements, inspection and removal of the top element.
queue An adaptor that provides a restricted subset of container functionality.
stack An adaptor that provides a restricted subset of container functionality: it provides insertion, removal, and inspection of the element at the top of the stack.

Sequences

Functions Description
sequences A variable-sized container whose elements are arranged in a strict linear order.
deque A kind of sequence that, like a vector, supports random access iterators.
list A kind of sequence that supports bidirectional iterators and allows constant time insert and erase operations anywhere within the sequence, with storage management handled automatically.
vector A kind of sequence that supports random access iterators.

String pack

Functions Description
basic string A class that represents a sequence of characters.
bitset The template class describes a type of object that stores a sequence consisting of a fixed number that provide a compact way of keeping flags for a set of items or conditions.
char traits The char_traits class is the default Character Traits class used by the library.

 


Function Objects

Function objects are objects with an operator()defined.

Adaptors

Functions Description
binary_function Simplifies the typedefs of the argument and result types.
binary_negate A function object adaptor that returns a binary predicate function object that is the complement of the original.
bind1st A helper template function that creates an adaptor to convert a binary function object into a unary function object.
bind2nd A helper template function that creates an adaptor to convert a binary function object into a unary function object.
binder1st A helper template function that creates an adaptor to convert a binary function object into a unary function object.
binder2nd A helper template function that creates an adaptor to convert a binary function object into a unary function object.
mem_fun1 An adaptor for member functions.
mem_fun An adaptor for member functions.
mem_fun_ref An adaptor for member functions.
negators Functions that return the complement of the predicate function objects.
pointer_to_binary_function A Function object adaptor that allows a function pointer to be treated as a binary function.
pointer_to_unary_function A Function object adaptor that allows a function pointer to be treated as an unary function.
ptr_fun Takes a function pointer as its argument and returns a function pointer adaptor.
unary_function A function object, called as if it were an ordinary C++ function.
unary_negate A function object adaptor that represents the logical negation of some other adaptable predicate.

Arithmetic operations

Functions Description
plus An adaptable binary function.
minus An adaptable binary function.
times An adaptable binary function.
divides An adaptable binary function.
modulus An adaptable binary function.
negate An adaptable binary function.
complex The template class describes an object that stores two objects, one that represents the real part of a complex number and one that represents the imaginary part.

Comparisons

Functions Description
equal_to A function object that tests the truth or falsehood of some condition.
greater A function object that tests the truth or falsehood of some condition.
greater_equal A function object that tests the truth or falsehood of some condition.
less A function object that tests the truth or falsehood of some condition.
less_equal A function object that tests the truth or falsehood of some condition.
not_equal_to A function object that tests the truth or falsehood of some condition.

Logical operations

Functions Description
logical_and A function object that tests the truth or falsehood of some condition.
logical_not A function object that tests the truth or falsehood of some condition.
logical_or A function object that tests the truth or falsehood of some condition.

 


Iterators

Iterators are a generalization of pointers: they are objects that point to other objects. Iterators act as an interface between algorithms and containers. Algorithms typically take iterators as arguments, so a container need only provide a way to access its elements using iterators.

Base classes

Functions Description
Input iterators An iterator that is dereferenced to refer to some object, and incremented to obtain the next iterator in a sequence.
Output iterators An iterator type that provides a mechanism for storing (but not necessarily accessing) a sequence of values.
Forward iterators An iterator that corresponds to the notion of a linear sequence of values.
Bidirectional iterators An iterator that can be both incremented and decremented.
Random access iterators An iterator that provide essentially all of the operations of ordinary C pointer arithmetic.
Stream iterators Includes iterator capabilities for input and output streams.

Classes

Functions Description
istreambuf_iterator The template class describes an input iterator object.
istream_iterator Performs formatted input of objects of type T from a particular istream.
ostream_iterator Performs formatted output of objects of type T from a particular ostream.
front_insert_iterator An iterator adaptor that functions as an output iterator.
back_insert_iterator An iterator adaptor that functions as an output iterator.
insert_iterator An iterator adaptor that functions as an output iterator.
reverse_iterator An iterator adaptor that enables backwards traversal of a range.
raw_storage_iterator An adaptor that allocates memory for an object and then creates an object at that location by calling a constructor.
reverse_bidirectional_iterator An iterator adaptor that has a template argument that is a bidirectional iterator.

Functions

Functions Description
advance An iterator tag function used to advance the iterator by the distance specified.
distance_type An iterator tag function used to determine the distance type associated with an iterator.
distance An iterator tag function used to determine the distance between the iterator arguments.
iterator_category An iterator tag function used to determine the category to which an iterator belongs.

Iterator tags

Functions Description
iterator_traits A template class that returns basic information about an iterator.

 


Memory Allocation

Classes

Functions Description
allocator Encapsulates the allocation and deallocation of memory.

Functions

Functions Description
auto_ptr A smart pointer class that ensures that the object to which it points gets destroyed automatically when control leaves a block.
uninitialized_copy An algorithm that copies values form one range to another using constructs.
uninitialized_fill An algorithm that sets values in a collection using constructs.
uninitialized_fill_n An algorithm that sets values in a collection using constructs.
get_temporary_buffer Allocates temporary storage for a sequence of elements that does not exceed a specified number of elements.
return_temporary_buffer Deallocates memory that was allocated using get_temporary_buffer.

 


Numerics

Classes

Functions Description
gslice An array class that provides generalized view into an array.
gslice_array A class that provides glice view into a valarray.
indirect_array A numeric class that represents elements selected from a valarray.
mask_array An array class that provides a masked view of the class valarray.
slice A class that provides a slice of array.
slice_array Class that provides a sliced view into a valarray.
valarray A simple array class that stores varying length sequence of elements and allows manipulation of the elements.

 


Utilities

Classes

Functions Description
pair A heterogeneous template that owns its elements but does not support the standard methods of accessing the elements of a container.

Functions

Functions Description
Operators The relational operators used in the Standard Template Library (STL).

Give feedback on this article


Back to top


Copyright ©2008 Nokia Corporation. All rights reserved. This documentation can be used in the connection with this Product to help and support the user.