Next Dinkum C++ Library Use of this Dinkum C++ Library Reference is subject to limitations. See the Copyright Notice for detailed restrictions. A C++ program can call on a large number of functions from the Dinkum C++ Library, a conforming implementation of the Standard C++ library. These functions perform essential services such as input and output. They also provide efficient implementations of frequently used operations.
The Standard C++ library consists of 51 required headers. This implementation also includes three additional headers, , , and , not required by the C++ Standard, for a total of 54 headers. Of these 54 headers, 16 constitute the Standard Template Library, or STL.
-- for defining template classes that buffer iostreams operations -- for defining a template class that implements a string container -- for defining several iostreams classes that manipulate in-memory character sequences -- for defining class type_info, the result of the typeid operator -- (STL) for defining several templates of general utility -- for defining several classes and template classes that support value-oriented arrays --
-- for computing common mathematical functions -- for executing nonlocal goto statements -- for controlling various exceptional conditions -- for accessing a varying number of arguments -- for defining several useful types and macros -- for performing input and output -- for performing a variety of operations -- for manipulating several kinds of strings
Copyright © 1992-2001 by P.J. Plauger. All rights reserved.
Next Hewlett-Packard Notice This material is derived in part from software and documentation bearing the following restrictions: Copyright © 1994 Hewlett-Packard Company Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation.
Next Dinkumware, Ltd. Genuine Software Copyright and License Notice Dinkumware, Ltd. 398 Main Street Concord MA 01742 USA +1-978-371-2773 Dinkum® C++ Library developed by P.J. Plauger Dinkum C++ Library Reference developed by P.J. Plauger Disclaimer for HP NonStopTM Implementation: This documentation is intended to document the Standard C++ Library ISO/IEC (VERSION3) on HP NonStop systems.
● ● ● ● ● You may make one or more backup copies of the Product for archival purposes. You may permanently transfer ownership of the Product to another party only if the other party agrees to the terms stated in this Notice and you transfer or destroy all copies of the Product that are in your posession. You must preserve this Notice and all copyright notices with any copy you make of the Product. You may not loan, rent, or sublicense the Product.
DAMAGES. By using this Product, you agree to abide by the intellectual property laws and all other applicable laws of the USA, and the terms described above. You may be held legally responsible for any infringement that is caused or encouraged by your failure to abide by the terms of this Notice. RESTRICTED RIGHTS: Use, duplication, or disclosure by the government is subject to the restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software Clause as DFARS 52.
● ● Contains a complete implementation of the Standard C library, as of 1992 at least, as well as text from the library portion of the C Standard and guidance in using the Standard C library. P.J. Plauger, The Draft Standard C++ Library (Englewood Cliffs NJ: Prentice Hall, 1995). Contains a complete implementation of the draft Standard C++ library as of early 1994. P.J. Plauger, Alexander Stepanov, Meng Lee, and David R. Musser, The Standard Template Library (Englewood Cliffs NJ: Prentice Hall, 2001).
Next adjacent_find · binary_search · copy · copy_backward · count · count_if · equal · equal_range · fill · fill_n · find · find_end · find_first_of · find_if · for_each · generate · generate_n · includes · inplace_merge · iter_swap · lexicographical_compare · lower_bound · make_heap · max · max_element · merge · min · min_element · mismatch · next_permutation · nth_element · partial_sort · partial_sort_copy · partition · pop_heap · prev_permutation · push_heap · random_shuffle · remove · remov
FwdIt1 find_end(FwdIt1 first1, FwdIt1 last1, FwdIt2 first2, FwdIt2 last2); template FwdIt1 find_end(FwdIt1 first1, FwdIt1 last1, FwdIt2 first2, FwdIt2 last2, Pr pred); template FwdIt1 find_first_of(FwdIt1 first1, FwdIt1 last1, FwdIt2 first2, FwdIt2 last2); template FwdIt1 find_first_of(FwdIt1 first1, FwdIt1 last1, FwdIt2 first2, FwdIt2 last2, Pr pred); template FwdIt adjacent_find(FwdIt first
FwdIt1 search_n(FwdIt1 first1, FwdIt1 last1, Diff2 count, const Ty& val, Pr pred); template OutIt copy(InIt first, InIt last, OutIt dest); template BidIt2 copy_backward(BidIt1 first, BidIt1 last, BidIt2 dest); template void swap(Ty& left, Ty& right); template FwdIt2 swap_ranges(FwdIt1 first1, FwdIt1 last1, FwdIt2 last2); template void iter_swap(FwdIt1 left, FwdIt2 right); template
template FwdIt remove_if(FwdIt first, FwdIt last, Pr pred); template OutIt remove_copy(InIt first, InIt last, OutIt dest, const Ty& val); template OutIt remove_copy_if(InIt first, InIt last, OutIt dest, Pr pred); template FwdIt unique(FwdIt first, FwdIt last); template FwdIt unique(FwdIt first, FwdIt last, Pr pred); template OutIt unique_copy(InIt first, I
template void partial_sort(RanIt first, RanIt mid, RanIt last); template void partial_sort(RanIt first, RanIt mid, RanIt last, Pr pred); template RanIt partial_sort_copy(InIt first1, InIt last1, RanIt first2, RanIt last2); template RanIt partial_sort_copy(InIt first1, InIt last1, RanIt first2, RanIt last2, Pr pred); template void nth_element(RanIt first, RanIt nth, RanIt last); template
InIt2 first2, InIt2 last2, OutIt dest); template OutIt merge(InIt1 first1, InIt1 last1, InIt2 first2, InIt2 last2, OutIt dest, Pr pred); template void inplace_merge(BidIt first, BidIt mid, BidIt last); template void inplace_merge(BidIt first, BidIt mid, BidIt last, Pr pred); template bool includes(InIt1 first1, InIt1 last1, InIt2 first2, InIt2 last2); template bo
OutIt set_symmetric_difference(InIt1 first1, InIt1 last1, InIt2 first2, InIt2 last2, OutIt dest, Pr pred); template void push_heap(RanIt first, RanIt last); template void push_heap(RanIt first, RanIt last, Pr pred); template void pop_heap(RanIt first, RanIt last); template void pop_heap(RanIt first, RanIt last, Pr pred); template void make_heap(RanIt first, RanIt last); template void make_heap(RanIt f
template bool next_permutation(BidIt first, BidIt last, Pr pred); template bool prev_permutation(BidIt first, BidIt last); template bool prev_permutation(BidIt first, BidIt last, Pr pred); }; adjacent_find template FwdIt adjacent_find(FwdIt first, FwdIt last); template FwdIt adjacent_find(FwdIt first, FwdIt last, Pr pred); The first template function determines the lowest N in the range [0, last - first) for whic
The second template function behaves the same, except that it replaces operator<(X, Y) with pred(X, Y). copy template OutIt copy(InIt first, InIt last, OutIt dest); The template function evaluates *(dest + N) = *(first + N)) once for each N in the range [0, last - first), for strictly increasing values of N beginning with the lowest value. It then returns dest + N. If dest and first designate regions of storage, dest must not be in the range [first, last).
function returns count. It evaluates the predicate exactly last - first times. equal template bool equal(InIt1 first1, InIt1 last1, InIt2 first2); template bool equal(InIt1 first1, InIt1 last1, InIt2 first2, Pr pred); The first template function returns true only if, for each N in the range [0, last1 first1), the predicate *(first1 + N) == *(first2 + N) is true. Here, operator== must perform a pairwise comparison between its operands.
fill_n template void fill_n(OutIt first, Diff count, const Ty& val); The template function evaluates *(first + N) = val once for each N in the range [0, count). find template InIt find(InIt first, InIt last, const Ty& val); The template function determines the lowest value of N in the range [0, last - first) for which the predicate *(first + N) == val is true. Here, operator== must perform a pairwise comparison between its operands.
template FwdIt1 find_first_of(FwdIt1 first1, FwdIt1 last1, FwdIt2 first2, FwdIt2 last2, Pr pred); The first template function determines the lowest value of N in the range [0, last1 first1) such that for some M in the range [0, last2 - first2), the predicate *(first1 + N) == *(first2 + M) is true. Here, operator== must perform a pairwise comparison between its operands. It then returns first1 + N. If no such value exists, the function returns last1.
[0, count).
The second template function behaves the same, except that it replaces operator<(X, Y) with pred(X, Y). iter_swap template void iter_swap(FwdIt1 left, FwdIt2 right); The template function leaves the value originally stored in *right subsequently stored in *left, and the value originally stored in *left subsequently stored in *right.
ordered by operator<. It then returns first + N. Thus, the function determines the lowest position before which val can be inserted in the sequence and still preserve its ordering. The function evaluates the ordering predicate X < Y at most ceil(log(last - first)) + 1 times. The second template function behaves the same, except that it replaces operator<(X, Y) with pred(X, Y).
N) < *(first + M) is false. It then returns first + N. Thus, the function determines the lowest position that contains the largest value in the sequence. The function evaluates the ordering predicate X < Y exactly max((last - first) - 1, 0) times. The second template function behaves the same, except that it replaces operator<(X, Y) with pred(X, Y).
need supply only a single-argument constructor and a destructor. The second template function behaves the same, except that it replaces operator<(X, Y) with pred(X, Y).
template bool next_permutation(BidIt first, BidIt last, Pr pred); The first template function determines a repeating sequence of permutations, whose initial permutation occurs when the sequence designated by iterators in the range [first, last) is ordered by operator<. (The elements are sorted in ascending order.) It then reorders the elements in the sequence, by evaluating swap(X, Y) for the elements X and Y zero or more times, to form the next permutation.
void partial_sort(RanIt first, RanIt mid, RanIt last, Pr pred); The first template function reorders the sequence designated by iterators in the range [first, last) such that for each N in the range [0, mid - first) and for each M in the range (N, last - first) the predicate !(*(first + M) < *(first + N)) is true. Thus, the smallest mid - first elements of the entire sequence are sorted in ascending order, ordered by operator<. The order of the remaining elements is otherwise unspecified.
pred(*(first + N)) is true, and for each N in the range [K, last - first) the predicate pred(*(first + N)) is false. The function then returns first + K. The predicate must not alter its operand. The function evaluates pred(*(first + N)) exactly last - first times, and swaps at most (last - first) / 2 pairs of elements.
with pred(X, Y). push_heap template void push_heap(RanIt first, RanIt last); template void push_heap(RanIt first, RanIt last, Pr pred); The first template function reorders the sequence designated by iterators in the range [first, last) to form a new heap ordered by operator<. Iterators in the range [first, last 1) must designate an existing heap, also ordered by operator<. Thus, first != last must be true and *(last - 1) is the element to add to (push on) the heap.
once for each N in the range [0, last - first). Here, operator== must perform a pairwise comparison between its operands. It then returns X. Thus, the function removes from the resulting sequence all elements for which the predicate *(first + N) == val is true, without altering the relative order of remaining elements, and returns the iterator value that designates the end of the resulting sequence.
remove_if template FwdIt remove_if(FwdIt first, FwdIt last, Pr pred); The template function effectively assigns first to X, then executes the statement: if (!pred(*(first + N))) *X++ = *(first + N); once for each N in the range [0, last - first). It then returns X.
replace_copy_if template OutIt replace_copy_if(InIt first, InIt last, OutIt dest, Pr pred, const Ty& val); The template function executes the statement: if (pred(*(first + N))) *(dest + N) = val; else *(dest + N) = *(first + N) once for each N in the range [0, last - first). If dest and first designate regions of storage, the range [dest, dest + (last first)) must not overlap the range [first, last).
The template function evaluates *(dest + N) = *(last - 1 - N) once for each N in the range [0, last - first). It then returns dest + (last - first). Thus, the function reverses the order of elements in the sequence that it copies. If dest and first designate regions of storage, the range [dest, dest + (last first)) must not overlap the range [first, last).
The first template function determines the lowest value of N in the range [0, (last1 first1) - (last2 - first2)) such that for each M in the range [0, last2 first2), the predicate *(first1 + N + M) == *(first2 + M) is true. Here, operator== must perform a pairwise comparison between its operands. It then returns first1 + N. If no such value exists, the function returns last1. It evaluates the predicate at most (last2 - first2) * (last1 - first1) times.
otherwise be copied to adjacent elements, the function copies only the element from the ordered range [first1, last1) and skips the other. An element from one sequence that has equivalent ordering with no element from the other sequence is copied from the ordered range [first1, last1) and skipped from the other. Thus, the function merges two ordered sequences to form another ordered sequence that is effectively the difference of two sets.
set_symmetric_difference template OutIt set_symmetric_difference(InIt1 InIt1 last1, InIt2 first2, InIt2 Pr pred); OutIt> first1, last2, OutIt dest); OutIt, first1, last2, OutIt dest, The first template function alternately copies values from two sequences designated by iterators in the ranges [first1, last1) and [first2, last2), both ordered by operator<,
function then returns dest + K. The merge occurs without altering the relative order of elements within either sequence. Moreover, for two elements from different sequences that have equivalent ordering that would otherwise be copied to adjacent elements, the function copies only the element from the ordered range [first1, last1) and skips the other. Thus, the function merges two ordered sequences to form another ordered sequence that is effectively the union of two sets.
The function evaluates the ordering predicate X < Y at most ceil((last - first) * log(last - first)) times. The second template function behaves the same, except that it replaces operator<(X, Y) with pred(X, Y).
swap template void swap(Ty& left, Ty& right); The template function leaves the value originally stored in right subsequently stored in left, and the value originally stored in left subsequently stored in right. swap_ranges template FwdIt2 swap_ranges(FwdIt1 first1, FwdIt1 last1, FwdIt2 first2); The template function evaluates swap(*(first1 + N), *(first2 + N)) once for each N in the range [0, last1 - first1). It then returns first2 + (last1 first1).
The first template function effectively assigns first to X, then executes the statement: if (N == 0) ++X; else if (!(*X == *(first + N))) *X++ = V; once for each N in the range [0, last - first). It then returns X. Thus, the function repeatedly removes from the resulting sequence the second of a pair of elements for which the predicate *(first + N) == *(first + N + 1) is true, until only the first of a sequence of elements survives that satisfies the comparison.
If dest and first designate regions of storage, the range [dest, dest + (last first)) must not overlap the range [first, last).
Next Include the standard header to define the template class bitset and two supporting templates.
typename basic_string::size_type count = basic_string::npos); bitset& operator&=(const bitset& right); bitset& operator|=(const bitset& right); bitset& operator^=(const bitset& right); bitset& operator<<=(const bitset& pos); bitset& operator>>=(const bitset& pos); bitset& set(); bitset& set(size_t pos, bool val = true); bitset& reset(); bitset& reset(size_t pos); bitset& flip(); bitset
bitset::bitset bitset(); bitset(unsigned long val); template explicit bitset(const basic_string& str, typename basic_string::size_type pos = 0, typename basic_string::size_type count = basic_string::npos); The first constructor resets all bits in the bit sequence. The second constructor sets only those bits at position J for which val & 1 << J is nonzero.
bitset::operator!= bool operator !=(const bitset& right) const; The member operator function returns true only if the bit sequence stored in *this differs from the one stored in right. bitset::operator&= bitset& operator&=(const bitset& right); The member operator function replaces each element of the bit sequence stored in *this with the logical AND of its previous value and the corresponding bit in right. The function returns *this.
bitset::operator>>= bitset& operator>>=(const bitset& pos); The member function replaces each element of the bit sequence stored in *this with the element pos positions later in the sequence. If no such later element exists, the function clears the bit. The function returns *this.
reference& flip(); }; The member class describes an object that designates an individual bit within the bit sequence.
bitset::to_string template basic_string to_string() const; The member function constructs str, an object of class basic_string. For each bit in the bit sequence, the function appends 1 if the bit is set, otherwise 0. The last element appended to str corresponds to bit position zero. The function returns str.
See also the Table of Contents and the Index. Copyright © 1992-2001 by P.J. Plauger. All rights reserved.
Next abs · arg · complex · complex · complex · complex · conj · cos · cosh · exp · imag · log · log10 · norm · operator!= · operator* · operator+ · operator- · operator/ · operator<< · operator== · operator>> · polar · pow · real · sin · sinh · sqrt · tan · tanh · __STD_COMPLEX Include the standard header to define template class complex and a host of supporting template functions.
template complex operator-(const complex& const Ty& right); template complex operator-(const Ty& left, const complex& right); template complex operator*(const complex& const complex& right); template complex operator*(const complex& const Ty& right); template complex operator*(const Ty& left, const complex& right); template complex operator/(const complex& const complex& right); template
template bool operator!=(const Ty& left, const complex& right); template basic_istream& operator>>(basic_istream& istr, complex& right); template basic_ostream& operator<<(basic_ostream& ostr, const complex& right); template Ty real(const complex& left); template Ty imag(const complex& left); template Ty abs(const complex& left); template
template complex pow(const Ty& left, const complex& right); template complex sin(const complex& left); template complex sinh(const complex& left); template complex sqrt(const complex& left); }; abs template Ty abs(const complex& left); The function returns the magnitude of left. arg template Ty arg(const complex& left); The function returns the phase angle of left.
complex& operator*=(const complex& right); template complex& operator/=(const complex& right); complex& operator=(const Ty& right); complex& operator+=(const Ty& right); complex& operator-=(const Ty& right); complex& operator*=(const Ty& right); complex& operator/=(const Ty& right); }; The template class describes an object that stores two objects of type Ty, one that represents the real part of a complex number and one that represents the imaginary part.
which is the copy constructor. complex::imag Ty imag() const; The member function returns the stored imaginary part. complex::operator*= template complex& operator*=(const complex& right); complex& operator*=(const Ty& right); The first member function replaces the stored real and imaginary parts with those corresponding to the complex product of *this and right. It then returns *this.
complex::operator-= template complex& operator-=(const complex& right); complex& operator-=(const Ty& right); The first member function replaces the stored real and imaginary parts with those corresponding to the complex difference of *this and right. It then returns *this. The second member function subtracts right from the stored real part. It then returns *this.
The second member function replaces the stored real part with right and the stored imaginary part with zero. It then returns *this. In this implementation, if a translator does not support member template functions, the template: template complex& operator=(const complex& right); is replaced by: complex& operator=(const complex& right); which is the default assignment operator. complex::real Ty real() const; The member function returns the stored real part.
complex template<> class complex { public: complex(float realval = 0, float imagval = 0); explicit complex(const complex& right); explicit complex(const complex& right); // rest same as template class complex }; The explicitly specialized template class describes an object that stores two objects of type float, one that represents the real part of a complex number and one that represents the imaginary part.
cos template complex cos(const complex& left); The function returns the cosine of left. cosh template complex cosh(const complex& left); The function returns the hyperbolic cosine of left. exp template complex exp(const complex& left); The function returns the exponential of left. imag template Ty imag(const complex& left); The function returns the imaginary part of left.
norm template Ty norm(const complex& left); The function returns the squared magnitude of left. operator!= template bool operator!=(const complex& left, const complex& right); template bool operator!=(const complex& left, const Ty& right); template bool operator!=(const Ty& left, const complex& right); The operators each return true only if real(left) != real(right) || imag(left) != imag(right).
complex operator+(const complex& left, const Ty& right); template complex operator+(const Ty& left, const complex& right); template complex operator+(const complex& left); The binary operators each convert both operands to the return type, then return the complex sum of the converted left and right. The unary operator returns left.
The operators each convert both operands to the return type, then return the complex quotient of the converted left and right. operator<< template basic_ostream& operator<<(basic_ostream& ostr, const complex& right); The template function inserts the complex value right in the output stream os, effectively by executing: basic_ostringstream osstr; osstr.flags(ostr.flags()); osstr.imbue(ostr.imbue()); osstr.precision(ostr.
complex& right); The template function attempts to extract a complex value from the input stream istr, effectively by executing: istr >> ch && ch == '(' && istr >> re >> ch && ch == ',' && istr >> im >> ch && ch == ')' Here, ch is an object of type Elem, and re and im are objects of type Ty. If the result of this expression is true, the function stores re in the real part and im in the imaginary part of right. In any event, the function returns istr.
sin template complex sin(const complex& left); The function returns the sine of left. sinh template complex sinh(const complex& left); The function returns the hyperbolic sine of left. sqrt template complex sqrt(const complex& left); The function returns the square root of left, with phase angle in the half-open interval (-pi/2, pi/2]. The branch cuts are along the negative real axis.
See also the TableofContents and the Index. Copyright © 1992-2001 by P.J. Plauger. All rights reserved.
Next Include the STL standard header to define the container template class deque and several supporting templates.
deque allocator_type · assign · at · back · begin · clear · const_iterator · const_pointer · const_reference · const_reverse_iterator · deque · difference_type · empty · end · erase · front · get_allocator · insert · iterator · max_size · operator[] · pointer · pop_back · pop_front · push_back · push_front · rbegin · reference · rend · resize · reverse_iterator · size · size_type · swap · value_type template > class deque { public: typedef Alloc allocator_type; typedef
const_iterator begin() const; iterator end(); const_iterator end() const; reverse_iterator rbegin(); const_reverse_iterator rbegin() const; reverse_iterator rend(); const_reverse_iterator rend() const; void resize(size_type newsize); void resize(size_type newsize, Ty val); size_type size() const; size_type max_size() const; bool empty() const; Alloc get_allocator() const; reference at(size_type pos); const_reference at(size_type pos) const; reference operator[](size_type pos); const_reference operator[](siz
sequence require element copies and assignments proportional to the number of elements in the sequence (linear time). The object allocates and frees storage for the sequence it controls through a stored allocator object of class Alloc. Such an allocator object must have the same external interface as an object of template class allocator. Note that the stored allocator object is not copied when the container object is assigned.
deque::back reference back(); const_reference back() const; The member function returns a reference to the last element of the controlled sequence, which must be non-empty. deque::begin const_iterator begin() const; iterator begin(); The member function returns a random-access iterator that points at the first element of the sequence (or just beyond the end of an empty sequence). deque::clear void clear(); The member function calls erase( begin(), end()).
deque::const_reverse_iterator typedef reverse_iterator const_reverse_iterator; The type describes an object that can serve as a constant reverse random-access iterator for the controlled sequence.
deque::end const_iterator end() const; iterator end(); The member function returns a random-access iterator that points just beyond the end of the sequence. deque::erase iterator erase(iterator where); iterator erase(iterator first, iterator last); The first member function removes the element of the controlled sequence pointed to by where. The second member function removes the elements of the controlled sequence in the range [first, last).
Each of the member functions inserts, before the element pointed to by where in the controlled sequence, a sequence specified by the remaining operands. The first member function inserts a single element with value val and returns an iterator that points to the newly inserted element. The second member function inserts a repetition of count elements of value val. If InIt is an integer type, the last member function behaves the same as insert(where, (size_type)first, (Ty)last).
deque::pointer typedef typename Alloc::pointer pointer; The type describes an object that can serve as a pointer to an element of the controlled sequence. deque::pop_back void pop_back(); The member function removes the last element of the controlled sequence, which must be non-empty. Removing the element invalidates only iterators and references that designate the erased element. The member function never throws an exception.
deque::rbegin const_reverse_iterator rbegin() const; reverse_iterator rbegin(); The member function returns a reverse iterator that points just beyond the end of the controlled sequence. Hence, it designates the beginning of the reverse sequence. deque::reference typedef typename Alloc::reference reference; The type describes an object that can serve as a reference to an element of the controlled sequence.
The member function returns the length of the controlled sequence. deque::size_type typedef T2 size_type; The unsigned integer type describes an object that can represent the length of any controlled sequence. It is described here as a synonym for the implementation-defined type T2. deque::swap void swap(deque& right); The member function swaps the controlled sequences between *this and right. If get_allocator() == right.
operator< template bool operator<( const deque & left, const deque & right); The template function overloads operator< to compare two objects of template class deque. The function returns lexicographical_compare(left. begin(), left. end(), right.begin(), right.end()). operator<= template bool operator<=( const deque & left, const deque & right); The template function returns !(right < left).
deque & left, deque & right); The template function executes left.swap(right). See also the Table of Contents and the Index. Copyright © 1994-2001 by P.J. Plauger. Portions derived from work copyright © 1994 by Hewlett-Packard Company. All rights reserved.
Next Include the standard header to define several types and functions related to the handling of exceptions.
virtual ~exception() throw(); virtual const char *what() const throw(); }; The class serves as the base class for all exceptions thrown by certain expressions and by the Standard C++ library. The C string value returned by what() is left unspecified by the default constructor, but may be defined by the constructors for certain derived classes as an implementation-defined C string. None of the member functions throw any exceptions.
terminate_handler typedef void (*terminate_handler)(); The type describes a pointer to a function suitable for use as a terminate handler. uncaught_exception bool uncaught_exception(); The function returns true only if a thrown exception is being currently processed. Specifically, it returns true after completing evaluation of a throw expression and before completing initialization of the exception declaration in the matching handler or calling unexpected as a result of the throw expression.
See also the Table of Contents and the Index. Copyright © 1992-2001 by P.J. Plauger. All rights reserved.
Next Include the iostreams standard header to define several classes that support iostreams operations on sequences stored in external files.
off_type; basic_filebuf(); bool is_open() const; basic_filebuf *open(const char *filename, ios_base::openmode mode); basic_filebuf *close(); protected: virtual pos_type seekoff(off_type off, ios_base::seekdir way, ios_base::openmode which = ios_base::in | ios_base::out); virtual pos_type seekpos(pos_type pos, ios_base::openmode which = ios_base::in | ios_base::out); virtual int_type underflow(); virtual int_type pbackfail(int_type meta = traits_type::eof()); virtual int_type overflow(int_type meta = traits_
basic_filebuf::char_type typedef Elem char_type; The type is a synonym for the template parameter Elem. basic_filebuf::close basic_filebuf *close(); The member function returns a null pointer if the file pointer fp is a null pointer. Otherwise, it calls fclose(fp). If that function returns a nonzero value, the function returns a null pointer. Otherwise, it returns this to indicate that the file was successfully closed.
fopen(filename, strmode). Here strmode is determined from mode & ~(ate & | binary): ● ios_base::in becomes "r" (open existing file for reading). ● ios_base::out or ios_base::out | ios_base::trunc becomes "w" (truncate existing file or create for writing). ios_base::out | app becomes "a" (open existing file for appending all writes). ● ● ● ● ios_base::in | ios_base::out becomes "r+" (open existing file for reading and writing).
successive calls of the form fputc(ch, fp). If any conversion or write fails, the function does not succeed. If the function cannot succeed, it returns traits_type::eof(). Otherwise, it returns traits_type::not_eof(meta). basic_filebuf::pbackfail virtual int_type pbackfail(int_type meta = traits_type::eof()); The protected virtual member function endeavors to put back an element into the input buffer, then make it the current element (pointed to by the next pointer).
of type pos_type stores at least an fpos_t object.) For a file opened for both reading and writing, both the input and output streams are positioned in tandem. To switch between inserting and extracting, you must call either pubseekoff or pubseekpos. Calls to pubseekoff (and hence to seekoff) have various limitations for text streams, binary streams, and wide streams. If the file pointer fp is a null pointer, the function fails.
basic_filebuf::setbuf virtual basic_streambuf *setbuf(Elem *buffer, streamsize count); The protected member function returns zero if the file pointer fp is a null pointer. Otherwise, it calls setvbuf(fp, (char *)buffer, _IOFBF, count * sizeof (Elem)) to offer the array of count elements beginning at buffer as a buffer for the stream. If that function returns a nonzero value, the function returns a null pointer. Otherwise, it returns this to signal success.
basic_fstream template > class basic_fstream : public basic_iostream { public: basic_fstream(); explicit basic_fstream(const char *filename, ios_base::openmode mode = ios_base::in | ios_base::out); basic_filebuf *rdbuf() const; bool is_open() const; void open(const char *filename, ios_base::openmode mode = ios_base::in | ios_base::out); void close(); }; The template class describes an object that controls insertion and extraction of elements and
basic_fstream::is_open bool is_open(); The member function returns rdbuf()-> is_open(). basic_fstream::open void open(const char *filename, ios_base::openmode mode = ios_base::in | ios_base::out); The member function calls rdbuf()-> open(filename, mode). If that function returns a null pointer, the function calls setstate(failbit). basic_fstream::rdbuf basic_filebuf *rdbuf() const The member function returns the address of the stored stream buffer, of type pointer to basic_filebuf.
basic_ifstream::basic_ifstream basic_ifstream(); explicit basic_ifstream(const char *filename, ios_base::openmode mode = ios_base::in); The first constructor initializes the base class by calling basic_istream(sb), where sb is the stored object of class basic_filebuf. It also initializes sb by calling basic_filebuf(). The second constructor initializes the base class by calling basic_istream(sb). It also initializes sb by calling basic_filebuf(), then sb.
public: basic_filebuf *rdbuf() const; basic_ofstream(); explicit basic_ofstream(const char *filename, ios_base::openmode mode = ios_base::out); bool is_open() const; void open(const char *filename, ios_base::openmode mode = ios_base::out); void close(); }; The template class describes an object that controls insertion of elements and encoded objects into a stream buffer of class basic_filebuf, with elements of type Ele, whose character traits are determined by the class Tr.
basic_ofstream::open void open(const char *filename, ios_base::openmode mode = ios_base::out); The member function calls rdbuf()-> open(filename, mode | ios_base::out). If that function returns a null pointer, the function calls setstate(failbit). basic_ofstream::rdbuf basic_filebuf *rdbuf() const The member function returns the address of the stored stream buffer.
wfstream typedef basic_fstream > wfstream; The type is a synonym for template class basic_fstream, specialized for elements of type wchar_t with default character traits. wifstream typedef basic_ifstream > wifstream; The type is a synonym for template class basic_ifstream, specialized for elements of type wchar_t with default character traits.
Next binary_function · binary_negate · binder1st · binder2nd · const_mem_fun_t · const_mem_fun_ref_t · const_mem_fun1_t · const_mem_fun1_ref_t · divides · equal_to · greater · greater_equal · less · less_equal · logical_and · logical_not · logical_or · mem_fun_t · mem_fun_ref_t · mem_fun1_t · mem_fun1_ref_t · minus · modulus · multiplies · negate · not_equal_to · plus · pointer_to_binary_function · pointer_to_unary_function · unary_function · unary_negate bind1st · bind2nd · mem_fun · mem_fun_
template struct unary_negate; template struct binary_negate; template class binder1st; template class binder2nd; template class pointer_to_unary_function; template struct mem_fun_t; template struct const_mem_fun_t; template
template mem_fun1_ref_t mem_fun_ref(Result (Ty::*pm)(Arg left)); template const_mem_fun_ref_t mem_fun_ref(Result (Ty::*pm)() const); template const_mem_fun1_ref_t mem_fun_ref(Result (Ty::*pm)(Arg left) const); }; binary_function template struct binary_function { typedef Arg1 first_argument_type; typedef Arg2 second_argument_type; t
The function returns binder2nd(func, typename Fn2::second_argument_type(right)).
const_mem_fun_ref_t template struct const_mem_fun_ref_t : public unary_function { explicit const_mem_fun_t(Result (Ty::*pm)() const); Result operator()(const Ty& left) const; }; The template class stores a copy of pm, which must be a pointer to a member function of class Ty, in a private member object. It defines its member function operator() as returning (left.*pm)() const.
greater template struct greater : public binary_function { bool operator()(const Ty& left, const Ty& right) const; }; The template class defines its member function as returning left > right. The member function defines a total ordering if Ty is an object pointer type. (It will compare two pointer values consistently even if they don't point into the same array.
The template class defines its member function as returning left && right. logical_not template struct logical_not : public unary_function { bool operator()(const Ty& left) const; }; The template class defines its member function as returning !left. logical_or template struct logical_or : public binary_function { bool operator()(const Ty& left, const Ty& right) const; }; The template class defines its member function as returning left || right.
}; The template class stores a copy of pm, which must be a pointer to a member function of class Ty, in a private member object. It defines its member function operator() as returning (pleft->*pm)(). mem_fun_ref_t template struct mem_fun_ref_t : public unary_function { explicit mem_fun_t(Result (Ty::*pm)()); Result operator()(Ty& left) const; }; The template class stores a copy of pm, which must be a pointer to a member function of class Ty, in a private member object.
}; The template class defines its member function as returning left % right. multiplies template struct multiplies : public binary_function { Ty operator()(const Ty& left, const Ty& right) const; }; The template class defines its member function as returning left * right. negate template struct negate : public unary_function { Ty operator()(const Ty& left) const; }; The template class defines its member function as returning -left.
pointer_to_binary_function template class pointer_to_binary_function : public binary_function { public: explicit pointer_to_binary_function( Result (*pfunc)(Arg1, Arg2)); Result operator()(const Arg1 left, const Arg2 right) const; }; The template class stores a copy of pfunc. It defines its member function operator() as returning (*pfunc)(left, right).
unary_negate template class unary_negate : public unary_function< typename Fn1::argument_type, bool> { public: explicit unary_negate(const Fn1& Func); bool operator()( const typename Fn1::argument_type& left) const; }; The template class stores a copy of func, which must be a unary function object. It defines its member function operator() as returning !func(left). See also the Table of Contents and the Index. Copyright © 1994-2001 by P.J. Plauger.
Next Include the STL standard header to define the container template classes hash_map and hash_multimap, and their supporting templates.
bool operator>( const hash_map& left, const hash_map& right); template bool operator>( const hash_multimap& left, const hash_multimap& right); template bool operator<=( const hash_map& left, const hash_map& right); template bool operator<=( const hash_multimap
hash_compare(Pr pred); size_t operator()(const Key& Key) const; bool operator()(const Key& keyval1, const Key& keyval2) const; }; The template class describes an object that can be used by any of the containers hash_map, hash_multimap, hash_set, or hash_multiset as a hash traits object to order the sequence it controls. Each of these stores hash traits object of type Tr (a template parameter).
template >, class Alloc = allocator > > class hash_map { public: typedef Key key_type; typedef Ty mapped_type; typedef Tr key_compare; typedef Alloc allocator_type; typedef pair value_type; class value_compare; typedef Alloc::pointer pointer; typedef Alloc::const_pointer const_pointer; typedef Alloc::reference reference; typedef Alloc::const_reference const_reference; typedef T0 iterator; typedef T1 const_iterator
const_reverse_iterator rend() const; size_type size() const; size_type max_size() const; bool empty() const; Alloc get_allocator() const; mapped_type operator[](const Key& keyval); pair insert(const value_type& val); iterator insert(iterator where, const value_type& val); template void insert(InIt first, InIt last); iterator erase(iterator where); iterator erase(iterator first, iterator last); size_type erase(const Key& keyval); void clear(); void swap(hash_map& right); key_compa
must behave the same as an object of class hash_compare. Specifically, for all values keyval of type Key, the call key_comp()(keyval) yields a distribution of values of type size_t. Moreover, class Pr imposes a strict weak ordering on sort keys of type Key. For any element X that precedes Y in the sequence and has the same hash value, key_comp()(Y.first, X.first) is false. (For the default function object less, sort keys never decrease in value.
hash_map::const_pointer typedef Alloc::const_pointer const_pointer; The type describes an object that can serve as a constant pointer to an element of the controlled sequence. hash_map::const_reference typedef Alloc::const_reference const_reference; The type describes an object that can serve as a constant reference to an element of the controlled sequence.
hash_map::end const_iterator end() const; iterator end(); The member function returns a bidirectional iterator that points just beyond the end of the sequence. hash_map::equal_range pair equal_range(const Key& keyval); pair equal_range(const Key& keyval) const; The member function returns a pair of iterators X such that X.first == lower_bound(keyval) and X.second == upper_bound(keyval).
hash_map::hash_map hash_map(); explicit hash_map(const Tr& traits); hash_map(const Tr& traits, const Alloc& al); hash_map(const hash_map& right); template hash_map(InIt first, InIt last); template hash_map(InIt first, InIt last, const Tr& traits); template hash_map(InIt first, InIt last, const Tr& traits, const Alloc& al); All constructors store an allocator object and initialize the controlled sequence. The allocator object is the argument al, if present.
If an exception is thrown during the insertion of a single element, the container is left unaltered and the exception is rethrown. If an exception is thrown during the insertion of multiple elements, the container is left in a stable but unspecified state and the exception is rethrown. hash_map::iterator typedef T0 iterator; The type describes an object that can serve as a bidirectional iterator for the controlled sequence. It is described here as a synonym for the implementation-defined type T0.
hash_map::mapped_type typedef Ty mapped_type; The type is a synonym for the template parameter Ty. hash_map::max_size size_type max_size() const; The member function returns the length of the longest sequence that the object can control. hash_map::operator[] Ty& operator[](const Key& keyval); The member function determines the iterator where as the return value of insert( value_type(keyval, Ty()). (It inserts an element with the specified key if no such element exists.
The member function returns a reverse bidirectional iterator that points at the first element of the sequence (or just beyond the end of an empty sequence). Hence, it designates the end of the reverse sequence. hash_map::reverse_iterator typedef reverse_iterator reverse_iterator; The type describes an object that can serve as a reverse bidirectional iterator for the controlled sequence. hash_map::size size_type size() const; The member function returns the length of the controlled sequence.
hash_map::value_comp value_compare value_comp() const; The member function returns a function object that determines the order of elements in the controlled sequence. hash_map::value_compare class value_compare : public binary_function { public: bool operator()(const value_type& left, const value_type& right) const {return (comp(left.first, right.
value_type template >, class Alloc = allocator > > class hash_multimap { public: typedef Key key_type; typedef Ty mapped_type; typedef Tr key_compare; typedef Alloc allocator_type; typedef pair value_type; class value_compare; typedef Alloc::pointer pointer; typedef Alloc::const_pointer const_pointer; typedef Alloc::reference reference; typedef Alloc::const_reference const_reference; typedef T0 iterator; typedef T
const_reverse_iterator rbegin() const; reverse_iterator rend(); const_reverse_iterator rend() const; size_type size() const; size_type max_size() const; bool empty() const; Alloc get_allocator() const; iterator insert(const value_type& val); iterator insert(iterator where, const value_type& val); template void insert(InIt first, InIt last); iterator erase(iterator where); iterator erase(iterator first, iterator last); size_type erase(const Key& keyval); void clear(); void swap(hash_multimap& rig
access this stored object by calling the member function key_comp(). Such a traits object must behave the same as an object of class hash_compare. Specifically, for all values keyval of type Key, the call key_comp()(keyval) yields a distribution of values of type size_t. Moreover, class Pr imposes a strict weak ordering on sort keys of type Key. For any element X that precedes Y in the sequence and has the same hash value, key_comp()(Y.first, X.first) is false.
sequence. It is described here as a synonym for the implementation-defined type T1. hash_multimap::const_pointer typedef Alloc::const_pointer const_pointer; The type describes an object that can serve as a constant pointer to an element of the controlled sequence. hash_multimap::const_reference typedef Alloc::const_reference const_reference; The type describes an object that can serve as a constant reference to an element of the controlled sequence.
hash_multimap::end const_iterator end() const; iterator end(); The member function returns a bidirectional iterator that points just beyond the end of the sequence. hash_multimap::equal_range pair equal_range(const Key& keyval); pair equal_range(const Key& keyval) const; The member function returns a pair of iterators X such that X.first == lower_bound(keyval) and X.second == upper_bound(keyval).
hash_multimap::hash_multimap hash_multimap(); explicit hash_multimap(const Tr& traits); hash_multimap(const Tr& traits, const Alloc& al); hash_multimap(const hash_multimap& right); template hash_multimap(InIt first, InIt last); template hash_multimap(InIt first, InIt last, const Tr& traits); template hash_multimap(InIt first, InIt last, const Tr& traits, const Alloc& al); All constructors store an allocator object and initialize the controlled sequence.
hash_multimap::iterator typedef T0 iterator; The type describes an object that can serve as a bidirectional iterator for the controlled sequence. It is described here as a synonym for the implementation-defined type T0. hash_multimap::key_comp key_compare key_comp() const; The member function returns the stored hash traits object that determines the order of elements in the controlled sequence.
hash_multimap::max_size size_type max_size() const; The member function returns the length of the longest sequence that the object can control. hash_multimap::pointer typedef Alloc::pointer pointer; The type describes an object that can serve as a pointer to an element of the controlled sequence. hash_multimap::rbegin const_reverse_iterator rbegin() const; reverse_iterator rbegin(); The member function returns a reverse bidirectional iterator that points just beyond the end of the controlled sequence.
hash_multimap::size size_type size() const; The member function returns the length of the controlled sequence. hash_multimap::size_type typedef T2 size_type; The unsigned integer type describes an object that can represent the length of any controlled sequence. It is described here as a synonym for the implementation-defined type T2. hash_multimap::swap void swap(hash_multimap& right); The member function swaps the controlled sequences between *this and right. If get_allocator() == right.
bool operator()(const value_type& left, const value_type& right) const {return (comp(left.first, right.first)); } protected: value_compare(key_compare pr) : comp(pr) {} key_compare comp; }; The type describes a function object that can compare the sort keys in two elements to determine their relative order in the controlled sequence. The function object stores an object comp of type key_type. The member function operator() uses this object to compare the sort-key components of two element.
hash_map. The second template function overloads operator== to compare two objects of template class hash_multimap. Both functions return left.size() == right.size() && equal(left. begin(), left. end(), right.begin()).
const hash_multimap & left, const hash_multimap & right); The template function returns right < left.
Next Include the STL standard header to define the container template classes hash_set and hash_multiset, and their supporting templates.
const hash_set& right); template bool operator>( const hash_multiset& left, const hash_multiset& right); template bool operator<=( const hash_set& left, const hash_set& right); template bool operator<=( const hash_multiset& left, const hash_multiset& right); template
template >, class Alloc = allocator > class hash_multiset { public: typedef Key key_type; typedef Tr key_compare; typedef Key value_type; typedef Tr value_compare; typedef Alloc allocator_type; typedef Alloc::pointer pointer; typedef Alloc::const_pointer const_pointer; typedef Alloc::reference reference; typedef Alloc::const_reference const_reference; typedef T0 iterator; typedef T1 const_iterator; typedef T2 size_type; typedef T3 difference_type; typed
iterator insert(const value_type& val); iterator insert(iterator where, const value_type& val); template void insert(InIt first, InIt last); iterator erase(iterator where); iterator erase(iterator first, iterator last); size_type erase(const Key& keyval); void clear(); void swap(hash_multiset& right); key_compare key_comp() const; value_compare value_comp() const; const_iterator find(const Key& keyval) const; size_type count(const Key& keyval) const; const_iterator lower_bound(const Key& keyval)
elements that have equivalent ordering are adjacent in the controlled sequence. The object allocates and frees storage for the sequence it controls through a stored allocator object of class Alloc. Such an allocator object must have the same external interface as an object of template class allocator. Note that the stored allocator object is not copied when the container object is assigned. hash_multiset::allocator_type typedef Alloc allocator_type; The type is a synonym for the template parameter Alloc.
hash_multiset::const_reverse_iterator typedef reverse_iterator const_reverse_iterator; The type describes an object that can serve as a constant reverse bidirectional iterator for the controlled sequence. hash_multiset::count size_type count(const Key& keyval) const; The member function returns the number of elements in the range [lower_bound(keyval), upper_bound(keyval)).
hash_multiset::erase iterator erase(iterator where); iterator erase(iterator first, iterator last); size_type erase(const Key& keyval); The first member function removes the element of the controlled sequence pointed to by where. The second member function removes the elements in the range [first, last). Both return an iterator that designates the first element remaining beyond any elements removed, or end() if no such element exists.
right.get_allocator(). Otherwise, it is Alloc(). All constructors also store a hash traits object that can later be returned by calling key_comp(). The hash traits object is the argument traits, if present. For the copy constructor, it is right.key_comp()). Otherwise, it is Tr(). The first three constructors specify an empty initial controlled sequence. The fourth constructor specifies a copy of the sequence controlled by right.
hash_multiset::key_compare typedef Tr key_compare; The type describes a traits object that behaves much like an object of class hash_compare. In particular, it can compare two sort keys to determine the relative order of two elements in the controlled sequence. hash_multiset::key_type typedef Key key_type; The type describes the sort key object which constitutes each element of the controlled sequence.
hash_multiset::reference typedef Alloc::reference reference; The type describes an object that can serve as a reference to an element of the controlled sequence. hash_multiset::rend const_reverse_iterator rend() const; The member function returns a reverse bidirectional iterator that points at the first element of the sequence (or just beyond the end of an empty sequence). Hence, it designates the end of the reverse sequence.
hash_multiset::upper_bound const_iterator upper_bound(const Key& keyval) const; The member function returns an iterator just beyond the iterator that designates the latest element X in the controlled sequence for which X has equivalent ordering to keyval. If no such element exists, the function returns end(). hash_multiset::value_comp value_compare value_comp() const; The member function returns a function object that determines the order of elements in the controlled sequence.
typedef Key key_type; typedef Tr key_compare; typedef Key value_type; typedef Tr value_compare; typedef Alloc allocator_type; typedef Alloc::pointer pointer; typedef Alloc::const_pointer const_pointer; typedef Alloc::reference reference; typedef Alloc::const_reference const_reference; typedef T0 iterator; typedef T1 const_iterator; typedef T2 size_type; typedef T3 difference_type; typedef reverse_iterator const_reverse_iterator; typedef reverse_iterator reverse_iterator; hash_set()
iterator erase(iterator where); iterator erase(iterator first, iterator last); size_type erase(const Key& keyval); void clear(); void swap(hash_set& right); key_compare key_comp() const; value_compare value_comp() const; const_iterator find(const Key& keyval) const; size_type count(const Key& keyval) const; const_iterator lower_bound(const Key& keyval) const; const_iterator upper_bound(const Key& keyval) const; pair equal_range(const Key& keyval) const; }; The template class
the container object is assigned. hash_set::allocator_type typedef Alloc allocator_type; The type is a synonym for the template parameter Alloc. hash_set::begin const_iterator begin() const; The member function returns a bidirectional iterator that points at the first element of the sequence (or just beyond the end of an empty sequence). hash_set::clear void clear(); The member function calls erase( begin(), end()).
The type describes an object that can serve as a constant reverse bidirectional iterator for the controlled sequence. hash_set::count size_type count(const Key& keyval) const; The member function returns the number of elements in the range [lower_bound(keyval), upper_bound(keyval)). hash_set::difference_type typedef T3 difference_type; The signed integer type describes an object that can represent the difference between the addresses of any two elements in the controlled sequence.
where. The second member function removes the elements in the range [first, last). Both return an iterator that designates the first element remaining beyond any elements removed, or end() if no such element exists. The third member removes the elements with sort keys in the range [lower_bound(keyval), upper_bound(keyval)). It returns the number of elements it removes. The member functions never throw an exception.
specifies a copy of the sequence controlled by right. The last three constructors specify the sequence of element values [first, last). hash_set::insert pair insert(const value_type& val); iterator insert(iterator where, const value_type& val); template void insert(InIt first, InIt last); The first member function determines whether an element X exists in the sequence whose key has equivalent ordering to val. If not, it creates such an element X and initializes it with val.
hash_compare. In particular, it can compare two sort keys to determine the relative order of two elements in the controlled sequence. hash_set::key_type typedef Key key_type; The type describes the sort key object which constitutes each element of the controlled sequence. hash_set::lower_bound const_iterator lower_bound(const Key& keyval) const; The member function returns an iterator that designates the earliest element X in the controlled sequence for which X has equivalent ordering to keyval.
hash_set::rend const_reverse_iterator rend() const; The member function returns a reverse bidirectional iterator that points at the first element of the sequence (or just beyond the end of an empty sequence). Hence, it designates the end of the reverse sequence. hash_set::reverse_iterator typedef reverse_iterator reverse_iterator; The type describes an object that can serve as a reverse bidirectional iterator for the controlled sequence.
hash_set::value_comp value_compare value_comp() const; The member function returns a function object that determines the order of elements in the controlled sequence. hash_set::value_compare typedef Tr value_compare; The type describes a function object that can compare two elements as sort keys to determine their relative order in the controlled sequence. hash_set::value_type typedef Key value_type; The type describes an element of the controlled sequence.
operator== template bool operator==( const hash_set & left, const hash_set & right); template bool operator==( const hash_multiset & left, const hash_multiset & right); The first template function overloads operator== to compare two objects of template class hash_set. The second template function overloads operator== to compare two objects of template class hash_multiset.
const hash_multiset & left, const hash_multiset & right); The template function returns !(right < left). operator> template bool operator>( const hash_set & left, const hash_set & right); template bool operator>( const hash_multiset & left, const hash_multiset & right); The template function returns right < left.
Next Include the iostreams standard header to define several manipulators that each take a single argument. Each of these manipulators returns an unspecified type, called T1 through T6 here, that overloads both basic_istream::operator>> and basic_ostream::operator<<.
● If base is any other value, then mask is ios_base::fmtflags(0) setfill template T4 setfill(Elem ch); The template manipulator returns an object that, when extracted from or inserted into the stream str, calls str.fill(ch), then returns str. The type Elem must be the same as the element type for the stream str. setiosflags T2 setiosflags(ios_base::fmtflags mask); The manipulator returns an object that, when extracted from or inserted into the stream str, calls str.
Next basic_ios · fpos · ios · ios_base · streamoff · streampos · streamsize · wios · wstreampos boolalpha · dec · fixed · hex · internal · left · noboolalpha · noshowbase · noshowpoint · noshowpos · noskipws · nounitbuf · nouppercase · oct · right · scientific · showbase · showpoint · showpos · skipws · unitbuf · uppercase Include the iostreams standard header to define several types and functions basic to the operation of iostreams.
// MANIPULATORS ios_base& boolalpha(ios_base& iosbase); ios_base& noboolalpha(ios_base& iosbase); ios_base& showbase(ios_base& iosbase); ios_base& noshowbase(ios_base& iosbase); ios_base& showpoint(ios_base& iosbase); ios_base& noshowpoint(ios_base& iosbase); ios_base& showpos(ios_base& iosbase); ios_base& noshowpos(ios_base& iosbase); ios_base& skipws(ios_base& iosbase); ios_base& noskipws(ios_base& iosbase); ios_base& unitbuf(ios_base& iosbase); ios_base& nounitbuf(ios_base& iosbase); ios_base& uppercase(
explicit basic_ios(basic_streambuf *strbuf); virtual ~basic_ios(); operator void *() const; bool operator!() const; iostate rdstate() const; void clear(iostate state = goodbit); void setstate(iostate state); bool good() const; bool eof() const; bool fail() const; bool bad() const; iostate exceptions() const; iostate exceptions(iostate newexcept); basic_ios& copyfmt(const basic_ios& right); locale imbue(const locale& loc); char_type widen(char ch); char narrow(char_type ch, char dflt); char_type fi
● stream state information in a base object of type ios_base ● a fill character in an object of type char_type basic_ios::bad bool bad() const; The member function returns true if rdstate() & badbit is nonzero. basic_ios::basic_ios explicit basic_ios(basic_streambuf *strbuf); basic_ios(); The first constructor initializes its member objects by calling init(strbuf). The second (protected) constructor leaves its member objects uninitialized.
basic_ios::exceptions iostate exceptions() const; iostate exceptions(iostate newexcept); The first member function returns the stored exception mask. The second member function stores except in the exception mask and returns its previous stored value. Note that storing a new exception mask can throw an exception just like the call clear( rdstate()). basic_ios::fail bool fail() const; The member function returns true if rdstate() & failbit is nonzero.
● width() returns zero ● precision() returns 6 ● fill() returns the space character ● getloc() returns locale::classic() ● iword returns zero and pword returns a null pointer for all argument value basic_ios::int_type typedef typename Ty::int_type int_type; The type is a synonym for Ty::int_type. basic_ios::narrow char narrow(char_type ch, char dflt); The member function returns use_facet< ctype >( getloc()). narrow(ch, dflt).
basic_ios::rdbuf basic_streambuf *rdbuf() const; basic_streambuf *rdbuf(basic_streambuf *strbuf); The first member function returns the stored stream buffer pointer. The second member function stores strbuf in the stored stream buffer pointer and returns the previously stored value. basic_ios::rdstate iostate rdstate() const; The member function returns the stored stream state information.
dec ios_base& dec(ios_base& iosbase); The manipulator effectively calls iosbase.setf(ios_base:: dec, ios_base:: basefield), then returns iosbase. fixed ios_base& fixed(ios_base& iosbase); The manipulator effectively calls iosbase.setf(ios_base:: fixed, ios_base:: floatfield), then returns iosbase.
state-dependent encoding, mbstate_t may actually be unused. So the number of member objects stored may vary. fpos::fpos fpos(streamoff off); fpos(St state, fpos_t filepos); The first constructor stores the offset off, relative to the beginning of file and in the initial conversion state (if that matters). If off is -1, the resulting object represents an invalid stream position. The second constructor stores the object state and a file position determined by filepos.
fpos::operator== bool operator==(const fpos& right) const; The member function returns (streamoff)*this == (streamoff)right. fpos::operator streamoff operator streamoff() const; The member function returns the stored offset member object, plus any additional offset stored as part of the fpos_t member object. fpos::state St state() const; void state(St state); The first member function returns the value stored in the St member object. The second member function stores state in the St member object.
ios_base event · event_callback · failure · flags · fmtflags · getloc · imbue · Init · ios_base · iostate · iword · openmode · operator= · precision · pword · register_callback · seekdir · setf · streamoff · streampos · sync_with_stdio · unsetf · width · xalloc class ios_base { public: class failure; typedef T1 fmtflags; static const fmtflags boolalpha, dec, fixed, hex, internal, left, oct, right, scientific, showbase, showpoint, showpos, skipws, unitbuf, uppercase, adjustfield, basefield, floatfield; typed
locale getloc() const; static int xalloc(); long& iword(int idx); void *& pword(int idx); typedef void *(event_callback(event ev, ios_base& iosbase, int idx); void register_callback(event_callback pfn, int idx); static bool sync_with_stdio(bool newsync = true); protected: ios_base(); }; The class describes the storage and member functions common to both input and output streams that does not depend on the template parameters.
ios_base::event_callback typedef void *(event_callback(event ev, ios_base& iosbase, int idx); The type describes a pointer to a function that can be registered with register_callback. Such a function must not throw an exception. ios_base::failure class failure : public exception { public: explicit failure(const string& what_arg) { }; The member class serves as the base class for all exceptions thrown by the member function clear in template class basic_ios. The value returned by what() is what_arg.data().
● ● ● ● ● ● ● ● right, to pad to a field width as needed by inserting fill characters at the beginning of a generated field (right justification) scientific, to insert floating-point values in scientific format (with an exponent field) showbase, to insert a prefix that reveals the base of a generated integer field showpoint, to insert a decimal point unconditionally in a generated floating-point field showpos, to insert a plus sign in a non-negative generated numeric field skipws, to skip leading white sp
ios_base::iostate typedef T2 iostate; static const iostate badbit, eofbit, failbit, goodbit; The type is a bitmask type T2 that describes an object that can store stream state information.
ios_base::operator= ios_base& operator=(const ios_base& right); The operator copies the stored formatting information, making a new copy of any extensible arrays. It then returns *this. Note that the callback stack is not copied. ios_base::precision streamsize precision() const; streamsize precision(streamsize newprecision); The first member function returns the stored display precision. The second member function stores newprecision in the display precision and returns its previous stored value.
ios_base::setf void setf(fmtflags newfmtflags); fmtflags setf(fmtflags newfmtflags, fmtflags mask); The first member function effectively calls flags(newfmtflags | flags()) (set selected bits), then returns the previous format flags. The second member function effectively calls flags(mask & newfmtflags, flags() & ~mask) (replace selected bits under a mask), then returns the previous format flags. ios_base::streamoff typedef std::streamoff streamoff; The type is a synonym for std::streamoff.
ios_base::xalloc static int xalloc(); The static member function returns a stored static value, which it increments on each call. You can use the return value as a unique index argument when calling the member functions iword or pword. left ios_base& left(ios_base& iosbase); The manipulator effectively calls iosbase.setf(ios_base:: left, ios_base:: adjustfield), then returns iosbase. noboolalpha ios_base& noboolalpha(ios_base& iosbase); The manipulator effectively calls iosbase.
noskipws ios_base& noskipws(ios_base& iosbase); The manipulator effectively calls iosbase.unsetf(ios_base:: skipws), then returns iosbase. nounitbuf ios_base& nounitbuf(ios_base& iosbase); The manipulator effectively calls iosbase.unsetf(ios_base:: unitbuf), then returns iosbase. nouppercase ios_base& nouppercase(ios_base& iosbase); The manipulator effectively calls iosbase.unsetf(ios_base:: uppercase), then returns iosbase. oct ios_base& oct(ios_base& iosbase); The manipulator effectively calls iosbase.
showbase ios_base& showbase(ios_base& iosbase); The manipulator effectively calls iosbase.setf(ios_base:: showbase), then returns iosbase. showpoint ios_base& showpoint(ios_base& iosbase); The manipulator effectively calls iosbase.setf(ios_base:: showpoint), then returns iosbase. showpos ios_base& showpos(ios_base& iosbase); The manipulator effectively calls iosbase.setf(ios_base:: showpos), then returns iosbase. skipws ios_base& skipws(ios_base& iosbase); The manipulator effectively calls iosbase.
streamsize typedef T2 streamsize; The type is a signed integer type T3 that describes an object that can store a count of the number of elements involved in various stream operations. Its representation has at least 16 bits. It is not necessarily large enough to represent an arbitrary byte position within a stream. unitbuf ios_base& unitbuf(ios_base& iosbase); The manipulator effectively calls iosbase.setf(ios_base:: unitbuf), then returns iosbase.
Next Include the iostreams standard header to declare forward references to several template classes used throughout iostreams. All such template classes are defined in other standard headers. You include this header explicitly only when you need one of the above declarations, but not its definition.
class basic_stringstream; template > = char_traits > = char_traits > = char_traits > // char TYPE DEFINITIONS typedef basic_ios > ios; typedef basic_streambuf > streambuf; typedef basic_istream > istream
wistream; typedef basic_ostream > wostream; typedef basic_iostream > wiostream; typedef basic_stringbuf > wstringbuf; typedef basic_istringstream > wistringstream; typedef basic_ostringstream > wostringstream; typedef basic_stringstream > wstringstream; typedef basic_filebuf > wfilebuf; typedef basic_
Next Include the iostreams standard header to declare objects that control reading from and writing to the standard streams. This is often the only header you need include to perform input and output from a C++ program.
extern extern extern extern }; wistream wostream wostream wostream wcin; wcout; wcerr; wclog; cerr extern ostream cerr; The object controls unbuffered insertions to the standard error output as a byte stream. Once the object is constructed, the expression cerr.flags() & unitbuf is nonzero. cin extern istream cin; The object controls extractions from the standard input as a byte stream. Once the object is constructed, the call cin.tie() returns &cout.
wcin extern wistream wcin; The object controls extractions from the standard input as a wide stream. Once the object is constructed, the call wcin.tie() returns &wcout. wclog extern wostream wclog; The object controls buffered insertions to the standard error output as a wide stream. wcout extern wostream wcout; The object controls insertions to the standard output as a wide stream. See also the Table of Contents and the Index. Copyright © 1992-2001 by P.J. Plauger. All rights reserved.
Next Include the iostreams standard header to define template class basic_istream, which mediates extractions for the iostreams, and the template class. basic_iostream, which mediates both insertions and extractions. The header also defines a related manipulator. (This header is typically included for you by another of the iostreams headers. You seldom have occasion to include it directly.
unsigned char *str); template basic_istream& operator>>(basic_istream& istr, unsigned char& ch); // MANIPULATORS template class basic_istream& ws(basic_istream& istr); }; basic_iostream template > class basic_iostream : public basic_istream, public basic_ostream { public: explicit basic_iostream(basic_streambuf& *strbuf); virtual ~basic_iostream(); }; The template class descri
typedef typename basic_ios::off_type off_type; explicit basic_istream(basic_streambuf *strbuf); class sentry; virtual ~istream(); basic_istream& operator>>( basic_istream& (*pfn)(basic_istream&)); basic_istream& operator>>( ios_base& (*pfn)(ios_base&)); basic_istream& operator>>( basic_ios& (*pfn)(basic_ios&)); basic_istream& operator>>( basic_streambuf *strbuf); basic_istream& operator>>(bool& val); basic_istream& operator>>(short& val); basic_istream& oper
basic_istream& unget(); pos_type tellg(); basic_istream& seekg(pos_type pos); basic_istream& seekg(off_type off, ios_base::seek_dir way); int sync(); }; The template class describes an object that controls extraction of elements and encoded objects from a stream buffer with elements of type Elem, also known as char_type, whose character traits are determined by the class Tr, also known as traits_type. Most of the member functions that overload operator>> are formatted input functions.
if ((exceptions() & badbit) != 0) throw; }} setstate(state); Both groups of functions call setstate(eofbit) if they encounter end-of-file while extracting elements.
str. It always stores char_type() after any extracted elements it stores. In order of testing, extraction stops: 1. at end of file 2. after the function extracts an element that compares equal to delim, in which case the element is put back to the controlled sequence 3. after the function extracts count - 1 elements If the function extracts no elements, it calls setstate(failbit). In any case, it returns *this. The fifth function returns get(strbuf, widen('\n')).
compares equal to delim (which is also extracted). The function returns *this.
basic_istream& basic_istream& basic_istream& basic_istream& basic_istream& basic_istream& operator>>(unsigned short& val); operator>>(int& val); operator>>(unsigned int& val); operator>>(long& val); operator>>(unsigned long& val); operator>>(void *& val); each extract a field and convert it to a numeric value by calling use_facet(getloc()). get(InIt( rdbuf()), Init(0), *this, getloc(), val).
basic_istream::read basic_istream& read(char_type *str, streamsize count); The unformatted input function extracts up to count elements and stores them in the array beginning at str. Extraction stops early on end-of-file, in which case the function calls setstate(failbit). In any case, it returns *this. basic_istream::readsome streamsize readsome(char_type *str, streamsize count); The unformatted input function extracts up to count elements and stores them in the array beginning at str.
istr.setstate(failbit). In any case, the constructor stores the value returned by istr.good() in status. A later call to operator bool() delivers this stored value. basic_istream::sync int sync(); If rdbuf() is a null pointer, the function returns -1. Otherwise, it calls rdbuf()->pubsync(). If that returns -1, the function calls setstate(badbit) and returns -1. Otherwise, the function returns zero.
operator>> template basic_istream& operator>>(basic_istream basic_istream& operator>>(basic_istream basic_istream& operator>>(basic_istream basic_istream& operator>>(basic_istream basic_istream& operator>>(basic_istream basic_istream&
The template function: template basic_istream& operator>>(basic_istream& istr, signed char *str); returns istr >> (char *)str. The template function: template basic_istream& operator>>(basic_istream& istr, signed char& ch); returns istr >> (char&)ch. The template function: template basic_istream& operator>>(basic_istream& istr, unsigned char *str); returns istr >> (char *)str.
wchar_t with default character traits. ws template class basic_istream& ws(basic_istream& istr); The manipulator extracts and discards any elements ch for which use_facet< ctype >( getloc()). is( ctype::space, ch) is true. The function calls setstate(eofbit) if it encounters end-of-file while extracting elements. It returns istr. See also the Table of Contents and the Index. Copyright © 1992-2001 by P.J. Plauger. All rights reserved.
Next advance · back_insert_iterator · back_inserter · bidirectional_iterator_tag · distance · forward_iterator_tag · front_insert_iterator · front_inserter · input_iterator_tag · insert_iterator · inserter · istream_iterator · istreambuf_iterator · iterator · iterator_traits · operator!= · operator== · operator< · operator<= · operator> · operator>= · operator+ · operator- · ostream_iterator · ostreambuf_iterator · output_iterator_tag · random_access_iterator_tag · reverse_iterator Include the S
template class ostream_iterator; template class istreambuf_iterator; template class ostreambuf_iterator; // TEMPLATE FUNCTIONS template bool operator==( const reverse_iterator& left, const reverse_iterator& right); template bool operator==( const istream_iterator& left, const istream_iterator& right); template
const reverse_iterator& left, const reverse_iterator& right); template Diff operator-( const reverse_iterator& left, const reverse_iterator& right); template reverse_iterator operator+( Diff off, const reverse_iterator& right); template back_insert_iterator back_inserter(Container& cont); template front_insert_iterator front_inserter(Container& cont); template
back_insert_iterator& operator*(); back_insert_iterator& operator++(); back_insert_iterator operator++(int); protected: Container *container; }; The template class describes an output iterator object. It inserts elements into a container of type Container, which it accesses via the protected pointer object it stores called container.
back_insert_iterator::operator= back_insert_iterator& operator=(typename Container::const_reference val); The member function evaluates container. push_back(val), then returns *this. back_insert_iterator::reference typedef typename Container::reference reference; The type describes a reference to an element of the sequence controlled by the associated container.
object that can serve as a forward iterator.
front_insert_iterator::operator* front_insert_iterator& operator*(); The member function returns *this. front_insert_iterator::operator++ front_insert_iterator& operator++(); front_insert_iterator operator++(int); The member functions both return *this. front_insert_iterator::operator= front_insert_iterator& operator=(typename Container::const_reference val); The member function evaluates container. push_front(val), then returns *this.
typedef Container container_type; typedef typename Container::reference reference; insert_iterator(Container& cont, typename Container::iterator it); insert_iterator& \\ operator=(typename Container::const_reference val); insert_iterator& operator*(); insert_iterator& operator++(); insert_iterator& operator++(int); protected: Container *container; typename Container::iterator iter; }; The template class describes an output iterator object.
insert_iterator::operator* insert_iterator& operator*(); The member function returns *this. insert_iterator::operator++ insert_iterator& operator++(); insert_iterator& operator++(int); The member functions both return *this. insert_iterator::operator= insert_iterator& operator=(typename Container::const_reference val); The member function evaluates iter = container. insert(iter, val), then returns *this.
istream_iterator(istream_type& istr); const U& operator*() const; const U *operator->() const; istream_iterator& operator++(); istream_iterator operator++(int); }; The template class describes an input iterator object. It extracts objects of class Ty from an input stream, which it accesses via an object it stores, of type pointer to basic_istream.
istream_iterator::operator++ istream_iterator& operator++(); istream_iterator operator++(int); The first operator attempts to extract and store an object of type Ty from the associated input stream. The second operator makes a copy of the object, increments the object, then returns the copy. istream_iterator::traits_type typedef Tr traits_type; The type is a synonym for the template parameter Tr.
istreambuf_iterator::equal bool equal(const istreambuf_iterator& right) const; The member function returns true only if the stored stream buffer pointers for the object and right are both null pointers or are both non-null pointers. istreambuf_iterator::int_type typedef typename Tr::int_type int_type; The type is a synonym for Ty::int_type. istreambuf_iterator::istream_type typedef basic_istream istream_type; The type is a synonym for basic_istream.
istreambuf_iterator::traits_type typedef Tr traits_type; The type is a synonym for the template parameter Tr. iterator template struct iterator { typedef Category iterator_category; typedef Ty value_type; typedef Diff difference_type; typedef Pointer pointer; typedef Reference reference; }; The template class can serve as a convenient base class for an iterator class that you define.
typedef typedef typedef typedef }; Ty value_type; ptrdiff_t difference_type; const Ty *pointer; const Tr& reference; The template class determines several critical types associated with the iterator type Iter. It defines the member types iterator_category (a synonym for Iter::iterator_category), value_type (a synonym for Iter::value_type), difference_type (a synonym for Iter::difference_type), pointer (a synonym for Iter::pointer), and reference (a synonym for Iter::reference).
The template operator returns !(left == right).
The template operator returns right < left. operator>= template bool operator>=( const reverse_iterator& left, const reverse_iterator& right); The template operator returns !(left < right). operator+ template reverse_iterator operator+(Diff off, const reverse_iterator& right); The template operator returns right + off.
}; The template class describes an output iterator object. It inserts objects of class Ty into an output stream, which it accesses via an object it stores, of type pointer to basic_ostream. It also stores a pointer to a delimiter string, a null-terminated string of elements of type Elem, which is appended after each insertion. (Note that the string itself is not copied by the constructor. ostream_iterator::char_type typedef Elem char_type; The type is a synonym for the template parameter Elem.
ostream_iterator::traits_type typedef Tr traits_type; The type is a synonym for the template parameter Tr.
ostreambuf_iterator::operator++ ostreambuf_iterator& operator++(); T1 operator++(int); The first operator returns *this. The second operator returns an object of some type T1 that can be converted to ostreambuf_iterator. ostreambuf_iterator::operator= ostreambuf_iterator& operator=(Elem ch); The operator inserts ch into the associated stream buffer, then returns *this.
random_access_iterator_tag struct random_access_iterator_tag : public bidirectional_iterator_tag { }; The type is the same as iterator::iterator_category when Iter describes an object that can serve as a random-access iterator.
}; The template class describes an object that behaves like a random-access iterator, only in reverse. It stores a random-access iterator of type RanIt in the protected object current. Incrementing the object X of type reverse_iterator decrements X.current, and decrementing x increments X.current. Moreover, the expression *X evaluates to *(current - 1), of type reference. Typically, reference is type Tr&.
reverse_iterator::operator++ reverse_iterator& operator++(); reverse_iterator operator++(int); The first (preincrement) operator evaluates --current. then returns *this. The second (postincrement) operator makes a copy of *this, evaluates --current, then returns the copy. reverse_iterator::operator+= reverse_iterator& operator+=(difference_type off); The operator evaluates current - off. then returns *this.
reverse_iterator::pointer typedef typename iterator_traits::pointer pointer; The type is a synonym for the iterator trait typename iterator_traits::pointer. reverse_iterator::reference typedef typename iterator_traits::reference reference; The type is a synonym for the iterator trait typename iterator_traits::reference.
Next Include the standard header to define the template class numeric_limits. Explicit specializations of this class describe many arithmetic properties of the scalar types (other than pointers).
The enumeration describes the various methods that an implementation can choose for rounding a floating-point value to an integer value: ● round_indeterminate -- rounding method cannot be determined ● round_toward_zero -- round toward zero ● round_to_nearest -- round to nearest integer ● round_toward_infinity -- round away from zero ● round_toward_neg_infinity -- round to more negative integer numeric_limits template class numeric_limits { public: static const float_denorm_style has_denorm = deno
static static static static static }; Ty Ty Ty Ty Ty max() throw(); min() throw(); quiet_NaN() throw(); round_error() throw(); signaling_NaN() throw(); The template class describes many arithmetic properties of its parameter type Ty. The header defines explicit specializations for the types wchar_t, bool, char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, float, double, and long double.
numeric_limits::has_denorm static const float_denorm_style has_denorm = denorm_absent; The member stores denorm_present for a floating-point type that has denormalized values (effectively a variable number of exponent bits).
numeric_limits::is_bounded static const bool is_bounded = false; The member stores true for a type that has a bounded set of representable values (which is the case for all predefined types). numeric_limits::is_exact static const bool is_exact = false; The member stores true for a type that has exact representations for all its values (which is the case for all predefined integer types). A fixed-point or rational representation is also considered exact, but not a floating-point representation.
numeric_limits::is_specialized static const bool is_specialized = false; The member stores true for a type that has an explicit specialization defined for template class numeric_limits (which is the case for all scalar types other than pointers). numeric_limits::max static Ty max() throw(); The function returns the maximum finite value for the type (which is INT_MAX for type int and FLT_MAX for type float). The return value is meaningful if is_bounded is true.
numeric_limits::min_exponent10 static const int min_exponent10 = 0; The member stores the minimum negative integer such that the type can represent as a normalized value 10 raised to that power (which is the value FLT_MIN_10_EXP for type float). Meaningful only for floating-point types. numeric_limits::quiet_NaN static Ty quiet_NaN() throw(); The function returns a representation of a quiet NaN for the type. The return value is meaningful only if has_quiet_NaN is true.
numeric_limits::tinyness_before static const bool tinyness_before = false; The member stores true for a type that determines whether a value is ``tiny'' (too small to represent as a normalized value) before rounding, an option with IEC 559 floating-point representations that can affect some results. numeric_limits::traps static const bool traps = false; The member stores true for a type that generates some kind of signal to report certain arithmetic exceptions. See also the Table of Contents and the Index.
Next Include the STL standard header to define the container template class list and several supporting templates.
list allocator_type · assign · back · begin · clear · const_iterator · const_pointer · const_reference · const_reverse_iterator · difference_type · empty · end · erase · front · get_allocator · insert · iterator · list · max_size · merge · pointer · pop_back · pop_front · push_back · push_front · rbegin · reference · remove · remove_if · rend · resize · reverse · reverse_iterator · size · size_type · sort · splice · swap · unique · value_type template > class list { pub
const_iterator begin() const; iterator end(); const_iterator end() const; reverse_iterator rbegin(); const_reverse_iterator rbegin() const; reverse_iterator rend(); const_reverse_iterator rend() const; void resize(size_type newsize); void resize(size_type newsize, Ty val); size_type size() const; size_type max_size() const; bool empty() const; Alloc get_allocator() const; reference front(); const_reference front() const; reference back(); const_reference back() const; void push_front(const Ty& val); void po
template void unique(Pr2 pred); void merge(list& right); template void merge(list& right, Pr3 pred); void sort(); template void sort(Pr3 pred); void reverse(); }; The template class describes an object that controls a varying-length sequence of elements of type Ty. The sequence is stored as a bidirectional linked list of elements, each containing a member of type Ty.
list::back reference back(); const_reference back() const; The member function returns a reference to the last element of the controlled sequence, which must be non-empty. list::begin const_iterator begin() const; iterator begin(); The member function returns a bidirectional iterator that points at the first element of the sequence (or just beyond the end of an empty sequence). list::clear void clear(); The member function calls erase( begin(), end()).
list::const_reverse_iterator typedef reverse_iterator const_reverse_iterator; The type describes an object that can serve as a constant reverse bidirectional iterator for the controlled sequence. list::difference_type typedef T3 difference_type; The signed integer type describes an object that can represent the difference between the addresses of any two elements in the controlled sequence. It is described here as a synonym for the implementation-defined type T3.
list::front reference front(); const_reference front() const; The member function returns a reference to the first element of the controlled sequence, which must be non-empty. list::get_allocator Alloc get_allocator() const; The member function returns the stored allocator object.
list::list list(); explicit list(const Alloc& al); explicit list(size_type count); list(size_type count, const Ty& val); list(size_type count, const Ty& val, const Alloc& al); list(const list& right); template list(InIt first, InIt last); template list(InIt first, InIt last, const Alloc& al); All constructors store an allocator object and initialize the controlled sequence. The allocator object is the argument al, if present. For the copy constructor, it is right.get_allocator().
No pairs of elements in the original controlled sequence are reversed in the resulting controlled sequence. If a pair of elements in the resulting controlled sequence has equivalent ordering (!(*Pi < *Pj) && !(*Pj < *Pi)), an element from the original controlled sequence appears before an element from the sequence controlled by right. An exception occurs only if pred throws an exception. In that case, the controlled sequence is left in unspecified order and the exception is rethrown.
If an exception is thrown, the container is left unaltered and the exception is rethrown. list::rbegin const_reverse_iterator rbegin() const; reverse_iterator rbegin(); The member function returns a reverse bidirectional iterator that points just beyond the end of the controlled sequence. Hence, it designates the beginning of the reverse sequence.
list::resize void resize(size_type newsize); void resize(size_type newsize, Ty val); The member functions both ensure that size() henceforth returns newsize. If it must make the controlled sequence longer, the first member function appends elements with value Ty(), while the second member function appends elements with value val. To make the controlled sequence shorter, both member functions call erase(begin() + newsize, end()).
imposes the order !(*Pj < *Pi) whenever I < J. (The elements are sorted in ascending order.) The member template function imposes the order !pred(*Pj, *Pi) whenever I < J. No ordered pairs of elements in the original controlled sequence are reversed in the resulting controlled sequence. (The sort is stable.) An exception occurs only if pred throws an exception. In that case, the controlled sequence is left in unspecified order and the exception is rethrown.
list::unique void unique(); template void unique(Pr2 pred); The first member function removes from the controlled sequence every element that compares equal to its preceding element. For the iterators Pi and Pj designating elements at positions I and J, the second member function removes every element for which I + 1 == J && pred(*Pi, *Pj). For a controlled sequence of length N (> 0), the predicate pred(*Pi, *Pj) is evaluated N 1 times. An exception occurs only if pred throws an exception.
operator< template bool operator<( const list & left, const list & right); The template function overloads operator< to compare two objects of template class list. The function returns lexicographical_compare(left. begin(), left. end(), right.begin(), right.end()). operator<= template bool operator<=( const list & left, const list & right); The template function returns !(right < left).
list & right); The template function executes left.swap(right). See also the Table of Contents and the Index. Copyright © 1994-2001 by P.J. Plauger. Portions derived from work copyright © 1994 by Hewlett-Packard Company. All rights reserved.
Next codecvt · codecvt_base · codecvt_byname · collate · collate_byname · ctype · ctype · ctype_base · ctype_byname · has_facet · locale · messages · messages_base · messages_byname · money_base · money_get · money_put · moneypunct · moneypunct_byname · num_get · num_put · numpunct · numpunct_byname · time_base · time_get · time_get_byname · time_put · time_put_byname · use_facet isalnum · isalpha · iscntrl · isdigit · isgraph · islower · isprint · ispunct · isspace · isupper · isxdigit · to
class money_base; template class money_get; template class money_put; template class moneypunct; template class moneypunct_byname; class messages_base; template class messages; template class messages_byname; // TEMPLATE FUNCTIONS template bool has_facet(const locale& loc); template const Facet& use_facet(const locale& loc); template
: public locale::facet, codecvt_base { public: typedef Elem intern_type; typedef Byte extern_type; typedef Statype state_type; explicit codecvt(size_t refs = 0); result in(Statype& state, const Byte *first1, const Byte *last1, const Byte *next1, Elem *first2, Elem *last2, Elem *next2); result out(Statype& state, const Elem *first1, const Elem *last1, const Elem *next1, Byte *first2, Byte *last2, Byte *next2); result unshift(Statype& state, Byte *first2, Byte *last2, Byte *next2); bool always_noconv() const
which converts between wchar_t and char sequences. codecvt::always_noconv bool always_noconv() const throw(); The member function returns do_always_noconv(). codecvt::codecvt explicit codecvt(size_t refs = 0); The constructor initializes its locale::facet base object with locale::facet(refs). codecvt::do_always_noconv virtual bool do_always_noconv() const throw(); The protected virtual member function returns true only if every call to do_in or do_out returns noconv.
codecvt::do_length virtual int do_length(const Statype state&, const Byte *first1, const Byte *last1, size_t len2) const throw(); The protected virtual member function effectively calls do_in(mystate, first1, last1, next1, buf, buf + len2, next2) for mystate a copy of state, some buffer buf, and pointers next1 and next2. It then returns next2 - buf. (Thus, it counts the maximum number of conversions, not greater than len2, defined by the source sequence at [first1, last1).
stored value, as needed, to reflect the current state of a successful conversion. Typically, converting the source element Elem(0) leaves the current state in the initial conversion state.
The member function returns do_out(state, first1, last1, next1, first2, last2, next2). codecvt::state_type typedef Statype state_type; The type is a synonym for the template parameter Statype. codecvt::unshift result unshift(Statype state&, Byte *first2, Byte *last2, Byte *next2); The member function returns do_unshift(state, first2, last2, next2).
int compare(const Elem *first1, const Elem *last1, const Elem *first2, const Elem *last2) const; string_type transform(const Elem *first, const Elem *last) const; long hash(const Elem *first, const Elem *last) const; static locale::id id; protected: ~collate(); virtual int do_compare(const Elem *first1, const Elem *last1, const Elem *first2, const Elem *last2) const; virtual string_type do_transform(const Elem *first, const Elem *last) const; virtual long do_hash(const Elem *first, const Elem *last) const;
collate::do_hash virtual long do_hash(const Elem *first, const Elem *last) const; The protected virtual member function returns an integer derived from the values of the elements in the sequence [first, last). Such a hash value can be useful, for example, in distributing sequences pseudo randomly across an array of lists.
ctype char_type · ctype · do_is · do_narrow · do_scan_is · do_scan_not · do_tolower · do_toupper · do_widen · is · narrow · scan_is · scan_not · tolower · toupper · widen template class ctype : public locale::facet, public ctype_base { public: typedef Elem char_type; explicit ctype(size_t refs = 0); bool is(mask maskval, Elem ch) const; const Elem *is(const Elem *first, const Elem *last, mask *dest) const; const Elem *scan_is(mask maskval, const Elem *first, const Elem *last) const; const Elem *
The template class describes an object that can serve as a locale facet, to characterize various properties of a ``character'' (element) of type Elem. Such a facet also converts between sequences of Elem elements and sequences of char. As with any locale facet, the static object id has an initial stored value of zero. The first attempt to access its stored value stores a unique positive value in id.
The protected member function returns the smallest pointer ptr in the range [first, last) for which do_is(maskval, *ptr) is true. If no such value exists, the function returns last. ctype::do_scan_not virtual const Elem *do_scan_not(mask maskval, const Elem *first, const Elem *last) const; The protected member function returns the smallest pointer ptr in the range [first, last) for which do_is(maskval, *ptr) is false. If no such value exists, the function returns last.
The first member function returns do_narrow(ch, dflt). The second member function returns do_narrow(first, last, dflt, dest). ctype::scan_is const Elem *scan_is(mask maskval, const Elem *first, const Elem *last) const; The member function returns do_scan_is(maskval, first, last). ctype::scan_not const Elem *scan_not(mask maskval, const Elem *first, const Elem *last) const; The member function returns do_scan_not(maskval, first, last).
const char *first, const char *last) const; char toupper(char ch) const; const char *toupper(char *first, char *last) const; char tolower(char ch) const; const char *tolower(char *first, char *last) const; char widen(char byte) const; const char *widen(char *first, char *last, char *dest) const; char narrow(char ch, char dflt) const; const char *narrow(const char *first, const char *last, char dflt, char *dest) const; static locale::id id; protected: ~ctype(); virtual char do_toupper(char ch) const; virtual
ctype_base class ctype_base { public: enum mask { space = 1 << 0, // EXAMPLE VALUES ONLY print = 1 << 1, cntrl = 1 << 2, upper = 1 << 3, lower = 1 << 4, digit = 1 << 5, punct = 1 << 6, xdigit = 1 << 7, alpha = 1 << 8, alnum = 0x9 << 5, graph = 0xB << 5}; The class serves as a base class for facets of template class ctype. It defines just the enumeration mask.
has_facet template bool has_facet(const locale& loc); The template function returns true if a locale facet of class Facet is listed within the locale object loc. isalnum template bool isalnum(Elem ch, const locale& loc) const; The template function returns use_facet< ctype >(loc). is(ctype:: alnum, ch). isalpha template bool isalpha(Elem ch, const locale& loc) const; The template function returns use_facet< ctype >(loc). is(ctype:: alpha, ch).
isprint template bool isprint(Elem ch, const locale& loc) const; The template function returns use_facet< ctype >(loc). is(ctype:: print, ch). ispunct template bool ispunct(Elem ch, const locale& loc) const; The template function returns use_facet< ctype >(loc). is(ctype:: punct, ch). isspace template bool isspace(Elem ch, const locale& loc) const; The template function returns use_facet< ctype >(loc). is(ctype:: space, ch).
locale(const locale& loc, const char *locname, category cat); template locale(const locale& loc, Facet *fac); template locale combine(const locale& loc) const; template bool operator()(const basic_string& left, const basic_string& right) const; string name() const; bool operator==(const locale& right) const; bool operator!=(const locale& right) const; static locale global(const locale& right); static const locale&
time_get > time_put > time_put > Category messages (LC_MESSAGES) includes the facets: messages messages (The last category is required by Posix, but not the C Standard.) Some of these predefined facets are used by the iostreams classes, to control the conversion of numeric values to and from text sequences.
locale::classic static const locale& classic(); The static member function returns a locale object that represents the classic locale, which behaves the same as the C locale within the Standard C library. locale::combine template locale combine(const locale& loc) const; The member function returns a locale object that replaces in (or adds to) *this the facet Facet listed in loc.
locale::locale locale(); explicit locale(const char *locname); locale(const locale& loc, const locale& other, category cat); locale(const locale& loc, const char *locname, category cat); template locale(const locale& loc, Facet *fac); The first constructor initializes the object to match the global locale. The second constructor initializes all the locale categories to have behavior consistent with the locale name locname.
messages template class messages : public locale::facet, public messages_base { public: typedef Elem char_type; typedef basic_string string_type; explicit messages(size_t refs = 0); catalog open(const string& catname, const locale& loc) const; string_type get(catalog catval, int set, int message, const string_type& dflt) const; void close(catalog catval) const; static locale::id id; protected: ~messages(); virtual catalog do_open(const string& catname, const locale& loc) const; virtual str
make use of set, message, and dflt in doing so. It returns a copy of dflt on failure. Otherwise, it returns a copy of the specified message sequence. messages::do_open virtual catalog do_open(const string& catname, const locale& loc) const; The protected member function endeavors to open a message catalog whose name is catname. It may make use of the locale loc in doing so. It returns a value that compares less than zero on failure.
~messages_byname(); }; The template class describes an object that can serve as a locale facet of type messages. Its behavior is determined by the named locale locname. The constructor initializes its base object with messages(refs). money_base class money_base { enum part {none, sign, space, symbol, value}; struct pattern { char field[4]; }; }; The class describes an enumeration and a structure common to all specializations of template class moneypunct.
to monetary values. As with any locale facet, the static object id has an initial stored value of zero. The first attempt to access its stored value stores a unique positive value in id. money_get::char_type typedef Elem char_type; The type is a synonym for the template parameter Elem.
grouping constraints imposed by fac.grouping() is enforced. Note that the resulting digit sequence represents an integer whose low-order fac.frac_digits() decimal digits are considered to the right of the decimal point. Arbitrary white space is matched where the element equal to money_base::space appears in the format pattern, if it appears other than at the end of the format pattern. Otherwise, no internal white space is matched. An element ch is considered white space if use_facet >(iosbase.
virtual iter_type do_put(iter_type next, bool intl, ios_base& iosbase, Elem fill, string_type& val) const; virtual iter_type do_put(iter_type next, bool intl, ios_base& iosbase, Elem fill, long double& val) const; }; The template class describes an object that can serve as a locale facet, to control conversions of monetary values to sequences of type Elem. As with any locale facet, the static object id has an initial stored value of zero.
instances of fac.thousands_sep() are generated in the value portion of the monetary output field (where the element equal to money_base::value appears in the format pattern). If fac.frac_digits() is zero, then no instance of fac.decimal_point() is generated after the decimal digits. Otherwise, the resulting monetary output field places the low-order fac.frac_digits() decimal digits to the right of the decimal point. Padding occurs as for any numeric output field, except that if iosbase.flags() & iosbase.
explicit moneypunct(size_t refs = 0); Elem decimal_point() const; Elem thousands_sep() const; string grouping() const; string_type curr_symbol() const; string_type positive_sign() const; string_type negative_sign() const; int frac_digits() const; pattern pos_format( oonst; pattern neg_format() const; static const bool intl = Intl; static locale::id id; protected: ~moneypunct(); virtual Elem do_decimal_point() const; virtual Elem do_thousands_sep() const; virtual string do_grouping() const; virtual string_ty
moneypunct::do_curr_symbol string_type do_curr_symbol() const; The protected virtual member function returns a locale-specific sequence of elements to use as a currency symbol. moneypunct::do_decimal_point Elem do_decimal_point() const; The protected virtual member function returns a locale-specific element to use as a decimal-point.
field for a positive amount. (It also determines how to match the components of a monetary input field.) The encoding is the same as for do_neg_format. The template version of moneypunct returns {money_base::symbol, money_base::sign, money_base::value, money_base::none}. moneypunct::do_positive_sign string_type do_positive_sign() const; The protected virtual member function returns a locale-specific sequence of elements to use as a positive sign.
moneypunct::positive_sign string_type positive_sign() const; The member function returns do_positive_sign(). moneypunct::string_type typedef basic_string string_type; The type describes a specialization of template class basic_string whose objects can store copies of the punctuation sequences. moneypunct::thousands_sep Elem thousands_sep() const; The member function returns do_thousands_sep().
long double& val) const; iter_type get(iter_type first, iter_type last, ios_base& iosbase, ios_base::iostate& state, void *& val) const; iter_type get(iter_type first, iter_type last, ios_base& iosbase, ios_base::iostate& state, bool& val) const; static locale::id id; protected: ~num_get(); virtual iter_type do_get(iter_type first, iter_type last, ios_base& iosbase, ios_base::iostate& state, long& val) const; virtual iter_type do_get(iter_type first, iter_type last, ios_base& iosbase, ios_base::iostate& sta
virtual iter_type do_get(iter_type first, ios_base& iosbase, ios_base::iostate& double& val) const; virtual iter_type do_get(iter_type first, ios_base& iosbase, ios_base::iostate& long double& val) const; virtual iter_type do_get(iter_type first, ios_base& iosbase, ios_base::iostate& void *& val) const; virtual iter_type do_get(iter_type first, ios_base& iosbase, ios_base::iostate& bool& val) const; iter_type last, state, iter_type last, state, iter_type last, state, iter_type last, state, The first virtu
The fourth virtual protected member function: virtual iter_type do_get(iter_type first, iter_type last, ios_base& iosbase, ios_base::iostate& state, long double& val) const; behaves the same the third, except that the equivalent scan conversion specifier is Lf.
num_get::num_get explicit num_get(size_t refs = 0); The constructor initializes its base object with locale::facet(refs).
num_put::do_put virtual iter_type do_put(iter_type next, Elem fill, long val) const; virtual iter_type do_put(iter_type next, Elem fill, unsigned long val) const; virtual iter_type do_put(iter_type next, Elem fill, double val) const; virtual iter_type do_put(iter_type nextp Elem fill, long double val) const; virtual iter_type do_put(iter_type nextp Elem fill, const void *val) const; virtual iter_type do_put(iter_type next, Elem fill, bool val) const; ios_base& iosbase, ios_base& iosbase, ios_base& iosbase,
instances of fac.thousands_sep() are generated in the output field. Otherwise, separators are inserted after the print conversion occurs. The second virtual protected member function: virtual iter_type do_put(iter_type next, ios_base& iosbase, Elem fill, unsigned long val) const; behaves the same as the first, except that it replaces a conversion specification of ld with lu.
num_put::put iter_type put(iter_type next, ios_base& iosbase, Elem fill, long val) const; iter_type put(iter_type next, ios_base& iosbase, Elem fill, unsigned long val) const; iter_type put(iter_type iter_type next, ios_base& iosbase, Elem fill, double val) const; iter_type put(iter_type next, ios_base& iosbase, Elem fill, long double val) const; iter_type put(iter_type next, ios_base& iosbase, Elem fill, const void *val) const; iter_type put(iter_type next, ios_base& iosbase, Elem fill, bool val) const; Al
}; The template class describes an object that can serve as a locale facet, to desceibe the sequences of type Elem used to represent the input fields matched by num_get or the output fields generated by num_get. As with any locale facet, the static object id has an initial stored value of zero. The first attempt to access its stored value stores a unique positive value in id. numpunct::char_type typedef Elem char_type; The type is a synonym for the template parameter Elem.
numpunct::grouping string grouping() const; The member function returns do_grouping(). numpunct::numpunct explicit numpunct(size_t refs = 0); The constructor initializes its base object with locale::facet(refs). numpunct::string_type typedef basic_string string_type; The type describes a specialization of template class basic_string whose objects can store copies of the punctuation sequences. numpunct::thousands_sep Elem thousands_sep() const; The mmmber function returns do_thousands_sep().
● ● ● ● ● no_order specifies no particular order. dmy specifies the order day, month, then year, as in 2 December 1979. mdy specifies the order month, day, then year, as in December 2, 1979. ymd specifies the order year, month, then day, as in 1979/12/2. ydm specifies the order year, day, then month, as in 1979: 2 Dec.
time_get::char_type typedef Elem char_type; The type is a synonym for the template parameter Elem. time_get::date_order dateorder date_order() const; The member function returns date_order(). time_get::do_date_order virtual dateorder do_date_order() const; The virtual protected member function returns a value of type time_base::dateorder, which describes the order in which date components are matched by do_get_date.
The month input field is a sequence that matches the longest of a set of locale-specific sequences, such as: Jan, January, Feb, February, etc. The converted value is the number of months since January.
range of years [1969, 2036). Values in the range [0, 69) are also permissible, but may represent either the range of years [1900, 1969) or [2000, 2069), depending on the specific translation environment. time_get::get_date iter_type get_date(iter_type first, iter_type last, ios_base& iosbase, ios_base::iostate& state, tm *pt) const; The member function returns do_get_date(first, last, iosbase, state, pt).
protected: ~time_get_byname(); }; The template class describes an object that can serve as a locale facet of type time_get. Its behavior is determined by the named locale locname. The constructor initializes its base object with time_get(refs).
time_put::put iter_type put(iter_type next, ios_base& iosbase, char_type fill, const tm *pt, char fmt, char mod = 0) const; iter_type put(iter_type next, ios_base& iosbase, char_type fill, const tm *pt, const Elem *first, const Elem *last) const; The first member function returns do_put(next, iosbase, fill, pt, fmt, mod). The second member function copies to *next++ any element in the interval [first, last) other than a percent (%).
use_facet template const Facet& use_facet(const locale& loc); The template function returns a reference to the locale facet of class Facet listed within the locale object loc. If no such object is listed, the function throws an object of class bad_cast. See also the Table of Contents and the Index. Copyright © 1992-2001 by P.J. Plauger. All rights reserved.
Next
const map& right); template bool operator>( const multimap& left, const multimap& right); template bool operator<=( const map& left, const map& right); template bool operator<=( const multimap& left, const multimap& right); template
template, class Alloc = allocator > > class map { public: typedef Key key_type; typedef Ty mapped_type; typedef Pr key_compare; typedef Alloc allocator_type; typedef pair value_type; class value_compare; typedef Alloc::pointer pointer; typedef Alloc::const_pointer const_pointer; typedef Alloc::reference reference; typedef Alloc::const_reference const_reference; typedef T0 iterator; typedef T1 const_iterator; typedef T2 size_type; t
const_reverse_iterator rend() const; size_type size() const; size_type max_size() const; bool empty() const; Alloc get_allocator() const; mapped_type operator[](const Key& keyval); pair insert(const value_type& val); iterator insert(iterator where, const value_type& val); template void insert(InIt first, InIt last); iterator erase(iterator where); iterator erase(iterator first, iterator last); size_type erase(const Key& keyval); void clear(); void swap(map& right); key_compare ke
object of template class map ensures that key_comp()(X.first, Y.first) is true. (Each key is unique.) The object allocates and frees storage for the sequence it controls through a stored allocator object of class Alloc. Such an allocator object must have the same external interface as an object of template class allocator. Note that the stored allocator object is not copied when the container object is assigned.
controlled sequence. map::const_reverse_iterator typedef reverse_iterator const_reverse_iterator; The type describes an object that can serve as a constant reverse bidirectional iterator for the controlled sequence. map::count size_type count(const Key& keyval) const; The member function returns the number of elements in the range [lower_bound(keyval), upper_bound(keyval)).
lower_bound(keyval) and X.second == upper_bound(keyval). map::erase iterator erase(iterator where); iterator erase(iterator first, iterator last); size_type erase(const Key& keyval); The first member function removes the element of the controlled sequence pointed to by where. The second member function removes the elements in the interval [first, last). Both return an iterator that designates the first element remaining beyond any elements removed, or end() if no such element exists.
The second member function returns insert(val).first, using where as a starting place within the controlled sequence to search for the insertion point. (Insertion can occur in amortized constant time, instead of logarithmic time, if the insertion point immediately precedes or follows where.) The third member function inserts the sequence of element values, for each where in the range [first, last), by calling insert(*where).
sequence for which key_comp()(X. first, keyval) is false. If no such element exists, the function returns end(). map::map map(); explicit map(const Pr& pred); map(const Pr& pred, const Alloc& al); map(const map& right); template map(InIt first, InIt last); template map(InIt first, InIt last, const Pr& pred); template map(InIt first, InIt last, const Pr& pred, const Alloc& al); All constructors store an allocator object and initialize the controlled sequence.
map::operator[] Ty& operator[](const Key& keyval); The member function determines the iterator where as the return value of insert( value_type(keyval, Ty()). (It inserts an element with the specified key if no such element exists.) It then returns a reference to (*where).second. map::pointer typedef Alloc::pointer pointer; The type describes an object that can serve as a pointer to an element of the controlled sequence.
map::size size_type size() const; The member function returns the length of the controlled sequence. map::size_type typedef T2 size_type; The unsigned integer type describes an object that can represent the length of any controlled sequence. It is described here as a synonym for the implementation-defined type T2. map::swap void swap(map& right); The member function swaps the controlled sequences between *this and right. If get_allocator() == right.
bool operator()(const value_type& left, const value_type& right) const {return (comp(left.first, right.first)); } protected: value_compare(key_compare pr) : comp(pr) {} key_compare comp; }; The type describes a function object that can compare the sort keys in two elements to determine their relative order in the controlled sequence. The function object stores an object comp of type key_compare. The member function operator() uses this object to compare the sort-key components of two element.
typedef Alloc::const_reference const_reference; typedef T0 iterator; typedef T1 const_iterator; typedef T2 size_type; typedef T3 difference_type; typedef reverse_iterator const_reverse_iterator; typedef reverse_iterator reverse_iterator; multimap(); explicit multimap(const Pr& pred); multimap(const Pr& pred, const Alloc& al); multimap(const multimap& right); template multimap(InIt first, InIt last); template multimap(InIt first, InIt last, const Pr& pred); t
void swap(multimap& right); key_compare key_comp() const; value_compare value_comp() const; iterator find(const Key& keyval); const_iterator find(const Key& keyval) const; size_type count(const Key& keyval) const; iterator lower_bound(const Key& keyval); const_iterator lower_bound(const Key& keyval) const; iterator upper_bound(const Key& keyval); const_iterator upper_bound(const Key& keyval) const; pair equal_range(const Key& keyval); pair equal_range(cons
multimap::begin const_iterator begin() const; iterator begin(); The member function returns a bidirectional iterator that points at the first element of the sequence (or just beyond the end of an empty sequence). multimap::clear void clear(); The member function calls erase( begin(), end()). multimap::const_iterator typedef T1 const_iterator; The type describes an object that can serve as a constant bidirectional iterator for the controlled sequence.
multimap::count size_type count(const Key& keyval) const; The member function returns the number of elements in the range [lower_bound(keyval), upper_bound(keyval)). multimap::difference_type typedef T3 difference_type; The signed integer type describes an object that can represent the difference between the addresses of any two elements in the controlled sequence. It is described here as a synonym for the implementation-defined type T3.
Both return an iterator that designates the first element remaining beyond any elements removed, or end() if no such element exists. The third member removes the elements with sort keys in the range [lower_bound(keyval), upper_bound(keyval)). It returns the number of elements it removes. The member functions never throw an exception.
multimap::iterator typedef T0 iterator; The type describes an object that can serve as a bidirectional iterator for the controlled sequence. It is described here as a synonym for the implementation-defined type T0. multimap::key_comp key_compare key_comp() const; The member function returns the stored function object that determines the order of elements in the controlled sequence.
multimap::max_size size_type max_size() const; The member function returns the length of the longest sequence that the object can control.
the controlled sequence. Hence, it designates the beginning of the reverse sequence. multimap::reference typedef Alloc::reference reference; The type describes an object that can serve as a reference to an element of the controlled sequence. multimap::rend const_reverse_iterator rend() const; reverse_iterator rend(); The member function returns a reverse bidirectional iterator that points at the first element of the sequence (or just beyond the end of an empty sequence).
proportional to the number of elements in the two controlled sequences. multimap::upper_bound iterator upper_bound(const Key& keyval); const_iterator upper_bound(const Key& keyval) const; The member function returns an iterator that designates the earliest element right in the controlled sequence for which key_comp()(keyval, right.first) is true. If no such element exists, the function returns end().
operator!= template bool operator!=( const map & left, const map & right); template bool operator!=( const multimap & left, const multimap & right); The template function returns !(left == right).
begin(), left. end(), right.begin(), right.end(), left.value_comp()). operator<= template bool operator<=( const map & left, const map & right); template bool operator<=( const multimap & left, const multimap & right); The template function returns !(right < left).
swap template void swap( map & left, map & right); template void swap( multimap & left, multimap & right); The template function executes left.swap(right). See also the Table of Contents and the Index. Copyright © 1994-2001 by P.J. Plauger. Portions derived from work copyright © 1994 by Hewlett-Packard Company. All rights reserved.
Next Include the STL standard header to define a class, an operator, and several templates that help allocate and free objects.
}; allocator template class allocator { typedef size_t size_type; typedef ptrdiff_t difference_type; typedef Ty *pointer; typedef const Ty *const_pointer; typedef Ty& reference; typedef const Ty& const_reference; typedef Ty value_type; pointer address(reference val) const; const_pointer address(const_reference val) const; template struct rebind; allocator(); template allocator(const allocator& right); template allocator& operator=(const allocator
collection. Hence, a class that allocates storage using an allocator object should use these types religiously for declaring pointer and reference objects (as do the containers in the Standard C++ library).
allocator::const_pointer typedef const Ty *pointer; The pointer type describes an object ptr that can designate, via the expression *ptr, any const object that an object of template class allocator can allocate. allocator::const_reference typedef const Ty& const_reference; The reference type describes an object that can designate any const object that an object of template class allocator can allocate.
allocator::max_size size_type max_size() const; The member function returns the length of the longest sequence of elements of type Ty that an object of class allocator might be able to allocate. allocator::operator= template allocator& operator=(const allocator& right); The template assignment operator does nothing.
allocator::size_type typedef size_t size_type; The unsigned integer type describes an object that can represent the length of any sequence that an object of template class allocator can allocate. allocator::value_type typedef Ty value_type; The type is a synonym for the template parameter Ty.
~auto_ptr(); template operator auto_ptr() throw(); template operator auto_ptr_ref() throw(); template auto_ptr& operator=(auto_ptr& right) throw(); auto_ptr& operator=(auto_ptr& right) throw(); Ty& operator*() const throw(); Ty *operator->() const throw(); Ty *get() const throw(); Ty *release() const throw(); void reset(Ty *ptr = 0); }; The class describes an object that stores a pointer to an allocated object myptr of type Ty *.
auto_ptr::~auto_ptr ~auto_ptr(); The destructor evaluates the expression delete myptr to delete the object designated by the stored pointer. auto_ptr::element_type typedef Ty element_type; The type is a synonym for the template parameter Ty. auto_ptr::get Ty *get() const throw(); The member function returns the stored pointer myptr.
auto_ptr::operator auto_ptr template operator auto_ptr() throw(); The type cast operator returns auto_ptr(*this). auto_ptr::operator auto_ptr_ref template operator auto_ptr_ref() throw(); The type cast operator returns auto_ptr_ref(*this). auto_ptr::release Ty *release() throw(); The member replaces the stored pointer myptr with a null pointer and returns the previously stored pointer.
from an unspecified source (which may well be the standard heap used by operator new). It returns a value pr, of type pair. If the function allocates storage, pr.first designates the allocated storage and pr.second is the number of elements in the longest sequence the storage can hold. Otherwise, pr.first is a null pointer.
explicit raw_storage_iterator(FwdIt first); raw_storage_iterator& operator*(); raw_storage_iterator& operator=(const Ty& val); raw_storage_iterator& operator++(); raw_storage_iterator operator++(int); }; The class describes an output iterator that constructs objects of type Ty in the sequence it generates.
The first (preincrement) operator increments the stored output iterator object, then returns *this. The second (postincrement) operator makes a copy of *this, increments the stored output iterator object, then returns the copy. raw_storage_iterator::raw_storage_iterator explicit raw_storage_iterator(FwdIt first); The constructor stores first as the output iterator object.
unless the code throws an exception. In that case, all constructed objects are destroyed and the exception is rethrown. uninitialized_fill_n template void uninitialized_fill_n(FwdIt first, Size count, const Ty& val); The template function effectively executes: while (0 < count--) new ((void *)&*first++) iterator_traits::value_type(val); unless the code throws an exception. In that case, all constructed objects are destroyed and the exception is rethrown.
Next Include the standard header to define several types and functions that control allocation and freeing of storage under program control. Some of the functions declared in this header are replaceable. The implementation supplies a default version, whose behavior is described in this document. A program can, however, define a function with the same signature to replace the default version at link time. The replacement version must satisfy the requirements described in this document.
bad_alloc class bad_alloc : public exception { }; The class describes an exception thrown to indicate that an allocation request did not succeed. The value returned by what() is an implementation-defined C string. None of the member functions throw any exceptions. new_handler typedef void (*new_handler)(); The type points to a function suitable for use as a new handler. nothrow extern const nothrow_t nothrow; The object is used as a function argument to match the parameter type nothrow_t.
The third function is called by a placement delete expression corresponding to a new expression of the form new(std::size_t, const std::nothrow_t&). The program can define a function with this function signature that replaces the default version defined by the Standard C++ library. The required behavior is to accept a value of ptr that is null or that was returned by an earlier call to operator new(size_t). The default behavior is to evaluate delete(ptr).
contiguity of storage allocated by successive calls is unspecified. The initial stored value is unspecified. The returned pointer points to the start (lowest byte address) of the allocated storage. If count is zero, the value returned does not compare equal to any other value returned by the function. The default behavior is to execute a loop. Within the loop, the function first attempts to allocate the requested storage. Whether the attempt involves a call to malloc(size_t) is unspecified.
The required behavior is the same as for operator new(size_t). The default behavior is to return operator new(count). The second function is called by a placement new[] expression to allocate count bytes of storage suitably aligned to represent any array object of that size. The program can define a function with this function signature that replaces the default version defined by the Standard C++ library. The default behavior is to return operator new(count) if that function succeeds.
New Include the STL standard header to define several template functions useful for computing numeric values. The descriptions of these templates employ a number of conventions common to all algorithms.
The first template function repeatedly replaces val with val + *I, for each value of the InIt iterator I in the interval [first, last). It then returns val. The second template function repeatedly replaces val with func(val, *I), for each value of the InIt iterator I in the interval [first, last). It then returns val.
partial_sum template OutIt partial_sum(InIt first, InIt last, OutIt result); template OutIt partial_sum(InIt first, InIt last, OutIt result, Fn2 func); The first template function stores successive values beginning at result, for each value of the InIt iterator I in the interval [first, last). The first value val stored (if any) is *I. Each subsequent value val stored is val + *I. The function returns result incremented last - first times.
Next namespace std { template > class basic_ostream; typedef basic_ostream > ostream; typedef basic_ostream > wostream; // INSERTERS template basic_ostream& operator<<(basic_ostream basic_ostream& operator<<(basic_ostream basic_ostream& operator<<(basi
basic_ostream& operator<<(basic_ostream& ostr, signed char ch); template basic_ostream& operator<<(basic_ostream& ostr, const unsigned char *str); template basic_ostream& operator<<(basic_ostream& ostr, unsigned char ch); // MANIPULATORS template class basic_ostream& endl(basic_ostream& ostr); template class basic_ostream& ends(basic_ostream& ostr); template class
explicit basic_ostream(basic_streambuf *strbuf); class sentry; virtual ~ostream(); basic_ostream& operator<<( basic_ostream& (*pfn)(basic_ostream&)); basic_ostream& operator<<( ios_base;& (*pfn)(ios_base&)); basic_ostream& operator<<( basic_ios& (*pfn)(basic_ios&)); basic_ostream& operator<<( basic_streambuf *strbuf); basic_ostream& operator<<(bool val); basic_ostream& operator<<(short val); basic_ostream& operator<<(unsigned short val); basic_ostream& operator<<(int
catch (...) {try {setstate(badbit); } catch (...) {} if ((exceptions() & badbit) != 0) throw; }} width(0); // except for operator<<(Elem) setstate(state); return (*this); Two other member functions are unformatted output functions. They follow the pattern: iostate state = goodbit; const sentry ok(*this); if (!ok) state |= badbit; else {try { } catch (...) {try {setstate(badbit); } catch (...
the function calls setstate(badbit). It returns *this.
basic_ostream& basic_ostream& basic_ostream& basic_ostream& basic_ostream& basic_ostream& basic_ostream& operator<<(short val); operator<<(unsigned short val); operator<<(int val); operator<<(unsigned int val); operator<<(long val); operator<<(unsigned long val); operator<<(const void *val); each convert val to a numeric field and insert it by calling use_facet(getloc()). put(OutIt( rdbuf()), *this, getloc(), val). Here, OutIt is defined as ostreambuf_iterator.
operator bool() const; ~sentry(); private: sentry(const sentry&); // not defined sentry& operator=(const sentry&); // not defined bool status; }; The nested class describes an object whose declaration structures the formatted output functions and the unformatted output functions. If ostr.good() is true, and ostr.tie() is not a null pointer, the constructor calls ostr.tie->flush(). The constructor then stores the value returned by ostr.good() in status.
flush template class basic_ostream& flush(basic_ostream& ostr); The manipulator calls ostr.flush(). It returns ostr.
const unsigned char *str); template basic_ostream& operator<<(basic_ostream& ostr, unsigned char ch); The template function: template basic_ostream& operator<<(basic_ostream& ostr, const Elem *str); determines the length N = traits_type::length(str) of the sequence beginning at str, and inserts the sequence. If N < ostr.width(), then the function also inserts a repetition of ostr.width() - N fill characters.
char ch); behaves the same as: template basic_ostream& operator<<(basic_ostream& ostr, Elem ch); except that ch is converted to an object of type Elem by calling ostr.put(ostr. widen(ch)).
template basic_ostream& operator<<(basic_ostream& ostr, signed char ch); returns ostr << (char)ch. The template function: template basic_ostream& operator<<(basic_ostream& ostr, const unsigned char *str); returns ostr << (const char *)str. The template function: template basic_ostream& operator<<(basic_ostream& ostr, unsigned char ch); returns ostr << (char)ch.
Next Include the STL standard header to define the template classes priority_queue and queue, and several supporting templates.
operator== template bool operator==(const queue & left, const queue & right); The template function overloads operator== to compare two objects of template class queue. The function returns left.c == right.c. operator< template bool operator<(const queue & left, const queue & right); The template function overloads operator< to compare two objects of template class queue.
priority_queue template, class Pr = less > class priority_queue { public: typedef Container container_type; typedef typename Container::value_type value_type; typedef typename Container::size_type size_type; priority_queue(); explicit priority_queue(const Pr& pred); priority_queue(const Pr& pred, const container_type& cont); priority_queue(const priority_queue& right); template priority_queue(InIt first, InIt last); template<
largest, or highest priority.) An object of class Container must supply random-access iterators and several public members defined the same as for deque and vector (both of which are suitable candidates for class Container).
priority_queue::priority_queue priority_queue(); explicit priority_queue(const Pr& pred); priority_queue(const Pr& pred, const container_type& cont); priority_queue(const priority_queue& right); template priority_queue(InIt first, InIt last); template priority_queue(InIt first, InIt last, const Pr& pred); template priority_queue(InIt first, InIt last, const Pr& pred, const container_type& cont); All constructors with an argument cont initialize the stored object with c(co
priority_queue::top const value_type& top() const; The member function returns a reference to the first (highest priority) element of the controlled sequence, which must be non-empty. priority_queue::value_type typedef typename Container::value_type value_type; The type is a synonym for Container::value_type.
members are: typedef Ty value_type; typedef T0 size_type; Container(); bool empty() const; size_type size() const; value_type& front(); const value_type& front() const; value_type& back(); const value_type& back() const; void push_back(const value_type& val); void pop_front(); bool operator==(const Container& cont) const; bool operator!=(const Container& cont) const; bool operator<(const Container& cont) const; bool operator>(const Container& cont) const; bool operator<=(const Container& cont) const; bool o
The member function returns a reference to the first element of the controlled sequence, which must be non-empty. queue::pop void pop(); The member function removes the first element of the controlled sequence, which must be non-empty. queue::push void push(const Ty& val); The member function inserts an element with value val at the end of the controlled sequence.
Hewlett-Packard Company. All rights reserved.
Next Include the STL standard header to define the container template classes set and multiset, and their supporting templates.
const set& right); template bool operator>( const multiset& left, const multiset& right); template bool operator<=( const set& left, const set& right); template bool operator<=( const multiset& left, const multiset& right); template bool operator>=( const set
template, class Alloc = allocator > class multiset { public: typedef Key key_type; typedef Pr key_compare; typedef Key value_type; typedef Pr value_compare; typedef Allov allocator_type; typedef Alloc::pointer pointer; typedef Alloc::const_pointer const_pointer; typedef Alloc::reference reference; typedef Alloc::const_reference const_reference; typedef T0 iterator; typedef T1 const_iterator; typedef T2 size_type; typedef T3 difference_type; typedef reverse_iterator
bool empty() const; Alloc get_allocator() const; iterator insert(const value_type& val); iterator insert(iterator where, const value_type& val); template void insert(InIt first, InIt last); iterator erase(iterator where); iterator erase(iterator first, iterator last); size_type erase(const Key& keyval); void clear(); void swap(multiset& right); key_compare key_comp() const; value_compare value_comp() const; iterator find(const Key& keyval); const_iterator find(const Key& keyval) const; size_type
object of template class allocator. Note that the stored allocator object is not copied when the container object is assigned. multiset::allocator_type typedef Alloc allocator_type; The type is a synonym for the template parameter Alloc. multiset::begin iterator begin(); const_iterator begin() const; The member function returns a bidirectional iterator that points at the first element of the sequence (or just beyond the end of an empty sequence).
multiset::const_reverse_iterator typedef reverse_iterator const_reverse_iterator; The type describes an object that can serve as a constant reverse bidirectional iterator for the controlled sequence. multiset::count size_type count(const Key& keyval) const; The member function returns the number of elements in the range [lower_bound(keyval), upper_bound(keyval)).
multiset::erase iterator erase(iterator where); iterator erase(iterator first, iterator last); size_type erase(const Key& keyval); The first member function removes the element of the controlled sequence pointed to by where. The second member function removes the elements in the range [first, last). Both return an iterator that designates the first element remaining beyond any elements removed, or end() if no such element exists.
If an exception is thrown during the insertion of a single element, the container is left unaltered and the exception is rethrown. If an exception is thrown during the insertion of multiple elements, the container is left in a stable but unspecified state and the exception is rethrown. multiset::iterator typedef T0 iterator; The type describes an object that can serve as a bidirectional iterator for the controlled sequence. It is described here as a synonym for the implementation-defined type T0.
multiset::multiset multiset(); explicit multiset(const Pr& pred); multiset(const Pr& pred, const Alloc& al); multiset(const multiset& right); template multiset(InIt first, InIt last); template multiset(InIt first, InIt last, const Pr& pred); template multiset(InIt first, InIt last, const Pr& pred, const Alloc& al); All constructors store an allocator object and initialize the controlled sequence. The allocator object is the argument al, if present.
the controlled sequence. Hence, it designates the beginning of the reverse sequence. multiset::reference typedef Alloc::reference reference; The type describes an object that can serve as a reference to an element of the controlled sequence. multiset::rend reverse_iterator rend(); const_reverse_iterator rend() const; The member function returns a reverse bidirectional iterator that points at the first element of the sequence (or just beyond the end of an empty sequence).
proportional to the number of elements in the two controlled sequences. multiset::upper_bound iterator upper_bound(const Key& keyval) const_iterator upper_bound(const Key& keyval) const; The member function returns an iterator that designates the earliest element X in the controlled sequence for which key_comp()(keyval, X) is true. If no such element exists, the function returns end().
operator== template bool operator==( const set & left, const set & right); template bool operator==( const multiset & left, const multiset & right); The first template function overloads operator== to compare two objects of template class set. The second template function overloads operator== to compare two objects of template class multiset. Both functions return left.
The template function returns !(right < left). operator> template bool operator>( const set & left, const set & right); template bool operator>( const multiset & left, const multiset & right); The template function returns right < left.
public: typedef Key key_type; typedef Pr key_compare; typedef Key value_type; typedef Pr value_compare; typedef Alloc allocator_type; typedef Alloc::pointer pointer; typedef Alloc::const_pointer const_pointer; typedef Alloc::reference reference; typedef Alloc::const_reference const_reference; typedef T0 iterator; typedef T1 const_iterator; typedef T2 size_type; typedef T3 difference_type; typedef reverse_iterator const_reverse_iterator; typedef reverse_iterator reverse_iterator; se
pair insert(const value_type& val); iterator insert(iterator where, const value_type& val); template void insert(InIt first, InIt last); iterator erase(iterator where); iterator erase(iterator first, iterator last); size_type erase(const Key& keyval); void clear(); void swap(set& right); key_compare key_comp() const; value_compare value_comp() const; iterator find(const Key& keyval); const_iterator find(const Key& keyval) const; size_type count(const Key& keyval) const; iterator
set::allocator_type typedef Alloc allocator_type; The type is a synonym for the template parameter Alloc. set::begin iterator begin(); const_iterator begin() const; The member function returns a bidirectional iterator that points at the first element of the sequence (or just beyond the end of an empty sequence). set::clear void clear(); The member function calls erase( begin(), end()).
controlled sequence. set::count size_type count(const Key& keyval) const; The member function returns the number of elements in the range [lower_bound(keyval), upper_bound(keyval)). set::difference_type typedef T3 difference_type; The signed integer type describes an object that can represent the difference between the addresses of any two elements in the controlled sequence. It is described here as a synonym for the implementation-defined type T3.
The first member function removes the element of the controlled sequence pointed to by where. The second member function removes the elements in the range [first, last). Both return an iterator that designates the first element remaining beyond any elements removed, or end() if no such element exists. The third member removes the elements with sort keys in the range [lower_bound(keyval), upper_bound(keyval)). It returns the number of elements it removes. The member functions never throw an exception.
and the exception is rethrown. If an exception is thrown during the insertion of multiple elements, the container is left in a stable but unspecified state and the exception is rethrown. set::iterator typedef T0 iterator; The type describes an object that can serve as a bidirectional iterator for the controlled sequence. It is described here as a synonym for the implementation-defined type T0.
set::max_size size_type max_size() const; The member function returns the length of the longest sequence that the object can control. set::pointer typedef Alloc::pointer pointer; The type describes an object that can serve as a pointer to an element of the controlled sequence. set::rbegin reverse_iterator rbegin(); const_reverse_iterator rbegin() const; The member function returns a reverse bidirectional iterator that points just beyond the end of the controlled sequence.
set::set set(); explicit set(const Pr& pred); set(const Pr& pred, const Alloc& al); set(const set& right); template set(InIt first, InIt last); template set(InIt first, InIt last, const Pr& pred); template set(InIt first, InIt last, const Pr& pred, const Alloc& al); All constructors store an allocator object and initialize the controlled sequence. The allocator object is the argument al, if present. For the copy constructor, it is right.get_allocator().
throws an exception only as a result of copying the stored function object of type Pr, and it invalidates no references, pointers, or iterators that designate elements in the two controlled sequences. Otherwise, it performs a number of element assignments and constructor calls proportional to the number of elements in the two controlled sequences.
The template function executes left.swap(right). See also the Table of Contents and the Index. Copyright © 1994-2001 by P.J. Plauger. Portions derived from work copyright © 1994 by Hewlett-Packard Company. All rights reserved.
Next namespace std { template class slist; // TEMPLATE FUNCTIONS template bool operator==( const slist& lhs, const slist& rhs); template bool operator!=( const slist& lhs, const slist& rhs); template bool operator<( const slist& lhs, const slist& rhs); template bool operator>( const slist& lhs, const slist& rhs); template bool operator<=( const
operator!= template bool operator!=( const slist & lhs, const slist & rhs); The template function returns !(lhs == rhs). operator== template bool operator==( const slist & lhs, const slist & rhs); The template function overloads operator== to compare two objects of template class slist. The function returns lhs.size() == rhs.size() && equal(lhs. begin(), lhs. end(), rhs.begin()).
operator> template bool operator>( const slist & lhs, const slist & rhs); The template function returns rhs < lhs. operator>= template bool operator>=( const slist & lhs, const slist & rhs); The template function returns !(lhs < rhs).
typedef T2 size_type; typedef T3 difference_type; slist(); explicit slist(const A& al); explicit slist(size_type n); slist(size_type n, const T& v); slist(size_type n, const T& v, const A& al); slist(const slist& x); template slist(InIt first, InIt last); template slist(InIt first, InIt last, const A& al); iterator begin(); const_iterator begin() const; iterator end(); const_iterator end() const; iterator previous(const_iterator it); const_iterator previous(const_iterator it) const;
iterator erase(iterator first, iterator last); void clear(); void swap(slist& x); void splice(iterator it, slist& x); void splice(iterator it, slist& x, iterator first); void splice(iterator it, slist& x, iterator first, iterator last); void remove(const T& x); templace void remove_if(Pred pr); void unique(); template void unique(Pred pr); void merge(slist& x); template void merge(slist& x, Pred pr); void sort(); template void sort(Pred pr); void reverse(); };
slist::allocator_type typedef A allocator_type; The type is a synonym for the template parameter A. slist::assign template void assign(InIt first, InIt last); void assign(size_type n, const T& x); If InIt is an integer type, the first member function behaves the same as assign((size_type)first, (T)last). Otherwise, the first member function replaces the sequence controlled by *this with the sequence [first, last), which must not overlap the initial controlled sequence.
slist::const_pointer typedef typename A::const_pointer const_pointer; The type describes an object that can serve as a constant pointer to an element of the controlled sequence. slist::const_reference typedef typename A::const_reference const_reference; The type describes an object that can serve as a constant reference to an element of the controlled sequence.
become invalid only for the erased elements. The member functions never throw an exception. slist::front reference front(); const_reference front() const; The member function returns a reference to the first element of the controlled sequence, which must be non-empty. slist::get_allocator A get_allocator() const; The member function returns the stored allocator object.
slist::max_size size_type max_size() const; The member function returns the length of the longest sequence that the object can control. slist::merge void merge(slist& x); template void merge(slist& x, Pred pr); Both member functions remove all elements from the sequence controlled by x and insert them in the controlled sequence. Both sequences must be ordered by the same predicate, described below. The resulting sequence is also ordered by that predicate.
slist::pop_front void pop_front(); The member function removes the first element of the controlled sequence, which must be non-empty. The member function never throws an exception. slist::previous iterator previous(const_iterator it); const_iterator previous(const_iterator it) const; The member function returns an iterator that designates the element immediately preceding it, if possible; otherwise it returns end().
The member function never throws an exception. slist::remove_if templace void remove_if(Pred pr); The member function removes from the controlled sequence all elements, designated by the iterator P, for which pr(*P) is true. An exception occurs only if pr throws an exception. In that case, the controlled sequence is left in an unspecified state and the exception is rethrown.
slist::slist slist(); explicit slist(const A& al); explicit slist(size_type n); slist(size_type n, const T& v); slist(size_type n, const T& v, const A& al); slist(const slist& x); template slist(InIt first, InIt last); template slist(InIt first, InIt last, const A& al); All constructors store an allocator object and initialize the controlled sequence. The allocator object is the argument al, if present. For the copy constructor, it is x.get_allocator(). Otherwise, it is A().
slist::splice void splice(iterator it, slist& x); void splice(iterator it, slist& x, iterator first); void splice(iterator it, slist& x, iterator first, iterator last); The first member function inserts the sequence controlled by x before the element in the controlled sequence pointed to by it. It also removes all elements from x. (&x must not equal this.
For a controlled sequence of length N (> 0), the predicate pr(*Pi, *Pj) is evaluated N - 1 times. An exception occurs only if pr throws an exception. In that case, the controlled sequence is left in an unspecified state and the exception is rethrown. slist::value_type typedef typename A::value_type value_type; The type is a synonym for the template parameter T. swap template void swap( slist & lhs, slist & rhs); The template function executes lhs.swap(rhs).
Next Include the iostreams standard header to define several template classes that support iostreams operations on sequences stored in an allocated array object. Such sequences are easily converted to and from objects of template class basic_string.
class basic_stringbuf : public basic_streambuf { public: typedef typename basic_streambuf::char_type char_type; typedef typename basic_streambuf::traits_type traits_type; typedef typename basic_streambuf::int_type int_type; typedef typename basic_streambuf::pos_type pos_type; typedef typename basic_streambuf::off_type off_type; typedef Alloc allocator_type; basic_stringbuf(ios_base::openmode mode = ios_base::in | ios_base::out); basic_stringbuf(con
● If mode & ios_base::in is nonzero, the input buffer is accessible. ● If mode & ios_base::out is nonzero, the output buffer is accessible. basic_stringbuf::allocator_type typedef Alloc allocator_type; The type is a synonym for the template parameter Alloc.
basic_stringbuf::overflow virtual int_type overflow(int_type meta = traits_type::eof()); If meta does not compare equal to traits_type::eof(), the protected virtual member function endeavors to insert the element traits_type::to_char_type(meta) into the output buffer. It can do so in various ways: ● ● If a write position is available, it can store the element into the write position and increment the next pointer for the output buffer.
basic_stringbuf::seekoff virtual pos_type seekoff(off_type off, ios_base::seekdir way, ios_base::openmode mode = ios_base::in | ios_base::out); The protected virtual member function endeavors to alter the current positions for the controlled streams. For an object of class basic_stringbuf, a stream position consists purely of a stream offset. Offset zero designates the first element of the controlled sequence.
Otherwise (or if neither position is affected) the positioning operation fails. If the function succeeds in altering either or both of the stream positions, it returns the resultant stream position. Otherwise, it fails and returns an invalid stream position.
basic_istringstream template , class Alloc = allocator > class basic_istringstream : public basic_istream { public: typedef Alloc allocator_type; explicit basic_istringstream( ios_base::openmode mode = ios_base::in); explicit basic_istringstream( const basic_string& str, ios_base::openmode mode = ios_base::in); basic_stringbuf *rdbuf() const; basic_string str(); void str(const basic_string
initializes sb by calling basic_stringbuf(str, mode | ios_base::in). basic_istringstream::rdbuf basic_stringbuf *rdbuf() const The member function returns the address of the stored stream buffer, of type pointer to basic_stringbuf. basic_istringstream::str basic_string str() const; void str(const basic_string& newstr); The first member function returns rdbuf()-> str().
basic_ostringstream::allocator_type typedef Alloc allocator_type; The type is a synonym for the template parameter Alloc. basic_ostringstream::basic_ostringstream explicit basic_ostringstream( ios_base::openmode mode = ios_base::out); explicit basic_ostringstream( const basic_string& str, ios_base::openmode mode = ios_base::out); The first constructor initializes the base class by calling basic_ostream(sb), where sb is the stored object of class basic_stringbuf.
typedef Alloc allocator_type; explicit basic_stringstream( ios_base::openmode mode = ios_base::in | ios_base::out); explicit basic_stringstream( const basic_string& str, ios_base::openmode mode = ios_base::in | ios_base::out); basic_stringbuf *rdbuf() const; basic_string str(); void str(const basic_string& newstr); }; The template class describes an object that controls insertion and extraction of elements and encoded objects using a stream
basic_stringstream::rdbuf basic_stringbuf *rdbuf() const The member function returns the address of the stored stream buffer, of type pointer to basic_stringbuf. basic_stringstream::str basic_string str() const; void str(const basic_string& newstr); The first member function returns rdbuf()-> str(). The second member function calls rdbuf()-> str(newstr).
wistringstream typedef basic_istringstream wistringstream; The type is a synonym for template class basic_istringstream, specialized for elements of type wchar_t. wostringstream typedef basic_ostringstream wostringstream; The type is a synonym for template class basic_ostringstream, specialized for elements of type wchar_t. wstringbuf typedef basic_stringbuf wstringbuf; The type is a synonym for template class basic_stringbuf, specialized for elements of type wchar_t.
Next Include the STL standard header to define the template class stack and two supporting templates.
operator== template bool operator==(const stack & left, const stack & right); The template function overloads operator== to compare two objects of template class stack. The function returns left.c == right.c. operator< template bool operator<(const stack & left, const stack & right); The template function overloads operator< to compare two objects of template class stack.
stack template > class stack { public: typedef Container container_type; typedef typename Container::value_type value_type; typedef typename Container::size_type size_type; stack(); explicit stack(const container_type& cont); bool empty() const; size_type size() const; value_type& top(); const value_type& top() const; void push(const value_type& val); void pop(); protected: Container c; }; The template class describes an object that controls a varying-length sequence of
bool operator>=(const Container& cont) const; Here, T0 is an unspecified type that meets the stated requirements. stack::container_type typedef Container container_type; The type is a synonym for the template parameter Container. stack::empty bool empty() const; The member function returns true for an empty controlled sequence. stack::pop void pop(); The member function removes the last element of the controlled sequence, which must be non-empty.
sequence. The second constructor initializes the stored object with c(cont), to specify an initial controlled sequence that is a copy of the sequence controlled by cont. stack::top value_type& top(); const value_type& top() const; The member function returns a reference to the last element of the controlled sequence, which must be non-empty. stack::value_type typedef typename Container::value_type value_type; The type is a synonym for Container::value_type. See also the Table of Contents and the Index.
Next Include the standard header to define several classes used for reporting exceptions. The classes form a derivation hierarchy, as indicated by the indenting above, all derived from class exception.
length_error class length_error : public logic_error { public: length_error(const string& message); }; The class serves as the base class for all exceptions thrown to report an attempt to generate an object too long to be specified. The value returned by what() is a copy of message.data().
range_error class range_error : public runtime_error { public: range_error(const string& message); }; The class serves as the base class for all exceptions thrown to report a range error. The value returned by what() is a copy of message.data(). runtime_error class runtime_error : public exception { public: runtime_error(const string& message); }; The class serves as the base class for all exceptions thrown to report errors presumably detectable only when the program executes.
Next Include the iostreams standard header to define template class basic_streambuf, which is basic to the operation of the iostreams classes. (This header is typically included for you by another of the iostreams headers. You seldom have occasion to include it directly.
locale pubimbue(const locale& loc); locale getloc() const; basic_streambuf *pubsetbuf(char_type *buffer, streamsize count); pos_type pubseekoff(off_type off, ios_base::seekdir way, ios_base::openmode which = ios_base::in | ios_base::out); pos_type pubseekpos(pos_type sp, ios_base::openmode which = ios_base::in | ios_base::out); int pubsync(); streamsize in_avail(); int_type snextc(); int_type sbumpc(); int_type sgetc(); void stossc(); [optional] streamsize sgetn(char_type *ptr, streamsize count); int_type s
ios_base::in | ios_base::out); virtual pos_type seekpos(pos_type sp, ios_base::openmode which = ios_base::in | ios_base::out); virtual int sync(); virtual streamsize showmanyc(); virtual streamsize xsgetn(char_type *ptr, streamsize count); virtual int_type underflow(); virtual int_type uflow(); virtual int_type pbackfail(int_type meta = traits_type::eof()); virtual streamsize xsputn(const char_type *ptr, streamsize count); virtual int_type overflow(int_type meta = traits_type::eof()); }; The template class
● egptr(), a pointer just past the end of the buffer Similarly, an output buffer is characterized by: ● pbase(), a pointer to the beginning of the buffer ● pptr(), a pointer to the next element to write ● epptr(), a pointer just past the end of the buffer For any buffer, the protocol is: ● If the next pointer is null, no buffer exists. Otherwise, all three pointers point into the same sequence. (They can be safely compared for order.
basic_streambuf::egptr char_type *egptr() const; The member function returns a pointer just past the end of the input buffer. basic_streambuf::epptr char_type *epptr() const; The member function returns a pointer just past the end of the output buffer. basic_streambuf::gbump void gbump(int count); The member function adds count to the next pointer for the input buffer. basic_streambuf::getloc locale getloc() const; The member function returns the stored locale object.
basic_streambuf::int_type typedef typename traits_type::int_type int_type; The type is a synonym for traits_type::int_type. basic_streambuf::off_type typedef typename traits_type::off_type off_type; The type is a synonym for traits_type::off_type.
● input buffer. For a stream buffer with common input and output streams, it can make a putback position available by writing out, to some external destination, some or all of the elements between the beginning and next pointers for the output buffer. If the function cannot succeed, it returns traits_type::eof() or throws an exception. Otherwise, it returns some other value. The default behavior is to return traits_type::eof().
The member function returns seekoff(off, way, which). basic_streambuf::pubseekpos pos_type pubseekpos(pos_type sp, ios_base::openmode which = ios_base::in | ios_base::out); The member function returns seekpos(sp, which). basic_streambuf::pubsetbuf basic_streambuf *pubsetbuf(char_type *buffer, streamsize count); The member function returns setbuf(buffer, count). basic_streambuf::pubsync int pubsync(); The member function returns sync().
Typically, if which & ios_base::in is nonzero, the input stream is affected, and if which & ios_base::out is nonzero, the output stream is affected. Actual use of this parameter varies among derived stream buffers, however. If the function succeeds in altering the stream position(s), it returns the resultant stream position (or one of them). Otherwise, it returns an invalid stream position. The default behavior is to return an invalid stream position.
basic_streambuf::sgetc int_type sgetc(); If a read position is available, the member function returns traits_type::to_int_type( *gptr()) Otherwise, it returns underflow(). basic_streambuf::sgetn streamsize sgetn(char_type *ptr, streamsize count); The member function returns xsgetn(ptr, count).
basic_streambuf::sputn streamsize sputn(const char_type *ptr, streamsize count); The member function returns xsputn(ptr, count). basic_streambuf::stossc void stossc(); [optional] The member function calls sbumpc(). Note that an implementation is not required to supply this member function. basic_streambuf::sungetc int_type sungetc(); If a putback position is available, the member function decrements the next pointer for the input buffer and returns traits_type::to_int_type( *gptr()).
advances the next pointer for the input buffer. ● ● It can read an element directly, from some external source, and deliver it as the value ch. For a stream buffer with common input and output streams, it can make a read position available by writing out, to some external destination, some or all of the elements between the beginning and next pointers for the output buffer. Or it can allocate new or additional storage for the input buffer.
if by repeated calls to sputc, from the array beginning at ptr. It returns the number of elements actually inserted. streambuf typedef basic_streambuf > streambuf; The type is a synonym for template class basic_streambuf, specialized for elements of type char with default character traits.
Next basic_string · char_traits · char_traits · char_traits · getline · operator+ · operator!= · operator== · operator< · operator<< · operator<= · operator> · operator>= · operator>> · string · swap · wstring Include the standard header to define the container template class basic_string and various supporting templates.
const basic_string& template basic_string operator+( Elem left, const basic_string& template bool operator==( const basic_string& const basic_string& template bool operator==( const basic_string& const Elem *right); template bool operator==( const Elem *left, const basi
const basic_string& right); template bool operator>( const basic_string& left, const Elem *right); template bool operator>( const Elem *left, const basic_string& right); template bool operator<=( const basic_string& left, const basic_string& right); template bool operator<=( const basic
basic_string& str); template basic_istream& getline( basic_istream& istr, basic_string& str); template basic_istream& getline( basic_istream& istr, basic_string& str, Elem delim); }; basic_string basic_string · allocator_type · append · assign · at · begin · c_str · capacity · clear · compare · const_iterator · const_pointer · const_reference · con
pointer; typedef typename allocator_type::const_pointer const_pointer; typedef typename allocator_type::reference reference; typedef typename allocator_type::const_reference const_reference; typedef typename allocator_type::value_type value_type; static const size_type npos = -1; basic_string(); explicit basic_string(const allocator_type& al); basic_string(const basic_string& right); basic_string(const basic_string& right, size_type roff, size_type count = npos); basic_string(const basic_string& right, size
const_reference at(size_type off) const; reference at(size_type off); const_reference operator[](size_type off) const; reference operator[](size_type off); void push_back(value_type ch); const value_type *c_str() const; const value_type *data() const; size_type length() const; size_type size() const; size_type max_size() const; void resize(size_type newsize, value_type ch = value_type()); size_type capacity() const; void reserve(size_type count = 0); bool empty() const; basic_string& operator+=(const basic_
basic_string& insert(size_type off, const value_type *ptr); basic_string& insert(size_type off, size_type count, value_type ch); iterator insert(iterator where, value_type ch = value_type()); void insert(iterator where, size_type count, value_type ch); template void insert(iterator where, InIt first, InIt last); basic_string& erase(size_type off = 0, size_type count = npos); iterator erase(iterator where); iterator erase(iterator first, iterator last); void clear(); basic_string& replace(size_ty
size_type find(const value_type *ptr, size_type off, size_type count) const; size_type find(const value_type *ptr, size_type off = 0) const; size_type find(value_type ch, size_type off = 0) const; size_type rfind(const basic_string& right, size_type off = npos) const; size_type rfind(const value_type *ptr, size_type off, size_type count = npos) const; size_type rfind(const value_type *ptr, size_type off = npos) const; size_type rfind(value_type ch, size_type off = npos) const; size_type find_first_of(const
size_type find_last_not_of(value_type ch, size_type off = npos) const; basic_string substr(size_type off = 0, size_type count = npos) const; int compare(const basic_string& right) const; int compare(size_type off, size_type n0, const basic_string& right); int compare(size_type off, size_type n0, const basic_string& right, size_type roff, size_type count); int compare(const value_type *ptr) const; int compare(size_type off, size_type n0, const value_type *ptr) const; int compare(size_type off, size_type n0,
● ● ● ● ptr (which must not be a null pointer), where the terminating element is the value value_type() and is not part of the operand sequence ptr, count -- a sequence of count elements beginning at ptr (which must not be a null pointer) right -- the sequence specified by the basic_string object right right, roff, count -- the substring of the basic_string object right with up to count elements (or through the end of the string, whichever comes first) beginning at position roff first, last -- a sequence
each append the operand sequence to the end of the sequence controlled by *this, then return *this.
basic_string::basic_string basic_string(const value_type *ptr); basic_string(const value_type *ptr, const allocator_type& al); basic_string(const value_type *ptr, size_type count); basic_string(const value_type *ptr, size_type count, const allocator_type& al); basic_string(const basic_string& right); basic_string(const basic_string& right, size_type roff, size_type count = npos); basic_string(const basic_string& right, size_type roff, size_type count, const allocator_type& al); basic_string(size_type count,
basic_string::begin const_iterator begin() const; iterator begin(); The member functions each return a random-access iterator that points at the first element of the sequence (or just beyond the end of an empty sequence). basic_string::c_str const value_type *c_str() const; The member function returns a pointer to a non-modifiable C string constructed by adding a terminating null element (value_type()) to the controlled sequence. Calling any non-const member function for *this can invalidate the pointer.
● ● traits_type::compare), or if the two have a common prefix but the operand sequence is longer zero if the two compare equal element by element and are the same length a positive value otherwise basic_string::const_iterator typedef T1 const_iterator; The type describes an object that can serve as a constant random-access iterator for the controlled sequence. It is described here as a synonym for the implementation-defined type T1.
basic_string::data const value_type *data() const; The member function returns a pointer to the first element of the sequence (or, for an empty sequence, a non-null pointer that cannot be dereferenced). basic_string::difference_type typedef T3 difference_type; The signed integer type describes an object that can represent the difference between the addresses of any two elements in the controlled sequence. It is described here as a synonym for the implementation-defined type T3.
basic_string::find size_type find(value_type ch, size_type off = 0) const; size_type find(const value_type *ptr, size_type off = 0) const; size_type find(const value_type *ptr, size_type off, size_type count) const; size_type find(const basic_string& right, size_type off = 0) const; The member functions each find the first (lowest beginning position) subsequence in the controlled sequence, beginning on or after position off, that matches the operand sequence specified by the remaining operands.
basic_string::find_last_not_of size_type find_last_not_of(value_type ch, size_type off = npos) const; size_type find_last_not_of(const value_type *ptr, size_type off = npos) const; size_type find_last_not_of(const value_type *ptr, size_type off, size_type count) const; size_type find_last_not_of(const basic_string& right, size_type off = npos) const; The member functions each find the last (highest position) element of the controlled sequence, at or before position off, that matches none of the elements in
basic_string& insert(size_type off, size_type count, value_type ch); iterator insert(iterator where, value_type ch = value_type()); template void insert(iterator where, InIt first, InIt last); void insert(iterator where, size_type count, value_type ch); The member functions each insert, before position off or before the element pointed to by where in the controlled sequence, the operand sequence specified by the remaining operands. A function that returns a value returns *this.
basic_string::operator+= basic_string& operator+=(value_type ch); basic_string& operator+=(const value_type *ptr); basic_string& operator+=(const basic_string& right); The operators each append the operand sequence to the end of the sequence controlled by *this, then return *this.
basic_string::reference typedef typename allocator_type::reference reference; The type is a synonym for allocator_type::reference. basic_string::rend const_reverse_iterator rend() const; reverse_iterator rend(); The member functions each return a reverse iterator that points at the first element of the sequence (or just beyond the end of an empty sequence). Hence, the function designates the end of the reverse sequence.
In this implementation, if a translator does not support member template functions, the template: template basic_string& replace(iterator first, iterator last, InIt first2, InIt last2); is replaced by: basic_string& replace(iterator first, iterator last, const_pointer first2, const_pointer last2); basic_string::reserve void reserve(size_type count = 0); The member function ensures that capacity() henceforth returns at least count.
basic_string::size size_type size() const; The member function returns the length of the controlled sequence. basic_string::size_type typedef T2 size_type; The unsigned integer type describes an object that can represent the length of any controlled sequence. It is described here as a synonym for the implementation-defined type T2.
char_traits template class char_traits { public: typedef Elem char_type; typedef T1 int_type; typedef T2 pos_type; typedef T3 off_type; typedef T4 state_type; static void assign(char_type& left, const char_type& right); static char_type *assign(char_type *first, size_t count, char_type ch); static bool eq(const char_type& left, const char_type& right); static bool lt(const char_type& left, const char_type& right); static int compare(const char_type *first1, const char_type *first2, size_t count)
formatted output functions make use of the following additional operations, also with the expected semantics: ● operator==(Elem) and operator!=(Elem) to compare elements ● (char)ch to convert an element ch to its corresponding single-byte character code, or '\0' if no such code exists ● (Elem)ch to convert a char value ch to its correponding character code of type Elem None of the member functions of class char_traits may throw exceptions.
char_traits::eof static int_type eof(); The static member function returns a value that represents end-of-file (such as EOF or WEOF). If the value is also representable as type Elem, it must correspond to no valid value of that type. char_traits::eq static bool eq(const char_type& left, const char_type& right); The static member function returns true if left compares equal to right.
char_traits::move static char_type *move(char_type *first1, const char_type *first2, size_t count); The static member function copies the sequence of count elements beginning at first2 to the array beginning at first1, then returns first1. The source and destination may overlap. char_traits::not_eof static int_type not_eof(const int_type& meta); If !eq_int_type( eof(), meta), the static member function returns meta. Otherwise, it returns a value other than eof().
char_traits::to_int_type static int_type to_int_type(const char_type& ch); The static member function returns ch represented as type int_type. It must be possible to convert any value ch of type Elem to int_type (by evaluating meta = to_int_type(ch)) then back to Elem (by evaluating ch = to_char_type(meta)) and obtain a value that compares equal to ch.
3. after the function extracts str.max_size() elements, in which case the function calls setstate(ios_base::failbit). If the function extracts no elements, it calls setstate(failbit). In any case, it returns istr.
const Elem *left, const basic_string& right); The template functions each overload operator!= to compare two objects of template class basic_string. All effectively return basic_string(left).compare(right) != 0.
operator<< template basic_ostream& operator<<( basic_ostream& ostr, const basic_string& str); The template function overloads operator<< to insert an object str of template class basic_string into the stream ostr The function effectively returns ostr.write( str.c_str(), str.size()).
The template functions each overload operator> to compare two objects of template class basic_string. All effectively return basic_string(left).compare(right) > 0.
string typedef basic_string string; The type describes a specialization of template class basic_string specialized for elements of type char. swap template void swap( basic_string& left, basic_string& right); The template function executes left.swap(right). wstring typedef basic_string wstring; The type describes a specialization of template class basic_string for elements of type wchar_t. See also the Table of Contents and the Index.
Next Include the iostreams standard header to define several classes that support iostreams operations on sequences stored in an allocated array of char object. Such sequences are easily converted to and from C strings.
ios_base::openmode which = ios_base::in | ios_base::out); virtual int underflow(); virtual int pbackfail(int meta = EOF); virtual int overflow(int meta = EOF); }; The class describes a stream buffer that controls the transmission of elements to and from a sequence of elements stored in a char array object. Depending on how it is constructed, the object can be allocated, extended, and freed as necessary to accommodate changes in the sequence.
strstreambuf::overflow virtual int overflow(int meta = EOF); If meta != EOF, the protected virtual member function endeavors to insert the element (char)meta into the output buffer. It can do so in various ways: ● ● If a write position is available, it can store the element into the write position and increment the next pointer for the output buffer.
offset. Offset zero designates the first element of the controlled sequence. The new position is determined as follows: ● If way == ios_base::beg, the new position is the beginning of the stream plus off. ● If way == ios_base::cur, the new position is the current stream position plus off. ● If way == ios_base::end, the new position is the end of the stream plus off. If which & ios_base::in is nonzero and the input buffer exist, the function alters the next position to read in the input buffer.
strstreambuf::str char *str(); The member function calls freeze(), then returns a pointer to the beginning of the controlled sequence. (Note that no terminating null element exists, unless you insert one explicitly.
If putptr is a null pointer, the function establishes just an input buffer, by executing: setg(getptr, getptr, getptr + N); Otherwise, it establishes both input and output buffers, by executing: setg(getptr, getptr, putptr); setp(putptr, getptr + N); In this case, putptr must be in the interval [getptr, getptr + N].
The class describes an object that controls extraction of elements and encoded objects from a stream buffer of class strstreambuf. The object stores an ojbect of class strstreambuf. istrstream::istrstream explicit istrstream(const char *ptr); explicit istrstream(char *ptr); istrstream(const char *ptr, streamsize count); istrstream(char *ptr, streamsize count); All the constructors initialize the base class by calling istream(sb), where sb is the stored object of class strstreambuf.
ostrstream::freeze void freeze(bool freezeit = true) The member function calls rdbuf()-> freeze(freezeit). ostrstream::ostrstream ostrstream(); ostrstream(char *ptr, streamsize count, ios_base::openmode mode = ios_base::out); Both constructors initialize the base class by calling ostream(sb), where sb is the stored object of class strstreambuf. The first constructor also initializes sb by calling strstreambuf().
strstream class strstream : public iostream { public: strstream(); strstream(char *ptr, streamsize count, ios_base::openmode mode = ios_base::in | ios_base::out); strstreambuf *rdbuf() const; void freeze(bool freezeit = true); char *str(); streamsize pcount() const; }; The class describes an object that controls insertion and extraction of elements and encoded objects using a stream buffer of class strstreambuf. The object stores an ojbect of class strstreambuf.
● Otherwise, ptr must designate the first element of an array of count elements that contains a C string whose first element is designated by ptr, and the constructor calls strstreambuf(ptr, count, ptr + strlen(ptr). strstream::rdbuf strstreambuf *rdbuf() const The member function returns the address of the stored stream buffer, of type pointer to strstreambuf. strstream::str char *str(); The member function returns rdbuf()-> str(). See also the Table of Contents and the Index.
Next Include the standard header to define several types associated with the type-identification operator typeid, which yields information about both static and dynamic types. namespace std { class type_info; class bad_cast; class bad_typeid; }; bad_cast class bad_cast : public exception { }; The class describes an exception thrown to indicate that a dynamic cast expression, of the form: dynamic_cast(expression) generated a null pointer to initialize a reference.
bool operator==(const type_info& right) const; bool operator!=(const type_info& right) const; bool before(const type_info& right) const; const char *name() const; private: type_info(const type_info& right); type_info& operator=(const type_info& right); }; The class describes type information generated within the program by the implementation. Objects of this class effectively store a pointer to a name for the type, and an encoded value suitable for comparing two types for equality or collating order.
Next Include the STL standard header to define several templates of general use throughout the Standard Template Library. Four template operators -- operator!=, operator<=, operator>, and operator>= -define a total ordering on pairs of operands of the same type, given definitions of operator== and operator<. If an implementation supports namespaces, these template operators are defined in the rel_ops namespace, nested within the std namespace.
const pair& right); namespace rel_ops { template bool operator!=(const Ty& left, const Ty& right); template bool operator<=(const Ty& left, const Ty& right); template bool operator>(const Ty& left, const Ty& right); template bool operator>=(const Ty& left, const Ty& right); }; }; make_pair template pair make_pair(Ty1 val1, Ty2 val2); The template function returns pair(val1, val2).
operator< template bool operator<(const pair& left, const pair& right); The template function returns left.first < right.first || !(right.first < left.first && left.second < right.second). operator<= template bool operator<=(const Ty& left, const Ty& right); template bool operator<=(const pair& left, const pair& right); The template function returns !(right < left).
pair template struct pair { typedef Ty1 first_type; typedef Ty2 second_type Ty1 first; Ty2 second; pair(); pair(const Ty1& val1, const Ty2& val2); template pair(const pair& right); }; The template class stores a pair of objects, first, of type Ty1, and second, of type Ty2. The type definition first_type, is the same as the template parameter Ty1, while second_type, is the same as the template parameter Ty2.
Next gslice · gslice_array · indirect_array · mask_array · slice · slice_array · valarray · valarray abs · acos · asin · atan · atan2 · cos · cosh · exp · log · log10 · operator!= · operator% · operator& · operator&& · operator> · operator>> · operator>= · operator< · operator<< · operator<= · operator* · operator+ · operator- · operator/ · operator== · operator^ · operator| · operator|| · pow · sin · sinh · sqrt · tan · tanh Include the standard header to define the template cl
const valarray& right); template valarray operator/(const valarray& left, const valarray& right); template valarray operator/(const valarray left, const Ty& right); template valarray operator/(const Ty& left, const valarray& right); template valarray operator%(const valarray& left, const vararray& right); template valarray operator%(const valarray left, const Ty& right); template valarray oper
template valarray operator&(const valarray left, const Ty& right); template valarray operator&(const Ty& left, const valarray& right); template valarray operator|(const valarray& left, const valarray& right); template valarray operator|(const valarray left, const Ty& right); template valarray operator|(const Ty& left, const valarray& right); template valarray operator<<(const valarray& left, const
template valarray operator||(const Ty& left, const valarray& right); template valarray operator==(const valarray& left, const valarray& right); template valarray operator==(const valarray left, const Ty& right); template valarray operator==(const Ty& left, const valarray& right); template valarray operator!=(const valarray& left, const valarray& right); template valarray operator!=(con
template valarray operator<=(const valarray& left, const valarray& right); template valarray operator<=(const valarray left, const Ty& right); template valarray operator<=(const Ty& left, const valarray& right); template valarray abs(const valarray& left); template valarray acos(const valarray& left); template valarray asin(const valarray& left); template valarray atan(const va
valarray tan(const valarray& left); template valarray tanh(const valarray& left); }; abs template valarray abs(const valarray& left); The template function returns an object of class valarray, each of whose elements I is the absolute value of left[I]. acos template valarray acos(const valarray& left); The template function returns an object of class valarray, each of whose elements I is the arccosine of left[I].
arctangent of left[I] / right[I]. The second template function stores in element I the arctangent of left[I] / right. The third template function stores in element I the arctangent of left / right[I]. cos template valarray cos(const valarray& left); The template function returns an object of class valarray, each of whose elements I is the cosine of left[I].
gslice::gslice gslice(); gslice(size_t off, const valarray lenarr, const valarray incarr); The default constructor stores zero for the starting index, and zero-length vectors for the length and stride vectors. The second constructor stores off for the starting index, lenarr for the length vector, and incarr for the stride vector. gslice::size const valarray size() const; The member function returns the stored length vector.
gslice_array& operator=( const gslice_array&); }; // not defined The class describes an object that stores a reference to an object va of class valarray, along with an object gs of class gslice which describes the sequence of elements to select from the valarray object. You construct a gslice_array object only by writing an expression of the form va[gs].
private: private: void indirect_array(); // not defined void indirect_array( const indirect_array&); // not defined indirect_array& operator=( const indirect_array&); // not defined }; The class describes an object that stores a reference to an object va of class valarray, along with an object xa of class valarray which describes the sequence of elements to select from the valarray object. You construct an indirect_array object only by writing an expression of the form va[xa].
void operator+=(const valarray right) const; void operator-=(const valarray right) const; void operator^=(const valarray right) const; void operator&=(const valarray right) const; void operator|=(const valarray right) const; void operator<<=(const valarray right) const; void operator>>=(const valarray right) const; private: void mask_array(); // not defined void mask_array( const mask_array&); // not defined gslice_array& operator=( const mask_array&); // not defined }; The class
operator% template valarray operator%(const valarray& left, const valarray& right); template valarray operator%(const valarray left, const Ty& right); template valarray operator%(const Ty& left, const valarray& right); The first template operator returns an object of class valarray, each of whose elements I is left[I] % right[I]. The second template operator stores in element I left[I] % right.
operator> template valarray operator>(const valarray& left, const valarray& right); template valarray operator>(const valarray left, const Ty& right); template valarray operator>(const Ty& left, const valarray& right); The first template operator returns an object of class valarray, each of whose elements I is left[I] > right[I]. The second template operator stores in element I left[I] > right.
operator< template valarray operator<(const valarray& left, const valarray& right); template valarray operator<(const valarray left, const Ty& right); template valarray operator<(const Ty& left, const valarray& right); The first template operator returns an object of class valarray, each of whose elements I is left[I] < right[I]. The second template operator stores in element I left[I] < right.
template valarray operator*(const valarray left, const Ty& right); template valarray operator*(const Ty& left, const valarray& right); The first template operator returns an object of class valarray, each of whose elements I is left[I] * right[I]. The second template operator stores in element I left[I] * right. The third template operator stores in element I left * right[I].
valarray operator/(const valarray left, const Ty& right); template valarray operator/(const Ty& left, const valarray& right); The first template operator returns an object of class valarray, each of whose elements I is left[I] / right[I]. The second template operator stores in element I left[I] / right. The third template operator stores in element I left / right[I].
valarray operator|(const Ty& left, const valarray& right); The first template operator returns an object of class valarray, each of whose elements I is left[I] | right[I]. The second template operator stores in element I left[I] | right. The third template operator stores in element I left | right[I].
sinh template valarray sinh(const valarray& left); The template function returns an object of class valarray, each of whose elements I is the hyperbolic sine of left[I]. slice class slice { public: slice(); slice(size_t st, size_t len, size_t str); size_t start() const; size_t size() const; size_t stride() const; }; The class stores the parameters that characterize a slice_array when an object of class slice appears as a subscript for an object of class valarray.
slice::stride size_t stride() const; The member function returns the stored stride.
The template function returns an object of class valarray, each of whose elements I is the square root of left[I]. tan template valarray tan(const valarray& left); The template function returns an object of class valarray, each of whose elements I is the tangent of left[I]. tanh template valarray tanh(const valarray& left); The template function returns an object of class valarray, each of whose elements I is the hyperbolic tangent of left[I].
valarray& operator=(const mask_array& maskarr); valarray& operator=(const indirect_array& indarr); Ty& operator[](size_t off); slice_array operator[](slice slicearr); gslice_array operator[](const gslice& gslicearr); mask_array operator[](const valarray& boolarr); indirect_array operator[](const valarray& indarr); Ty operator[](size_t off) const; valarray operator[](slice slicearr) const; valarray operator[](const gslice& gslicearr) const; valarray o
Ty sum() const; Ty max() const; Ty min() const; valarray shift(int count) const; valarray cshift(int count) const; valarray apply(Ty func(Ty)) const; valarray apply(Ty func(const Ty&)) const; void resize(size_t newsize); void resize(size_t newsize, const Ty& val); }; The template class describes an object that controls a varying-length sequence of elements of type Ty. The sequence is stored as an array of Ty.
valarray::min Ty min() const; The member function returns the value of the smallest element of *this, which must have nonzero length. If the length is greater than one, it compares values by applying operator< between pairs of elements of class Ty. valarray::operator Ty * operator Ty *(); operator const Ty *() const; Both member functions return a pointer to the first element of the controlled array, which must have at least one element.
The member operator replaces each element I of *this with (*this)[I] << right[I]. It returns *this. valarray::operator*= valarray& operator*=(const valarray& right); valarray& operator*=(const Ty& right); The member operator replaces each element I of *this with (*this)[I] * right[I]. It returns *this. valarray::operator+ valarray operator+() const; The member operator returns an object of class valarray, of length size(), each of whose elements I is (*this)[I].
valarray::operator= valarray& operator=(const valarray& right); valarray& operator=(const Ty& val); valarray& operator=(const slice_array& slicearr); valarray& operator=(const gslice_array& gslicearr); valarray& operator=(const mask_array& maskarr); valarray& operator=(const indirect_array& indarr); The first member operator replaces the controlled sequence with a copy of the sequence controlled by right.
valarray v1("ABCDEF", 6); const size_t lv[] = {2, 3}; const size_t dv[] = {7, 2}; const valarray len(lv, 2), str(dv, 2); v0[gslice(3, len, str)] = v1; // v0 == valarray("abcAeBgCijDlEnFp", 16) The fourth member operator selects those elements of the controlled sequence designated by boolarr.
example: valarray v0("abcdefghijklmnop", 16); const size_t vi[] = {7, 5, 2, 3, 8}; // v0[valarray(vi, 5)] returns // valarray("hfcdi", 5) valarray::operator^= valarray& operator^=(const valarray& right); valarray& operator^=(const Ty& right); The member operator replaces each element I of *this with (*this)[I] ^ right[I]. It returns *this.
valarray::size size_t size() const; The member function returns the number of elements in the array. valarray::sum Ty sum() const; The member function returns the sum of all elements of *this, which must have nonzero length. If the length is greater than one, it adds values to the sum by applying operator+= between pairs of elements of class Ty.
Next Include the STL standard header to define the container template class vector and several supporting templates.
vector& right); }; operator!= template bool operator!=( const vector & left, const vector & right); The template function returns !(left == right). operator== template bool operator==( const vector & left, const vector & right); The template function overloads operator== to compare two objects of template class vector. The function returns left.size() == right.size() && equal(left. begin(), left.
operator> template bool operator>( const vector & left, const vector & right); The template function returns right < left. operator>= template bool operator>=( const vector & left, const vector & right); The template function returns !(left < right). swap template void swap( vector & left, vector & right); The template function executes left.swap(right).
typedef typename Alloc::pointer pointer; typedef typename Alloc::const_pointer const_pointer; typedef typename Alloc::reference reference; typedef typename Alloc::const_reference const_reference; typedef typename Alloc::value_type value_type; typedef T0 iterator; typedef T1 const_iterator; typedef T2 size_type; typedef T3 difference_type; typedef reverse_iterator const_reverse_iterator; typedef reverse_iterator reverse_iterator; vector(); explicit vector(const Alloc& al); explicit
bool empty() const; Alloc get_allocator() const; reference at(size_type off); const_reference at(size_type off) const; reference operator[](size_type off); const_reference operator[](size_type off); reference front(); const_reference front() const; reference back(); const_reference back() const; void push_back(const Ty& val); void pop_back(); template void assign(InIt first, InIt last); void assign(size_type count, const Ty& val); iterator insert(iterator where, const Ty& val); void insert(itera
vector::assign template void assign(InIt first, InIt last); void assign(size_type count, const Ty& val); If InIt is an integer type, the first member function behaves the same as assign((size_type)first, (Ty)last). Otherwise, the first member function replaces the sequence controlled by *this with the sequence [first, last), which must not overlap the initial controlled sequence.
vector::clear void clear(); The member function calls erase( begin(), end()). vector::const_iterator typedef T1 const_iterator; The type describes an object that can serve as a constant random-access iterator for the controlled sequence. It is described here as a synonym for the implementation-defined type T1. vector::const_pointer typedef typename Alloc::const_pointer const_pointer; The type describes an object that can serve as a constant pointer to an element of the controlled sequence.
vector::empty bool empty() const; The member function returns true for an empty controlled sequence. vector::end const_iterator end() const; iterator end(); The member function returns a random-access iterator that points just beyond the end of the sequence. vector::erase iterator erase(iterator where); iterator erase(iterator first, iterator last); The first member function removes the element of the controlled sequence pointed to by where.
vector::insert iterator insert(iterator where, const Ty& val); void insert(iterator where, size_type count, const Ty& val); template void insert(iterator where, InIt first, InIt last); Each of the member functions inserts, before the element pointed to by where in the controlled sequence, a sequence specified by the remaining operands. The first member function inserts a single element with value val and returns an iterator that points to the newly inserted element.
vector::operator[] const_reference operator[](size_type off) const; reference operator[](size_type off); The member function returns a reference to the element of the controlled sequence at position off. If that position is invalid, the behavior is undefined. vector::pointer typedef typename Alloc::pointer pointer; The type describes an object that can serve as a pointer to an element of the controlled sequence.
vector::rend const_reverse_iterator rend() const; reverse_iterator rend(); The member function returns a reverse iterator that points at the first element of the sequence (or just beyond the end of an empty sequence). Hence, it designates the end of the reverse sequence. vector::reserve void reserve(size_type count); If count is greater than max_size(), the member function reports a length error by throwing an object of class length_error.
vector::swap void swap(vector& right); The member function swaps the controlled sequences between *this and right. If get_allocator() == right.get_allocator(), it does so in constant time, it throws no exceptions, and it invalidates no references, pointers, or iterators that designate elements in the two controlled sequences. Otherwise, it performs a number of element assignments and constructor calls proportional to the number of elements in the two controlled sequences.
vector template class vector { public: class reference; typedef bool const_reference; typedef T0 iterator; typedef T1 const_iterator; typedef T4 pointer; typedef T5 const_pointer; void flip(); static void swap(reference left, reference right); // rest same as template class vector }; The class is a partial specialization of template class vector for elements of type bool.
vector::flip void flip(); The member function inverts the values of all the members of the controlled sequence. vector::iterator typedef T0 iterator; The type describes an object that can serve as a random-access iterator for the controlled sequence. It is described here as a synonym for the unspecified type T0. vector::pointer typedef T4 pointer; The type describes an object that can serve as a pointer to an element of the controlled sequence.
vector::swap void swap(reference left, reference right); The static member function swaps the members of the controlled sequences designated by left and right. See also the Table of Contents and the Index. Copyright © 1994-2001 by P.J. Plauger. Portions derived from work copyright © 1994 by Hewlett-Packard Company. All rights reserved.
Next Include the standard header to effectively include the Standard C library header . #include See also the Table of Contents and the Index. Copyright © 1992-2001 by P.J. Plauger. All rights reserved.
Next Include the standard header to define the macros traditionally defined in the Standard C library header . Including this header also ensures that the names declared with external linkage in the Standard C library header are declared in the std namespace. In this implementation, the names may or may not also be declared in the global namespace, depending on the specific translation environment. #if #include
Next Include the standard header to effectively include the Standard C library header . #include See also the Table of Contents and the Index. Copyright © 1992-2001 by P.J. Plauger. All rights reserved.
Next Include the standard header to effectively include the Standard C library header . #include See also the Table of Contents and the Index. Copyright © 1992-2001 by P.J. Plauger. All rights reserved.
Next Include the standard header to effectively include the standard header . #include See also the Table of Contents and the Index. Copyright © 1992-2001 by P.J. Plauger. All rights reserved.
Next Include the standard header to effectively include the Standard C library header . #include See also the Table of Contents and the Index. Copyright © 1992-2001 by P.J. Plauger. All rights reserved.
Next Include the standard header to define the macros traditionally defined in the Standard C library header . Including this header also ensures that the names declared with external linkage in the Standard C library header are declared in the std namespace. In this implementation, the names may or may not also be declared in the global namespace, depending on the specific translation environment. #if #include
Next Include the standard header to define the macros traditionally defined in the Standard C library header . Including this header also ensures that the names declared with external linkage in the Standard C library header are declared in the std namespace. In this implementation, the names may or may not also be declared in the global namespace, depending on the specific translation environment. #if #include
Next Include the standard header to define the macros traditionally defined in the Standard C library header . Including this header also ensures that the names declared with external linkage in the Standard C library header are declared in the std namespace. In this implementation, the names may or may not also be declared in the global namespace, depending on the specific translation environment. #if #include
Next Include the standard header to define the macros traditionally defined in the Standard C library header . Including this header also ensures that the names declared with external linkage in the Standard C library header are declared in the std namespace. In this implementation, the names may or may not also be declared in the global namespace, depending on the specific translation environment. #if #include
Next Include the standard header to define the macros traditionally defined in the Standard C library header . Including this header also ensures that the names declared with external linkage in the Standard C library header are declared in the std namespace. In this implementation, the names may or may not also be declared in the global namespace, depending on the specific translation environment. #if #include
Next Include the standard header to define the macros traditionally defined in the Standard C library header . Including this header also ensures that the names declared with external linkage in the Standard C library header are declared in the std namespace. In this implementation, the names may or may not also be declared in the global namespace, depending on the specific translation environment. #if #include
Next Include the standard header to define the macros traditionally defined in the Standard C library header . Including this header also ensures that the names declared with external linkage in the Standard C library header are declared in the std namespace. In this implementation, the names may or may not also be declared in the global namespace, depending on the specific translation environment. #if #include
Next Include the standard header to define the macros traditionally defined in the Standard C library header . Including this header also ensures that the names declared with external linkage in the Standard C library header are declared in the std namespace. In this implementation, the names may or may not also be declared in the global namespace, depending on the specific translation environment. #if #include
Next Include the standard header to define the macros traditionally defined in the Standard C library header . Including this header also ensures that the names declared with external linkage in the Standard C library header are declared in the std namespace. In this implementation, the names may or may not also be declared in the global namespace, depending on the specific translation environment. #if #include
Next Include the standard header to define the macros traditionally defined in the Standard C library header . Including this header also ensures that the names declared with external linkage in the Standard C library header are declared in the std namespace. In this implementation, the names may or may not also be declared in the global namespace, depending on the specific translation environment. #if #include
Next Include the standard header to define the macros traditionally defined in the Standard C library header . Including this header also ensures that the names declared with external linkage in the Standard C library header are declared in the std namespace. In this implementation, the names may or may not also be declared in the global namespace, depending on the specific translation environment. #if #include
Next Include the standard header to define the macros traditionally defined in the Standard C library header . Including this header also ensures that the names declared with external linkage in the Standard C library header are declared in the std namespace. In this implementation, the names may or may not also be declared in the global namespace, depending on the specific translation environment. #if #include
Next Include the standard header to define the macro assert, which is useful for diagnosing logic errors in the program. You can eliminate the testing code produced by the macro assert without removing the macro references from the program by defining the macro NDEBUG in the program before you include . Each time the program includes this header, it redetermines the definition of the macro assert.
Next isalnum · isalpha · iscntrl · isdigit · isgraph · islower · isprint · ispunct · isspace · isupper · isxdigit · tolower · toupper Include the standard header to declare several functions that are useful for classifying and mapping codes from the target character set. Every function that has a parameter of type int can accept the value of the macro EOF or any value representable as type unsigned char.
The diagram tells you that the function isprint returns nonzero for space or for any character for which the function isgraph returns nonzero. The function isgraph, in turn, returns nonzero for any character for which either the function isalnum or the function ispunct returns nonzero. The function isdigit, on the other hand, returns nonzero only for the digits 0-9. An implementation can define additional characters that return nonzero for some of these functions.
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 or any other locale-specific alphabetic character. isalpha int isalpha(int c); The function returns nonzero if c is any of: a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z or any other locale-specific alphabetic character. iscntrl int iscntrl(int c); The function returns nonzero if c is any of: BEL BS CR FF HT NL VT or any other implementation-defined control character.
a b c d e f g h i j k l m n o p q r s t u v w x y z or any other locale-specific lowercase character. isprint int isprint(int c); The function returns nonzero if c is space or a character for which isgraph returns nonzero. ispunct int ispunct(int c); The function returns nonzero if c is any of: ! " # % & ' ( ) ; < = > ? [ \ ] * + , . / : ^ _ { | } ~ or any other implementation-defined punctuation character.
0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F tolower int tolower(int c); The function returns the corresponding lowercase letter if one exists and if isupper(c); otherwise, it returns c. toupper int toupper(int c); The function returns the corresponding uppercase letter if one exists and if islower(c); otherwise, it returns c. See also the Table of Contents and the Index. Copyright © 1989-2001 by P.J. Plauger and Jim Brodie. All rights reserved.
Next Include the standard header to test the value stored in errno by certain library functions. At program startup, the value stored is zero. Library functions store only values greater than zero. Any library function can alter the value stored, but only those cases where a library function is explicitly required to store a value are documented here.
errno #define errno The macro designates an object that is assigned a value greater than zero on certain library errors. See also the Table of Contents and the Index. Copyright © 1989-2001 by P.J. Plauger and Jim Brodie. All rights reserved.
Next Include the standard header to determine various properties of floating-point type representations. The standard header is available even in a freestanding implementation. You can test only the value of the macro FLT_RADIX in an if directive. All other macros defined in this header expand to expressions whose values can be determined only when the program executes. (These macros are rvalue expressions.
#define #define #define #define #define #define LDBL_MAX = LDBL_MAX_10_EXP LDBL_MIN 10^37> >= 37> 10^(-37)> <= -37> DBL_DIG #define DBL_DIG = 10> The macro yields the precision in decimal digits for type double. DBL_EPSILON #define DBL_EPSILON The macro yields the smallest X of type double such that 1.
DBL_MAX_EXP #define DBL_MAX_EXP The macro yields the maximum integer X, such that FLT_RADIX^(X - 1) is a finite representable value of type double. DBL_MIN #define DBL_MIN The macro yields the smallest normalized, finite representable value of type double. DBL_MIN_10_EXP #define DBL_MIN_10_EXP The macro yields the minimum integer X such that 10^X is a normalized, finite representable value of type double.
FLT_MANT_DIG #define FLT_MANT_DIG The macro yields the number of mantissa digits, base FLT_RADIX, for type float. FLT_MAX #define FLT_MAX = 10^37> The macro yields the largest finite representable value of type float. FLT_MAX_10_EXP #define FLT_MAX_10_EXP = 37> The macro yields the maximum integer X, such that 10^X is a finite representable value of type float.
FLT_MIN_EXP #define FLT_MIN_EXP The macro yields the minimum integer X, such that FLT_RADIX^(X - 1) is a normalized, finite representable value of type float. FLT_RADIX #define FLT_RADIX <#if expression >= 2> The macro yields the radix of all floating-point representations. FLT_ROUNDS #define FLT_ROUNDS The macro yields a value that describes the current rounding mode for floating-point operations.
LDBL_MANT_DIG #define LDBL_MANT_DIG The macro yields the number of mantissa digits, base FLT_RADIX, for type long double. LDBL_MAX #define LDBL_MAX = 10^37> The macro yields the largest finite representable value of type long double. LDBL_MAX_10_EXP #define LDBL_MAX_10_EXP = 37> The macro yields the maximum integer X, such that 10^X is a finite representable value of type long double.
LDBL_MIN_EXP #define LDBL_MIN_EXP The macro yields the minimum integer X, such that FLT_RADIX^(X - 1) is a normalized, finite representable value of type long double. See also the Table of Contents and the Index. Copyright © 1989-2001 by P.J. Plauger and Jim Brodie. All rights reserved.
Next [Added with Amendment 1] Include the standard header to provide readable alternatives to certain operators or punctuators. The standard header is available even in a freestanding implementation.
bitor #define bitor | [keyword in C++] The macro yields the operator |. compl #define compl ~ [keyword in C++] The macro yields the operator ~. not #define not ! [keyword in C++] The macro yields the operator !. not_eq #define not_eq != [keyword in C++] The macro yields the operator !=. or #define or || [keyword in C++] The macro yields the operator ||. or_eq #define or_eq |= [keyword in C++] The macro yields the operator |=. xor #define xor ^ [keyword in C++] The macro yields the operator ^.
xor_eq #define xor_eq ^= [keyword in C++] The macro yields the operator ^=. See also the Table of Contents and the Index. Copyright © 1989-2001 by P.J. Plauger and Jim Brodie. All rights reserved.
Next Include the standard header to determine various properties of the integer type representations. The standard header is available even in a freestanding implementation. You can test the values of all these macros in an if directive. (The macros are #if expressions.
CHAR_MAX #define CHAR_MAX <#if expression >= 127> The macro yields the maximum value for type char. Its value is: ● SCHAR_MAX if char represents negative values ● UCHAR_MAX otherwise CHAR_MIN #define CHAR_MIN <#if expression <= 0> The macro yields the minimum value for type char. Its value is: ● SCHAR_MIN if char represents negative values ● zero otherwise INT_MAX #define INT_MAX <#if expression >= 32,767> The macro yields the maximum value for type int.
MB_LEN_MAX #define MB_LEN_MAX <#if expression >= 1> The macro yields the maximum number of characters that constitute a multibyte character in any supported locale. Its value is >= MB_CUR_MAX. SCHAR_MAX #define SCHAR_MAX <#if expression >= 127> The macro yields the maximum value for type signed char. SCHAR_MIN #define SCHAR_MIN <#if expression <= -127> The macro yields the minimum value for type signed char.
ULONG_MAX #define ULONG_MAX <#if expression >= 4,294,967,295> The macro yields the maximum value for type unsigned long. USHRT_MAX #define USHRT_MAX <#if expression >= 65,535> The macro yields the maximum value for type unsigned short. See also the Table of Contents and the Index. Copyright © 1989-2001 by P.J. Plauger and Jim Brodie. All rights reserved.
Next Include the standard header to alter or access properties of the current locale -- a collection of culture-specific information. An implementation can define additional macros in this standard header with names that begin with LC_. You can use any of these macro names as the locale category argument (which selects a cohesive subset of a locale) to setlocale.
functions, wide-character classification functions, and various multibyte conversion functions. LC_MONETARY #define LC_MONETARY The macro yields the locale category argument value that affects monetary information returned by localeconv.
char char char char char n_sep_by_space; n_sign_posn; p_cs_precedes; p_sep_by_space; p_sign_posn; CHAR_MAX CHAR_MAX CHAR_MAX CHAR_MAX CHAR_MAX LC_MONETARY LC_MONETARY LC_MONETARY LC_MONETARY LC_MONETARY char char char char char char char char }; *int_curr_symbol; int_frac_digits; int_n_cs_precedes; int_n_sep_by_space; int_n_sign_posn; int_p_cs_precedes; int_p_sep_by_space; int_p_sign_posn; "" CHAR_MAX CHAR_MAX CHAR_MAX CHAR_MAX CHAR_MAX CHAR_MAX CHAR_MAX LC_MONETARY LC_MONETARY LC_MONETARY LC_MONETAR
mon_decimal_point -- the decimal point for monetary values (".") mon_grouping -- the sizes of digit groups for monetary values. Successive elements of the string describe groups going away from the decimal point. The encoding is the same as for grouping.
int_p_sep_by_space -- whether the international currency symbol is separated by a space (defined by int_curr_symbol[3]) or by no space from the value for positive monetary values: ● A value of 0 indicates that no space separates symbol and value. ● A value of 1 indicates that a space separates symbol and value. (0) int_p_sign_posn -- the format for positive international monetary values: ● A value of 0 indicates that parentheses surround the value and the currency symbol.
p_sign_posn -- the format for positive monetary values: ● A value of 0 indicates that parentheses surround the value and the currency symbol. ● A value of 1 indicates that the negative sign precedes the value and the currency symbol. ● A value of 2 indicates that the negative sign follows the value and the currency symbol. ● A value of 3 indicates that the negative sign immediately precedes the currency symbol. ● A value of 4 indicates that the negative sign immediately follows the currency symbol.
Copyright © 1989-2001 by P.J. Plauger and Jim Brodie. All rights reserved.
Next
double acos(double x); float acos(float x); [C++ only] long double acos(long double x); [C++ only] float acosf(float x); [required with C99] long double acosl(long double x); [required with C99] double asin(double x); float asin(float x); [C++ only] long double asin(long double x); [C++ only] float asinf(float x); [required with C99] long double asinl(long double x); [required with C99] double atan(double x); float atan(float x); [C++ only] long double atan(long double x); [C++ only] float atanf(float x); [
long double coshl(long double x); [required with C99] double exp(double x); float exp(float x); [C++ only] long double exp(long double x); [C++ only] float expf(float x); [required with C99] long double expl(long double x); [required with C99] double fabs(double x); float fabs(float x); [C++ only] long double fabs(long double x); [C++ only] float fabsf(float x); [required with C99] long double fabsl(long double x); [required with C99] double floor(double x); float floor(float x); [C++ only] long double floo
long double log(long double x); [C++ only] float logf(float x); [required with C99] long double logl(long double x); [required with C99] double log10(double x); float log10(float x); [C++ only] long double log10(long double x); [C++ only] float log10f(float x); [required with C99] long double log10l(long double x); [required with C99] double modf(double x, double *pint); float modf(float x, float *pint); [C++ only] long double modf(long double x, long double *pint); [C++ only] float modff(float x, float *pi
float sqrt(float x); [C++ only] long double sqrt(long double x); [C++ only] float sqrtf(float x); [required with C99] long double sqrtl(long double x); [required with C99] double tan(double x); float tan(float x); [C++ only] long double tan(long double x); [C++ only] float tanf(float x); [required with C99] long double tanl(long double x); [required with C99] double tanh(double x); float tanh(float x); [C++ only] long double tanh(long double x); [C++ only] float tanhf(float x); [required with C99] long doub
asin, asinf, asinl double asin(double x); float asin(float x); [C++ only] long double asin(long double x); [C++ only] float asinf(float x); [required with C99] long double asinl(long double x); [required with C99] The function returns the angle whose sine is x, in the range [-pi/2, +pi/2] radians. A domain error occurs if 1 < |x|.
cos, cosf, cosl double cos(double x); float cos(float x); [C++ only] long double cos(long double x); [C++ only] float cosf(float x); [required with C99] long double cosl(long double x); [required with C99] The function returns the cosine of x. If x is large the value returned might not be meaningful, but the function reports no error.
fmod, fmodf, fmodl double fmod(double x, double y); float fmod(float x, float y); [C++ only] long double fmod(long double x, long double y); [C++ only] float fmodf(float x, float y); [required with C99] long double fmodl(long double x, long double y); [required with C99] The function returns the remainder of x/y, which is defined as follows: ● If y is zero, the function either reports a domain error or simply returns zero.
float ldexpf(float x, int ex); [required with C99] long double ldexpl(long double x, int ex); [required with C99] The function returns x * 2^ex. log, logf, logl double log(double x); float log(float x); [C++ only] long double log(long double x); [C++ only] float logf(float x); [required with C99] long double logl(long double x); [required with C99] The function returns the natural logarithm of x. A domain error occurs if x < 0.
pow, powf, powl double pow(double x, double y); float pow(float x, float y); [C++ only] long double pow(long double x, long double y); [C++ only] double pow(double x, int y); [C++ only] float pow(float x, int y); [C++ only] long double pow(long double x, int y); [C++ only] float powf(float x, float y); [required with C99] long double powl(long double x, long double y); [required with C99] The function returns x raised to the power y, x^y.
tan, tanf, tanl double tan(double x); float tan(float x); [C++ only] long double tan(long double x); [C++ only] float tanf(float x); [required with C99] long double tanl(long double x); [required with C99] The function returns the tangent of x. If x is large the value returned might not be meaningful, but the function reports no error.
Next Include the standard header to perform control transfers that bypass the normal function call and return protocol. #define setjmp(jmp_buf env) typedef a-type jmp_buf; void longjmp(jmp_buf env, int val); jmp_buf typedef a-type jmp_buf; The type is the array type a-type of an object that you declare to hold the context information stored by setjmp and accessed by longjmp.
operand an integer constant expression You can write such an expression only as the expression part of a do, expression, for, if, if-else, switch,, or while statement. See also the Table of Contents and the Index. Copyright © 1989-2001 by P.J. Plauger and Jim Brodie. All rights reserved.
Next Include the standard header to specify how the program handles signals while it executes. A signal can report some exceptional behavior within the program, such as division by zero. Or a signal can report some asynchronous event outside the program, such as someone striking an interactive attention key on a keyboard. You can report any signal by calling raise. Each implementation defines what signals it generates (if any) and under what circumstances it generates them.
/* TYPES */ typedef i-type sig_atomic_t; /* FUNCTIONS */ int raise(int sig); void (*signal(int sig, void (*func)(int)))(int); raise int raise(int sig); The function sends the signal sig and returns zero if the signal is successfully reported. sig_atomic_t typedef i-type sig_atomic_t; The type is the integer type i-type for objects whose stored value is altered by an assigning operator as an atomic operation (an operation that never has its execution suspended while partially completed).
SIGINT #define SIGINT = 0> The macro yields the sig argument value for the asynchronous interactive attention signal. signal void (*signal(int sig, void (*func)(int)))(int); The function specifies the new handling for signal sig and returns the previous handling, if successful; otherwise, it returns SIG_ERR. ● ● ● If func is SIG_DFL, the target environment commences default handling (as defined by the implementation).
SIG_DFL #define SIG_DFL
The macro yields the func argument value to signal to specify default signal handling. SIG_ERR #define SIG_ERR The macro yields the signal return value to specify an erroneous call. SIG_IGN #define SIG_IGN The macro yields the func argument value to signal to specify that the target environment is to henceforth ignore the signal. See also the Table of Contents and the Index.Next Include the standard header to access the unnamed additional arguments (arguments with no corresponding parameter declarations) in a function that accepts a varying number of arguments. To access the additional arguments: ● The program must first execute the macro va_start within the body of the function to initialize an object with context information.
string (assuming that the existing string is stored in an object large enough to hold the resulting string). #define va_arg(va_list ap, Ty) #define va_end(va_list ap) #define va_start(va_list ap, last-par) typedef do-type va_list; va_arg #define va_arg(va_list ap, Ty) The macro yields the value of the next argument in order, specified by the context information designated by ap.
● a reference type [C++ only] See also the Table of Contents and the Index. Copyright © 1989-2001 by P.J. Plauger and Jim Brodie. All rights reserved.
Next Include the standard header to define several types and macros that are of general use throughout the program. The standard header is available even in a freestanding implementation.
size_t typedef ui-type size_t; The type is the unsigned integer type ui-type of an object that you declare to store the result of the sizeof operator. wchar_t typedef i-type wchar_t; [keyword in C++] The type is the integer type i-type of a wide-character constant, such as L'X'. You declare an object of type wchar_t to hold a wide character. See also the Table of Contents and the Index. Copyright © 1989-2001 by P.J. Plauger and Jim Brodie. All rights reserved.
Next
typedef o-type FILE; typedef o-type fpos_t; typedef ui-type size_t; /* FUNCTIONS */ void clearerr(FILE *stream); int fclose(FILE *stream); int feof(FILE *stream); int ferror(FILE *stream); int fflush(FILE *stream); FILE *fopen(const char *filename, const char *mode); FILE *freopen(const char *filename, const char *mode, FILE *stream); int remove(const char *filename); int rename(const char *old, const char *new); void rewind(FILE *stream); void setbuf(FILE *stream, char *buf); int setvbuf(FILE *stream, char
int putc(int c, FILE *stream); int putchar(int c); int puts(const char *s); int fscanf(FILE *stream, const char *format, ...); int scanf(const char *format, ...); int sscanf(const char *s, const char *format, ...); int int int int fprintf(FILE *stream, const char *format, ...); printf(const char *format, ...); sprintf(char *s, const char *format, ...
otherwise, it returns EOF. fclose writes any buffered output to the file, deallocates the stream buffer if it was automatically allocated, and removes the association between the stream and the file. Do not use the value of stream in subsequent expressions. feof int feof(FILE *stream); The function returns a nonzero value if the end-of-file indicator is set for the stream stream. ferror int ferror(FILE *stream); The function returns a nonzero value if the error indicator is set for the stream stream.
fgets char *fgets(char *s, int n, FILE *stream); The function reads characters from the input stream stream and stores them in successive elements of the array beginning at s and continuing until it stores n-1 characters, stores an NL character, or sets the end-of-file or error indicators. If fgets stores any characters, it concludes by storing a null character in the next element of the array.
● ● ● ● ● ● file-position indicator is positioned at the end of the file (possibly after arbitrary null byte padding) before each write "r+" -- to open an existing text file for reading and writing "w+" -- to create a text file or to open and truncate an existing text file, for reading and writing "a+" -- to create a text file or to open an existing text file, for reading and writing.
fputc int fputc(int c, FILE *stream); The function writes the character (unsigned char)c to the output stream stream, advances the file-position indicator (if defined), and returns (int)(unsigned char)c. If the function sets the error indicator for the stream, it returns EOF. fputs int fputs(const char *s, FILE *stream); The function accesses characters from the C string s and writes them to the output stream stream. The function does not write the terminating null character.
arguments. It obtains each scanned character from the stream stream. It returns the number of input items matched and assigned, or it returns EOF if the function does not store values before it sets the end-of-file or error indicator for the stream. fseek int fseek(FILE *stream, long offset, int mode); The function sets the file-position indicator for the stream stream (as specified by offset and mode), clears the end-of-file indicator for the stream, and returns zero if successful.
ftell long ftell(FILE *stream); The function returns an encoded form of the file-position indicator for the stream stream or stores a positive value in errno and returns the value -1. For a binary file, a successful return value gives the number of bytes from the beginning of the file. For a text file, target environments can vary on the representation and range of encoded file-position indicator values.
characters and has not set the error indicator for the stream; otherwise, it returns a null pointer. If it sets the error indicator, the array contents are indeterminate. The number of characters that gets reads and stores cannot be limited. Use fgets instead. _IOFBF #define _IOFBF The macro yields the value of the mode argument to setvbuf to indicate full buffering. (Flush the stream buffer only when it fills.
perror void perror(const char *s); The function writes a line of text to the stream stderr. If s is not a null pointer, the function first writes the C string s (as if by calling fputs(s, stderr)), followed by a colon (:) and a space. It then writes the same message C string that is returned by strerror(errno), converting the value stored in errno, followed by an NL. printf int printf(const char *format, ...
remove int remove(const char *filename); The function removes the file with the filename filename and returns zero if successful. If the file is open when you remove it, the result is implementation defined. After you remove it, you cannot open it as an existing file. rename int rename(const char *old, const char *new); The function renames the file with the filename old to have the filename new and returns zero if successful.
SEEK_END #define SEEK_END The macro yields the value of the mode argument to fseek to indicate seeking relative to the end of the file. SEEK_SET #define SEEK_SET The macro yields the value of the mode argument to fseek to indicate seeking relative to the beginning of the file.
size_t typedef ui-type size_t; The type is the unsigned integer type ui-type of an object that you declare to store the result of the sizeof operator. sprintf int sprintf(char *s, const char *format, ...); The function generates formatted text, under the control of the format format and any additional arguments, and stores each generated character in successive locations of the array object whose first element has the address s.
stdout #define stdout The macro yields a pointer to the object that controls the standard output stream. tmpfile FILE *tmpfile(void) The function creates a temporary binary file with the filename temp-name and then has the same effect as calling fopen(temp-name, "wb+"). The file temp-name is removed when the program closes it, either by calling fclose explicitly or at normal program termination. The filename temp-name does not conflict with any filenames that you create.
function returns EOF; otherwise, it returns (unsigned char)c. A subsequent library function call that reads a character from the stream stream obtains this stored value, which is then forgotten. Thus, you can effectively push back a character to a stream after reading a character. (You need not push back the same character that you read.) An implementation can let you push back additional characters before you read the first one. You read the characters in reverse order of pushing them back to the stream.
vsprintf int vsprintf(char *s, const char *format, va_list ap); The function generates formatted text, under the control of the format format and any additional arguments, and stores each generated character in successive locations of the array object whose first element has the address s. The function concludes by storing a null character in the next location of the array. It returns the number of characters generated -- not including the null character.
Next EXIT_FAILURE · EXIT_SUCCESS · MB_CUR_MAX · NULL · RAND_MAX abort · abs · atexit · atof · atoi div · div_t · exit · free · getenv malloc · mblen · mbstowcs · mbtowc size_t · srand · strtod · strtol · wcstombs · wctomb · atol · bsearch · calloc · · labs · ldiv · ldiv_t · · qsort · rand · realloc · strtoul · system · wchar_t · Include the standard header to declare an assortment of useful functions and to define the macros and types that help you use them.
ldiv_t ldiv(long numer, long denom); int rand(void); void srand(unsigned int seed); double atof(const char *s); int atoi(const char *s); long atol(const char *s); double strtod(const char *s, char **endptr); long strtol(const char *s, char **endptr, int base); unsigned long strtoul(const char *s, char **endptr, int base); void void void void *calloc(size_t nelem, size_t size); free(void *ptr); *malloc(size_t size); *realloc(void *ptr, size_t size); int mblen(const char *s, size_t n); size_t mbstowcs(wchar
void *bsearch(const void *key, const void *base, size_t nelem, size_t size, int (*cmp)(const void *ck, const void *ce)); extern "C++" void qsort(void *base, size_t nelem, int (*cmp)(const void *e1, const [C++ only] extern "C" [C++ only] void qsort(void *base, size_t nelem, int (*cmp)(const void *e1, const size_t size, void *e2)); size_t size, void *e2)); abort void abort(void); The function calls raise(SIGABRT), which reports the abort signal, SIGABRT.
Furthermore, in C++, if control leaves a called function because it fails to handle a thrown exception, terminate is called. atof double atof(const char *s); The function converts the initial characters of the string s to an equivalent value x of type double and then returns x. The conversion is the same as for strtod(s, 0), except that a value is not necessarily stored in errno if a conversion error occurs.
consists of nelem elements, each of size bytes, beginning with the element whose address is base. bsearch calls the comparison function whose address is cmp to compare the search key with elements of the array.
exit void exit(int status); The function calls all functions registered by atexit, closes all files, and returns control to the target environment. If status is zero or EXIT_SUCCESS, the program reports successful termination. If status is EXIT_FAILURE, the program reports unsuccessful termination. An implementation can define additional values for status.
labs long labs(long i); The function returns the absolute value of i, |i|, the same as abs. ldiv ldiv_t ldiv(long numer, long denom); The function divides numer by denom and returns both quotient and remainder in the structure result x, if the quotient can be represented. The structure member x.quot is the algebraic quotient truncated toward zero. The structure member x.rem is the remainder, such that numer == x.quot*denom + x.rem.
mblen int mblen(const char *s, size_t n); If s is not a null pointer, the function returns the number of bytes in the multibyte string s that constitute the next multibyte character, or it returns -1 if the next n (or the remaining) bytes do not constitute a valid multibyte character. mblen does not include the terminating null in the count of bytes. The function can use a conversion state stored in an internal static-duration object to determine how to interpret the multibyte string.
NULL #define NULL [0 in C++] The macro yields a null pointer constant that is usable as an address constant expression.
whose size is not greater than size. If ptr is not a null pointer, it must be the address of an existing object that you first allocate by calling calloc, malloc, or realloc. If the existing object is not larger than the newly allocated object, realloc copies the entire existing object to the initial part of the allocated object. (The values stored in the remainder of the object are indeterminate.) Otherwise, the function copies only the initial part of the existing object that fits in the allocated object.
Here, a point is the decimal-point character for the current locale. (It is the dot (.) in the "C" locale.) If the string s matches this pattern, its equivalent value is the decimal integer represented by any digits to the left of the point, plus the decimal fraction represented by any digits to the right of the point, times 10 raised to the signed decimal integer power that follows an optional e or E. A leading minus sign negates the value.
In locales other than the "C" locale, strtol can define additional patterns as well. If the string s does not match a valid pattern, the value stored in *endptr is s, and x is zero. If the equivalent value is too large to represent as type long, strtol stores the value of ERANGE in errno and returns either LONG_MAX, if x is positive, or LONG_MIN, if x is negative.
multibyte string begins in the initial conversion state. The function converts each wide character as if by calling wctomb (except that the conversion state stored for that function is unaffected). It stores no more than n bytes, stopping after it stores a null byte. It returns the number of bytes it stores, not counting the null byte, if all conversions are successful; otherwise, it returns -1.
Next memchr · strcat · · strlen strspn · memcmp · memcpy · memmove · memset · NULL · size_t · strchr · strcmp · strcoll · strcpy · strcspn · strerror · strncat · strncmp · strncpy · strpbrk · strrchr · strstr · strtok · strxfrm Include the standard header to declare a number of functions that help you manipulate C strings and other arrays of characters.
const void *memchr(const void *s, int c, size_t n); [C++ only] void *memchr(void *s, int c, size_t n); [C++ only] char *strchr(const char *s, int c); [not in C++] const char *strchr(const char *s, int c); [C++ only] char *strchr(char *s, int c); [C++ only] char *strpbrk(const char *s1, const char *s2); [not in C++] const char *strpbrk(const char *s1, const char *s2); [C++ only] char *strpbrk(char *s1, const char *s2); [C++ only] char *strrchr(const char *s, int c); [not in C++] const char *strrchr(const cha
● ● ● If all elements are equal, the function returns zero. If the differing element from s1 is greater than the element from s2, the function returns a positive number. Otherwise, the function returns a negative number. memcpy void *memcpy(void *s1, const void *s2, size_t n); The function copies the array of char beginning at the address s2 to the array of char beginning at the address s1 (both of size n). It returns s1. The elements of the arrays can be accessed and stored in any order.
strcat char *strcat(char *s1, const char *s2); The function copies the string s2, including its terminating null character, to successive elements of the array of char that stores the string s1, beginning with the element that stores the terminating null character of s1. It returns s1.
The function copies the string s2, including its terminating null character, to successive elements of the array of char whose first element has the address s1. It returns s1. strcspn size_t strcspn(const char *s1, const char *s2); The function searches for the first element s1[i] in the string s1 that equals any one of the elements of the string s2 and returns i. Each terminating null character is considered part of its string.
● unsigned char), the function returns a positive number. Otherwise, it returns a negative number. strncpy char *strncpy(char *s1, const char *s2, size_t n); The function copies the string s2, not including its terminating null character, to successive elements of the array of char whose first element has the address s1. It copies no more than n characters from s2. The function then stores zero or more null characters in the next elements to be altered in s1 until it stores a total of n characters.
strstr char *strstr(const char *s1, const char *s2); [not in C++] const char *strstr(const char *s1, const char *s2); [C++ only] char *strstr(char *s1, const char *s2); [C++ only] The function searches for the first sequence of elements in the string s1 that matches the sequence of elements in the string s2, not including its terminating null character. If successful, the function returns the address of the matching first element; otherwise, it returns a null pointer.
s1 can be a null pointer.) strxfrm generates the string it stores from the string s2 by using a transformation rule that depends on the current locale. For example, if x is a transformation of s1 and y is a transformation of s2, then strcmp(x, y) returns the same value as strcoll(s1, s2). See also the Table of Contents and the Index. Copyright © 1989-2001 by P.J. Plauger and Jim Brodie. All rights reserved.
Next Include the standard header to declare several functions that help you manipulate times. The diagram summarizes the functions and the object types that they convert between. The functions share two static-duration objects that hold values computed by the functions: ● a time string of type array of char ● a time structure of type struct tm A call to one of these functions can alter the value that was stored earlier in a static-duration object by another of these functions.
The function stores in the static-duration time string a 26-character English-language representation of the time encoded in *tptr. It returns the address of the static-duration time string. The text representation takes the form: Sun Dec 2 06:55:15 1979\n\0 clock clock_t clock(void); The function returns the number of clock ticks of elapsed processor time, counting from a time related to program startup, or it returns -1 if the target environment cannot measure elapsed processor time.
localtime struct tm *localtime(const time_t *tod); The function stores in the static-duration time structure an encoding of the calendar time in *tod, expressed as local time. It returns the address of that structure. mktime time_t mktime(struct tm *tptr); The function alters the values stored in *tptr to represent an equivalent encoded local time, but with the values of all members within their normal ranges. It then determines the values tptr->wday and tptr->yday from the values of the other members.
EST. For a Sunday week of the year, week 1 begins with the first Sunday on or after 1 January. For a Monday week of the year, week 1 begins with the first Monday on or after 1 January. An ISO 8601 week of the year is the same as a Monday week of the year, with the following exceptions: ● If 1 January is a Tuesday, Wednesday, or Thursday, the week number is one greater. Moreover, days back to and including the immediately preceding Monday in the preceding year are included in week 1 of the current year.
%R %S %t %T %u %U %V %w %W %x %Ex %X %EX %y %Ey %Y %EY %z %Z %% tm_mday tm_mon tm_year tm_min tm_hour tm_sec tm_sec tm_min tm_hour tm_wday tm_wday tm_yday tm_wday tm_yday tm_year tm_wday tm_wday tm_yday [all] [all] [all] [all] tm_year tm_mday tm_mon tm_year tm_year tm_mday tm_mon tm_year tm_isdst tm_isdst + hour:minute, from 01:00 (06:55) seconds after the minute (15) + horizontal tab character \t + 24-hour time, from 00:00:00 (06:55:15) + ISO 8601 day of the week, to 7 for Sunday (7) Sunday week of
tm struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; }; seconds after the minute (from 0) minutes after the hour (from 0) hour of the day (from 0) day of the month (from 1) month of the year (from 0) years since 1900 (from 0) days since Sunday (from 0) day of the year (from 0) Daylight Saving Time flag struct tm contains members that describe various properties of the calendar time.
Next
int fwscanf(FILE *stream, const wchar_t *format, ...); int swscanf(const wchar_t *s, const wchar_t *format, ...); int wscanf(const wchar_t *format, ...); int fwprintf(FILE *stream, const wchar_t *format, ...); int swprintf(wchar_t *s, size_t n, const wchar_t *format, ...); int wprintf(const wchar_t *format, ...
int wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n); wchar_t *wcsncpy(wchar_t *s1, const wchar_t *s2, size_t n); size_t wcsspn(const wchar_t *s1, const wchar_t *s2); wchar_t *wcsstr(const wchar_t *s1, const wchar_t *s2); wchar_t *wcstok(wchar_t *s1, const wchar_t *s2, wchar_t **ptr); size_t wcsxfrm(wchar_t *s1, const wchar_t *s2, size_t n); int wmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n); wchar_t *wmemcpy(wchar_t *s1, const wchar_t *s2, size_t n); wchar_t *wmemmove(wchar_t *s1, const wch
succeeds, the function returns the wide-character conversion. Otherwise, it returns WEOF. fgetwc wint_t fgetwc(FILE *stream); The function reads the next wide character c (if present) from the input stream stream, advances the file-position indicator (if defined), and returns (wint_t)c. If the function sets either the end-of-file indicator or the error indicator, it returns WEOF.
● a value less than zero if the stream is left byte oriented In no event will the function alter the orientation of a stream once it has been oriented. fwprintf int fwprintf(FILE *stream, const wchar_t *format, ...); The function generates formatted text, under the control of the format format and any additional arguments, and writes each generated wide character to the stream stream.
● (size_t)-1 if the function detects an encoding error before completing the next multibyte character, in which case the function stores the value EILSEQ in errno and leaves the resulting conversion state undefined ● zero, if the next completed character is a null character, in which case the resulting conversion state is the initial conversion state ● x, the number of bytes needed to complete the next muitibyte character, in which case the resulting conversion state indicates that x bytes have been co
mbsinit int mbsinit(const mbstate_t *ps); The function returns a nonzero value if ps is a null pointer or if *ps designates an initial conversion state. Otherwise, it returns zero.
NULL #define NULL [0 in C++] The macro yields a null pointer constant that is usable as an address constant expression. putwc wint_t putwc(wchar_t c, FILE *stream); The function has the same effect as fputwc(c, stream) except that a macro version of putwc can evaluate stream more than once. putwchar wint_t putwchar(wchar_t c); The function has the same effect as fputwc(c, stdout).
tm struct tm; struct tm contains members that describe various properties of the calendar time. The declaration in this header leaves struct tm an incomplete type. Include the header to complete the type. ungetwc wint_t ungetwc(wint_t c, FILE *stream); If c is not equal to WEOF, the function stores (wchar_t)c in the object whose address is stream and clears the end-of-file indicator. If c equals WEOF or the store cannot occur, the function returns WEOF; otherwise, it returns (wchar_t)c.
vwprintf int vwprintf(const wchar_t *format, va_list arg); The function generates formatted text, under the control of the format format and any additional arguments, and writes each generated wide character to the stream stdout. It returns the number of characters generated, or a negative value if the function sets the error indicator for the stream. The function accesses additional arguments by using the context information designated by ap.
any shift sequence needed to restore the initial shift state. followed by a null byte. The resulting conversion state is the initial conversion state. If s is a null pointer, the function effectively returns wcrtomb(buf, L'\0', ps), where buf is a buffer internal to the function. (The function thus returns the number of bytes needed to restore the initial conversion state and to terminate the multibyte string pending from a previous call to wcrtomb or wcsrtombs for the same string and conversion state.
The function compares two wide strings, s1 and s2, using a comparison rule that depends on the current locale. If s1 compares greater than s2 by this rule, the function returns a positive number. If the two wide strings compare equal, it returns zero. Otherwise, it returns a negative number. wcscpy wchar_t *wcscpy(wchar_t *s1, const wchar_t *s2); The function copies the wide string s2, including its terminating null wide character, to successive elements of the array whose first element has the address s1.
elements of the array that stores the wide string s1, beginning with the element that stores the terminating null wide character of s1. The function copies no more than n wide characters from s2. It then stores a null wide character, in the next element to be altered in s1, and returns s1.
wcsrtombs size_t wcsrtombs(char *dst, const wchar_t **src, size_t len, mbstate_t *ps); The function converts the wide-character string beginning at *src to a sequence of multibyte characters as if by repeated calls of the form: x = wcrtomb(dst ? dst : buf, *src, ps != 0 ? ps : &internal) where buf is an array of type char and internal is an object of type mbstate_t, both internal to the wcsrtombs function. At program startup, internal is initialized to the initial conversion state.
The function converts the initial wide characters of the wide string s to an equivalent value x of type double. If endptr is not a null pointer, the function stores a pointer to the unconverted remainder of the wide string in *endptr. The function then returns x. The initial wide characters of the wide string s must match the same pattern as recognized by the function strtod, where each wide character wc is converted as if by calling wctob(wc)).
as type long, wcstol stores the value of ERANGE in errno and returns either LONG_MAX if x is positive or LONG_MIN if x is negative. wcstoul unsigned long wcstoul(const wchar_t *nptr, wchar_t **endptr, int base); The function converts the initial wide characters of the wide string s to an equivalent value x of type unsigned long. If endptr is not a null pointer, it stores a pointer to the unconverted remainder of the wide string in *endptr. The function then returns x.
wint_t typedef i_type wint_t; The type is the integer type i_type that can represent all values of type wchar_t as well as the value of the macro WEOF, and that doesn't change when promoted.
wmemset wchar_t *wmemset(wchar_t *s, wchar_t c, size_t n); The function stores c in each of the elements of the array beginning at s, with size n. It returns s. wprintf int wprintf(const wchar_t *format, ...); The function generates formatted text, under the control of the format format and any additional arguments, and writes each generated wide character to the stream stdout.
Next [Added with Amendment 1] iswalnum · iswalpha · iswcntrl · iswdigit · iswgraph · iswlower · iswprint · iswpunct · iswspace · iswupper · iswxdigit · towlower · towctrans · towupper · wctrans · wctype Include the standard header to declare several functions that are useful for classifying and mapping codes from the target wide-character set. Every function that has a parameter of type wint_t can accept the value of the macro WEOF or any valid wide-character code (of type wchar_t).
Note that the last rule differs slightly from the corresponding rule for the function isspace, as indicated above. Note also that an implementation can define a locale other than the "C" locale in which a character can cause iswalpha (and hence iswalnum) to return nonzero, yet still cause iswupper and iswlower to return zero. WEOF #define WEOF The macro yields the return value, of type wint_t, used to signal the end of a wide stream or to report an error condition.
iswalnum int iswalnum(wint_t c); The function returns nonzero if c is any of: a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 or any other locale-specific alphabetic character. iswalpha int iswalpha(wint_t c); The function returns nonzero if c is any of: a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z or any other locale-specific alphabetic character.
iswgraph int iswgraph(wint_t c); The function returns nonzero if c is any character for which either iswalnum or iswpunct returns nonzero. iswlower int iswlower(wint_t c); The function returns nonzero if c is any of: a b c d e f g h i j k l m n o p q r s t u v w x y z or any other locale-specific lowercase character.
iswupper int iswupper(wint_t c); The function returns nonzero if c is any of: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z or any other locale-specific uppercase character. iswxdigit int iswxdigit(wint_t c); The function returns nonzero if c is any of 0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F towctrans wint_t towctrans(wint_t c, wctrans_t category); The function returns the transformation of the character c, using the transform in the category category.
LC_CTYPE category of the current locale does not define a mapping whose name matches the property string property, the function returns zero. Otherwise, it returns a nonzero value suitable for use as the second argument to a subsequent call to towctrans.
wctype_t typedef s_type wctype_t; The type is the scalar type s-type that can represent locale-specific character classifications, as specified by the return value of wctype. wint_t typedef i_type wint_t; The type is the integer type i_type that can represent all values of type wchar_t as well as the value of the macro WEOF, and that doesn't change when promoted. See also the Table of Contents and the Index. Copyright © 1989-2001 by P.J. Plauger and Jim Brodie. All rights reserved.
Next Include the traditional header to effectively include the standard header and hoist its names outside the std namespace. In this implementation, all names are hoisted, to provide a more traditional library environment. #include using namespace std; See also the Table of Contents and the Index. Copyright © 1992-2001 by P.J. Plauger. All rights reserved.
Next Include the traditional header to effectively include the standard header and hoist its names outside the std namespace. In this implementation, all names are hoisted, to provide a more traditional library environment. #include using namespace std; See also the Table of Contents and the Index. Copyright © 1992-2001 by P.J. Plauger. All rights reserved.
Next Include the traditional header to effectively include the standard header and hoist its names outside the std namespace. In this implementation, all names are hoisted, to provide a more traditional library environment. #include using namespace std; In this implementation, does not declare the wide oriented stream objects wcin, wcout, wcerr, and wclog. See also the Table of Contents and the Index. Copyright © 1992-2001 by P.J. Plauger.
Next Include the traditional header to effectively include the standard header and hoist its names outside the std namespace. In this implementation, all names are hoisted, to provide a more traditional library environment. #include using namespace std; See also the Table of Contents and the Index. Copyright © 1992-2001 by P.J. Plauger. All rights reserved.
Next Include the special header to effectively include all the standard headers that constitute the Standard Template Library (STL) and hoist their names outside the std namespace. The header also defines macro names that redefine the STL container template classes to match their more traditional definitions.
Next C++ Library Overview Using C++ Library Headers · C++ Library Conventions · Iostreams Conventions · Program Startup and Termination All C++ library entities are declared or defined in one or more standard headers. To make use of a library entity in a program, write an include directive that names the relevant standard header. The Standard C++ library consists of 51 required headers.
you guess wrong about its actual dependencies.) A Standard C header never includes another standard header. A standard header declares or defines only the entities described for it in this document. Every function in the library is declared in a standard header. Unlike in Standard C, the standard header never provides a masking macro, with the same name as the function, that masks the function declaration and achieves the same effect.
C++ Library Conventions The C++ library obeys much the same conventions as the Standard C library, plus a few more outlined here. An implementation has certain latitude in how it declares types and functions in the C++ library: ● Names of functions in the Standard C library may have either extern "C++" or extern "C" linkage. Include the appropriate Standard C header rather than declare a library entity inline.
IostreamsConventions The iostreams headers support conversions between text and encoded forms, and input and output to external files: , , , , , , , , , and . The simplest use of iostreams requires only that you include the header . You can then extract values from cin, to read the standard input. The rules for doing so are outlined in the description of the class basic_istream.
terminate(). See also the Table of Contents and the Index. Copyright © 1992-2001 by P.J. Plauger. All rights reserved.
Next C Library Overview Using Standard C Headers · C Library Conventions · Program Startup and Termination All Standard C library entities are declared or defined in one or more standard headers. To make use of a library entity in a program, write an include directive that names the relevant standard header. The full set of Standard C headers constitutes a hosted implementation: , , , , , , , , , ,
declaration and achieves the same effect. The macro typically expands to an expression that executes faster than a call to the function of the same name. The macro can, however, cause confusion when you are tracing or debugging the program. So you can use a standard header in two ways to declare or define a library function. To take advantage of any macro version, include the standard header so that each apparent call to the function can be replaced by a macro expansion. For example: #include
C Library Conventions A library macro that masks a function declaration expands to an expression that evaluates each of its arguments once (and only once). Arguments that have side effects evaluate the same way whether the expression executes the macro expansion or calls the function. Macros for the functions getc and putc are explicit exceptions to this rule. Their stream arguments can be evaluated more than once. Avoid argument expressions that have side effects with these macros.
when the description of the library function spells out what happens when you use a null pointer. Some examples are: strcpy(s1, 0) memcpy(s1, 0, 0) realloc(0, 50) is INVALID is UNSAFE is the same as malloc(50) Program Startup and Termination The target environment controls the execution of the program (in contrast to the translator part of the implementation, which prepares the parts of the program for execution).
that have static duration. It also opens three standard streams, controlled by the text-stream objects designated by the macros: ● stdin -- for standard input ● stdout -- for standard output ● stderr -- for standard error output If main returns to its caller, the target environment calls exit with the value returned from main as the status argument to exit. If the return statement that the program executes has no expression, the status argument is undefined.
Next Characters Character Sets · Character Sets and Locales · Escape Sequences · Numeric Escape Sequences · Trigraphs · Multibyte Characters · Wide-Character Encoding Characters play a central role in Standard C. You represent a C program as one or more source files. The translator reads a source file as a text stream consisting of characters that you can read when you display the stream on a terminal screen or produce hard copy with a printer. You often manipulate text when a C program executes.
underscore _ punctuation ! " # % & ' ( ) * + , - .
Mnemonic escape sequences help you remember the characters they represent: Character Escape Sequence " \" ' \' ? \? \ \\ BEL \a BS \b FF \f NL \n CR \r HT \t VT \v Numeric Escape Sequences You can also write numeric escape sequences using either octal or hexadecimal digits. An octal escape sequence takes one of the forms: \d or \dd or \ddd The escape sequence yields a code value that is the numeric value of the 1-, 2-, or 3-digit octal number following the backslash (\).
● ● You can write a string literal that begins with a specific numeric value: "\3abc" which becomes the array {3, 'a', 'b', 'c', 0} You can write a string literal that contains the hexadecimal escape sequence \xF followed by the digit 3 by writing two string literals: "\xF" "3" which becomes the array {0xF, '3', 0} Trigraphs A trigraph is a sequence of three characters that begins with two question marks (??).
Multibyte Characters A source character set or target character set can also contain multibyte characters (sequences of one or more bytes). Each sequence represents a single character in the extended character set. You use multibyte characters to represent large sets of characters, such as Kanji.
You can write multibyte characters in C source text as part of a comment, a character constant, a string literal, or a filename in an include directive. How such characters print is implementation defined. Each sequence of multibyte characters that you write must begin and end in the initial shift state. The program can also include multibyte characters in null-terminated C strings used by several library functions, including the format strings for printf and scanf.
Next Files and Streams Text and Binary Streams · Byte and Wide Streams · Controlling Streams · Stream States A program communicates with the target environment by reading and writing files (ordered sequences of bytes). A file can be, for example, a data set that you can read and write repeatedly (such as a disk file), a stream of bytes generated by a program (such as a pipeline), or a stream of bytes received from or sent to a peripheral device (such as the keyboard or display).
Text and Binary Streams A text stream consists of one or more lines of text that can be written to a text-oriented display so that they can be read. When reading from a text stream, the program reads an NL (newline) at the end of each line. When writing to a text stream, the program writes an NL to signal the end of a line.
which can have a broad range of encoding rules. (Text and binary files are still read and written as described above.) Within the program, the stream looks like the corresponding sequence of wide characters. Conversions between the two representations occur within the Standard C library. The conversion rules can, in principle, be altered by a call to setlocale that alters the category LC_CTYPE.
stream argument to a library function. Stream States The valid states, and state transitions, for a stream are shown in the diagram. Each of the circles denotes a stable state. Each of the lines denotes a transition that can occur as the result of a function call that operates on the stream. Five groups of functions can cause state transitions. Functions in the first three groups are declared in
vfwprintf, vwprintf, and wprintf, For the stream s, the call fwide(s, 0) is always valid and never causes a change of state. Any other call to fwide, or to any of the five groups of functions described above, causes the state transition shown in the state diagram. If no such transition is shown, the function call is invalid. The state diagram shows how to establish the orientation of a stream: ● The call fwide(s, -1), or to a byte read or byte write function, establishes the stream as byte oriented.
Next Formatted Output Print Formats · Print Functions · Print Conversion Specifiers Several library functions help you convert data values from encoded internal representations to text sequences that are generally readable by people. You provide a format string as the value of the format argument to each of these functions, hence the term formatted output. The functions fall into two categories. The byte print functions (declared in
one of the print conversion specifications described below. A print function scans the format string once from beginning to end to determine what conversions to perform. Every print function accepts a varying number of arguments, either directly or under control of an argument of type va_list. Some print conversion specifications in the format string use the next argument in the list. A print function uses each successive argument no more than once. Trailing arguments can be left unused.
(which must be of type int) as the field width. If the argument value is negative, it supplies a format flag and its magnitude is the field width. Following any field width, you can write a dot (.
%G %LG double x long double x (double)x (long double)x 10 10 6 6 %i %hi %li int x int x long x (int)x (short)x (long)x 10 10 10 1 1 1 %n %hn %ln int *x short *x long *x %o %ho %lo int x int x long x (unsigned int)x (unsigned short)x (unsigned long)x 8 8 8 1 1 1 %p void *x (void *)x %s %ls char x[] wchar_t x[] x[0]... x[0]...
You write %c to generate a single character from the converted value. printf("%c", 'a') generates a printf("<%3c|%-3c>", 'a', 'b') generates < a|b > For a wide stream, conversion of the character x occurs as if by calling btowc(x). wprintf(L"%c", 'a') generates btowc(a) You write %lc to generate a single character from the converted value.
%f conversion occurs instead. The generated text has no trailing zeros in any fraction and has a decimal point only if there are nonzero fraction digits, unless you specify the # format flag. printf("%.6g", 31.4) generates 31.4 printf("%.1g", 31.4) generates 3.14e+01 You write %n to store the number of characters generated (up to this point in the format) in an integer object whose address is the value of the next successive argument.
Next Formatted Input Scan Formats · Scan Functions · Scan Conversion Specifiers Several library functions help you convert data values from text sequences that are generally readable by people to encoded internal representations. You provide a format string as the value of the format argument to each of these functions, hence the term formatted input. The functions fall into two categories: The byte scan functions (declared in
Scan Functions For the scan functions, literal text in a format string must match the next characters to scan in the input text. White space in a format string must match the longest possible sequence of the next zero or more white-space characters in the input. Except for the scan conversion specifier %n (which consumes no input), each scan conversion specification determines a pattern that one or more of the next characters in the input must match.
Scan Conversion Specifiers Following any field width, you must write a one-character scan conversion specifier, either a one-character code or a scan set, possibly preceded by a one-character qualifier. Each combination determines the type required of the next argument (if any) and how the scan functions interpret the text sequence and converts it to an encoded value. The integer and floating-point conversions also determine what base to assume for the text representation.
%n %hn %ln int *x short *x long *x %o %ho %lo unsigned int *x unsigned short *x unsigned long *x %p strtoul strtoul strtoul 8 8 8 void **x %s %ls char x[] wchar_t x[] %u %hu %lu unsigned int *x unsigned short *x unsigned long *x strtoul strtoul strtoul 10 10 10 %x %hx %lx unsigned int *x unsigned short *x unsigned long *x strtoul strtoul strtoul 16 16 16 %X %hX %lX unsigned int *x unsigned short *x unsigned long *x strtoul strtoul strtoul 16 16 16 %[...] %l[...
You write %lc to store the matched input characters in an array object, with elements of type wchar_t. If you specify no field width w, then w has the value one. The match does not skip leading white space. Any sequence of w characters matches the conversion pattern. For a byte stream, conversion occurs as if by repeatedly calling mbrtowc, beginning in the initial conversion state.
You write %[ to store the matched input characters in an array object, followed by a terminating null character. If you do not specify a field width w, then w has a large value. The match does not skip leading white space. A sequence of up to w characters matches the conversion pattern in the scan set that follows. To complete the scan set, you follow the left bracket ([) in the conversion specification with a sequence of zero or more match characters, terminated by a right bracket (]).
Next STL Conventions Algorithm Conventions · Iterator Conventions The Standard Template Library, or STL, establishes uniform standards for the application of iterators to STL containers or other sequences that you define, by STL algorithms or other functions that you define. This document summarizes many of the conventions used widely throughout the Standard Template Library.
hence are often passed and returned by value, not by reference. Note also that none of the operations described above can throw an exception, at least when performed on a valid iterator. The hierarchy of iterator categories can be summarize by showing three sequences. For write-only access to a sequence, you can use any of: output iterator -> forward iterator -> bidirectional iterator -> random-access iterator The right arrow means ``can be replaced by.
● ● ● ● (++N), and have the object compare equal to B after a finite number of increments (N == B). The phrase ``each N in the range [A, B)'' means that N begins with the value A and is incremented zero or more times until it equals the value B. The case N == B is not in the range. The phrase ``the lowest value of N in the range [A, B) such that X'' means that the condition X is determined for each N in the range [A, B) until the condition X is met.
A sequence of elements designated by iterators in the range [first, last) is ``a heap ordered by operator<'' if: ● For each N in the range [1, last - first) the predicate !(*first < *(first + N)) is true. (The first element is the largest.) ● It is possible to insert (push_heap) a new element or remove (pop_heap) the largest element in logarithmic time and preserve the heap discipline in the resulting sequence.
Next Containers A container is an STL template class that manages a sequence of elements. Such elements can be of any object type that supplies a copy constructor, a destructor, and an assignment operator (all with sensible behavior, of course). The destructor may not throw an exception. This document describes the properties required of all such containers, in terms of a generic template class Container. An actual container template class may have additional template parameters.
const Container& right); template bool operator<( const Container& left, const Container& right); template bool operator>( const Container& left, const Container& right); template bool operator<=( const Container& left, const Container& right); template bool operator>=( const Container& left, const Container& right); template void swap( Container& left, Container& right); }; Container begin · clear · const_iterato
typedef T8 const_reverse_iterator; iterator begin(); const_iterator begin() const; iterator end(); const_iterator end() const; reverse_iterator rbegin(); const_reverse_iterator rbegin() const; reverse_iterator rend(); const_reverse_iterator rend() const; size_type size() const; size_type max_size() const; bool empty() const; iterator erase(iterator where); iterator erase(iterator first, iterator last); void clear(); void swap(Container& right); }; The template class describes an object that controls a varyi
For all the container classes defined by STL, if an exception is thrown during calls to the following member functions: insert // single element inserted at end push_back push_front the container is left unaltered and the exception is rethrown. For all the container classes defined by STL, no exception is thrown during calls to the following member functions: pop_back pop_front The member function erase throws an exception only if a copy operation (assignment or copy construction) throws an exception.
● ● Type Alloc::pointer is the same as Ty *. Type Alloc::reference is the same as Ty&. In this implementation, however, containers do not make such simplifying assumptions. Thus, they work properly with allocator objects that are more ambitious: ● All objects of class Alloc need not compare equal. (You can maintain multiple pools of storage.) ● Type Alloc::const_pointer need not be the same as const Ty *. (A const pointer can be a class.) ● Type Alloc::pointer need not be the same as Ty *.
reverse_iterator ). Container::difference_type typedef T1 difference_type; The signed integer type describes an object that can represent the difference between the addresses of any two elements in the controlled sequence. It is described here as a synonym for the unspecified type T1 (typically Alloc::difference_type). Container::empty bool empty() const; The member function returns true for an empty controlled sequence.
Container::max_size size_type max_size() const; The member function returns the length of the longest sequence that the object can control, in constant time regardless of the length of the controlled sequence. Container::rbegin const_reverse_iterator rbegin() const; reverse_iterator rbegin(); The member function returns a reverse iterator that points just beyond the end of the controlled sequence. Hence, it designates the beginning of the reverse sequence.
of the length of the controlled sequence. Container::size_type typedef T0 size_type; The unsigned integer type describes an object that can represent the length of any controlled sequence. It is described here as a synonym for the unspecified type T0 (typically Alloc::size_type). Container::swap void swap(Container& right); The member function swaps the controlled sequences between *this and right. If get_allocator() == right.get_allocator(), it does so in constant time.
operator< template bool operator<( const Container & left, const Container & right); The template function overloads operator< to compare two objects of template class Container. The function returns lexicographical_compare(left. begin(), left. end(), right.begin(), right.end()). operator<= template bool operator<=( const Container & left, const Container & right); The template function returns !(right < left).
Container & left, Container & right); The template function executes left.swap(right). See also the Table of Contents and the Index. Copyright © 1994-2001 by P.J. Plauger. Portions derived from work copyright © 1994 by Hewlett-Packard Company. All rights reserved.
Next Expressions You write expressions to determine values, to alter values stored in objects, and to call functions that perform input and output. In fact, you express all computations in the program by writing expressions. The translator must evaluate some of the expressions you write to determine properties of the program. The translator or the target environment must evaluate other expressions prior to program startup to determine the initial values stored in objects with static duration.
promotes its type to one of these. If all of the values representable in the original type are also representable as type int, then the promoted type is int. Otherwise, the promoted type is unsigned int. Thus, for signed char, short, and any signed bitfield type, the promoted type is int.
Next Functions You write functions to specify all the actions that a program performs when it executes. The type of a function tells you the type of result it returns (if any). It can also tell you the types of any arguments that the function expects when you call it from within an expression.
An if-else statement executes one of two statements, depending on whether the test-context expression has a nonzero value: if (test) statement-1 else statement-2 A return statement terminates execution of the function and transfers control to the expression that called the function. If you write the optional rvalue expression within the return statement, the result must be assignment-compatible with the type returned by the function.
Copyright © 1989-2001 by P.J. Plauger and Jim Brodie. All rights reserved.
Preprocessing The translator processes each source file in a series of phases. Preprocessing constitutes the earliest phases, which produce a translation unit. Preprocessing treats a source file as a sequence of text lines. You can specify directives and macros that insert, delete, and alter source text.
● ● ● ● ● The expression defined X, or defined (X), is replaced by 1 if X is defined as a macro, otherwise 0. You cannot write the sizeof or type cast operators. (The translator expands all macro names, then replaces each remaining name with 0, before it recognizes keywords.) The translator may be able to represent a broader range of integers than the target environment. The translator represents type int the same as long, and unsigned int the same as unsigned long.
Index A B C D E F G H I J K L M N O P Q R S T U V W X Y Z %% · %% · %[ A abort · abs · abs · abs · abs · accessor objects · accumulate · acos · acos · acosf · acosl · additional graphic characters · address constant expression · adjacent_difference · adjacent_find · advance · Algorithm Conventions · · allocator · allocator object · allocator::address · allocator::allocate · allocator::allocator · allocator::const_pointer · allocator::const_reference · allocator::construct · allocator::deallocate
basic_filebuf · basic_filebuf::basic_filebuf · basic_filebuf::char_type · basic_filebuf::close · basic_filebuf::int_type · basic_filebuf::is_open · basic_filebuf::off_type · basic_filebuf::open · basic_filebuf::overflow · basic_filebuf::pbackfail · basic_filebuf::pos_type · basic_filebuf::seekoff · basic_filebuf::seekpos · basic_filebuf::setbuf · basic_filebuf::sync · basic_filebuf::traits_type · basic_filebuf::underflow · basic_fstream · basic_fstream::basic_fstream · basic_fstream::close · basic_fstream::
basic_ostream::tellp · basic_ostream::write · basic_ostringstream · basic_ostringstream::allocator_type · basic_ostringstream::basic_ostringstream · basic_ostringstream::rdbuf · basic_ostringstream::str · basic_streambuf · basic_streambuf::basic_streambuf · basic_streambuf::char_type · basic_streambuf::eback · basic_streambuf::egptr · basic_streambuf::epptr · basic_streambuf::gbump · basic_streambuf::getloc · basic_streambuf::gptr · basic_streambuf::imbue · basic_streambuf::in_avail · basic_streambuf::int_t
basic_string::const_reverse_iterator · basic_string::copy · basic_string::c_str · basic_string::data · basic_string::difference_type · basic_string::empty · basic_string::end · basic_string::erase · basic_string::find · basic_string::find_first_not_of · basic_string::find_first_of · basic_string::find_last_not_of · basic_string::find_last_of · basic_string::get_allocator · basic_string::insert · basic_string::iterator · basic_string::length · basic_string::max_size · basic_string::npos · basic_string::opera
oriented · byte print functions · byte read functions · byte scan functions · byte stream · byte write functions C %c · %c · C++ Library Conventions · C Library Conventions · C++ library headers · C++ Library Overview · C Library Overview · C locale · C++ Program Startup and Termination · C Program Startup and Termination · C++ Standard · C string · C99 · callback event · callback stack · calloc · · · ceil · ceilf · ceill · cerr · · · character classification · character
conj · constant expression · const_mem_fun1_ref_t · const_mem_fun1_t · const_mem_fun_ref_t · const_mem_fun_t · constructing iostreams · Container · Container::begin · Container::clear · Container::const_iterator · Container::const_reference · Container::const_reverse_iterator · Container::difference_type · Container::empty · Container::end · Container::erase · Container::get_allocator · Container::get_allocator · Container::insert · Container::iterator · Container::max_size · Container::pop_back · Container
· deque::begin · deque::clear · deque::const_iterator · deque::const_pointer · deque::const_reference · deque::const_reverse_iterator · deque::deque · deque::difference_type · deque::empty · deque::end · deque::erase · deque::front · deque::get_allocator · · deque::insert · deque::iterator · deque::max_size · deque::operator[] · deque::pointer · deque::pop_back · deque::pop_front · deque::push_back · deque::push_front · deque::rbegin · deque::reference · deque::rend · deque::resize · deque::reverse_
float_round_style::round_toward_neg_infinity · float_round_style::round_toward_zero · floor · floorf · floorl · FLT_DIG · FLT_EPSILON · FLT_MANT_DIG · FLT_MAX · FLT_MAX_10_EXP · FLT_MAX_EXP · FLT_MIN · FLT_MIN_10_EXP · FLT_MIN_EXP · FLT_RADIX · FLT_ROUNDS · flush · fmod · fmodf · fmodl · fopen · FOPEN_MAX · For Statement · for_each · format flag · format flags · format string · Formatted Input · formatted input functions · Formatted Output · formatted output functions · formatting information · forwarditera
has_facet · hash function · hash traits · hash_compare · hash_compare::bucket_size · hash_compare::min_buckets · hash_map · hash_map::allocator_type · hash_map::begin · hash_map::clear · hash_map::const_iterator · hash_map::const_pointer · hash_map::const_reference · hash_map::const_reverse_iterator · hash_map::count · hash_map::difference_type · hash_map::empty · hash_map::end · hash_map::equal_range · hash_map::erase · hash_map::find · hash_map::get_allocator · · hash_map::hash_map · hash_map::
hash_multiset::const_reference · hash_multiset::const_reverse_iterator · hash_multiset::count · hash_multiset::difference_type · hash_multiset::empty · hash_multiset::end · hash_multiset::equal_range · hash_multiset::erase · hash_multiset::find · hash_multiset::get_allocator · hash_multiset::hash_multiset · hash_multiset::insert · hash_multiset::iterator · hash_multiset::key_comp · hash_multiset::key_compare · hash_multiset::key_type · hash_multiset::lower_bound · hash_multiset::max_size · hash_multiset::po
indirect_array::operator|= · indirect_array::operator&= · indirect_array::operator>>= · indirect_array::operator<<= · indirect_array::value_type · InIt · initial conversion state · initial shift state · inner_product · inplace_merge · input buffer · input failure · input iterator · input_iterator_tag · inserter · insert_iterator · insert_iterator::container · insert_iterator::container_type · insert_iterator::insert_iterator · insert_iterator::iter · insert_iterator::operator* · insert_iterator::operator++
· iostreams · isalnum · isalnum · isalpha · isalpha · iscntrl · iscntrl · isdigit · isdigit · isgraph · isgraph · islower · islower ·
reallocation · list::allocator_type · list::assign · list::back · list::begin · list::clear · list::const_iterator · list::const_pointer · list::const_reference · list::const_reverse_iterator · list::difference_type · list::empty · list::end · list::erase · list::front · list::get_allocator · · list::insert · list::iterator · list::list · list::max_size · list::merge · list::pointer · list::pop_back · list::pop_front · list::push_back · list::push_front · list::rbegin · list::reference · list::remove
#mask_array::operator= · mask_array::operator= · mask_array::operator^= · mask_array::operator|= · mask_array::operator&= · mask_array::operator>>= · mask_array::operator<<= · mask_array::value_type · masking macro · masking macro · matching failure ·
multimap::const_iterator · multimap::const_pointer · multimap::const_reference · multimap::const_reverse_iterator · multimap::count · multimap::difference_type · multimap::empty · multimap::end · multimap::equal_range · multimap::erase · multimap::find · multimap::get_allocator · multimap::insert · multimap::iterator · multimap::key_comp · multimap::key_compare · multimap::key_type · multimap::lower_bound · multimap::mapped_type · multimap::max_size · multimap::multimap · multimap::pointer · multimap::rbegi
numeric_limits::digits10 · numeric_limits::epsilon · numeric_limits::has_denorm · numeric_limits::has_denorm_loss · numeric_limits::has_infinity · numeric_limits::has_quiet_NaN · numeric_limits::has_signaling_NaN · numeric_limits::infinity · numeric_limits::is_bounded · numeric_limits::is_exact · numeric_limits::is_iec559 · numeric_limits::is_integer · numeric_limits::is_modulo · numeric_limits::is_signed · numeric_limits::is_specialized · numeric_limits::max · numeric_limits::max_exponent · numeric_limits:
operator> · operator>= · operator> · operator>= · operator> · operator>= · operator> · operator>= · operator> · operator>= · operator> · operator>= · operator> · operator>= · operator> · operator>= · operator> · operator>= · operator> · operator>= · operator>> · operator>> · operator>> · operator>> · operator>> · operator< · operator<= · operator< · operator<= · operator< · operator<= · operator< · operator<= · operator< · operator<= · operator< · operator<= · operator< · operator<= · operator< · operator<=
specification · Print Conversion Specifiers · print field width · Print Formats · Print Functions · printf · priority_queue · priority_queue::c · priority_queue::comp · priority_queue::container_type · priority_queue::empty · priority_queue::pop · priority_queue::priority_queue · priority_queue::push · priority_queue::size · priority_queue::size_type · priority_queue::top · priority_queue::value_type · private heap · program · program arguments · program startup · program termination · Promoting · p_sep_by_
reverse_iterator::reverse_iterator · rewind · right · rotate · rotate_copy · runtime_error · rvalue expression S %s · %s · scan conversion specification · Scan Conversion Specifiers · scan field width · Scan Formats · Scan Functions · scan set · scanf · SCHAR_MAX · SCHAR_MIN · scientific · search · search_n · seek mode · SEEK_CUR · SEEK_END · SEEK_SET · sequence ordering · set · set::allocator_type · setbase · set::begin · setbuf · set::clear · set::const_iterator · set::const_pointer · set::const_reference
slist::difference_type · slist::empty · slist::end · slist::erase · slist::front · slist::get_allocator · · slist::insert · slist::iterator · slist::max_size · slist::merge · slist::pointer · slist::pop_back · slist::pop_front · slist::previous · slist::push_back · slist::push_front · slist::reference · slist::remove · slist::remove_if · slist::resize · slist::reverse · slist::size · slist::size_type · slist::slist · slist::sort · slist::splice · slist::swap · slist::unique · slist::value_type · sor
Table of Contents · tan · tan · tan · tanf · tanh · tanh · tanh · tanhf · tanhl · tanl · target character set · target environment · terminate · terminate handler · terminate_handler · test-context expression · Text and Binary Streams · text lines · text stream · text stream · thousands_sep · tie pointer · time · time input field · time string · time structure · time_base · time_base::dateorder · time_base::dmy · time_base::mdy · time_base::no_order · time_base::ydm · time_base::ymd · time_get · time_get_by
valarray::operator+= · valarray::operator- · valarray::operator-= · valarray::operator/= · valarray::operator= · valarray::operator[] · valarray::operator^= · valarray::operator|= · valarray::operator~ · valarray::operator Ty * · valarray::operator&= · valarray::operator>>= · valarray::operator<<= · valarray::resize · valarray::shift · valarray::size · valarray::sum · valarray::valarray · valarray::value_type · va_list · _Val_type · varying number of arguments · va_start · vector · vector reallocation · vec
Wide-Character Encoding · wide-character string · wide-character string literal · wifstream · wint_t · wint_t · wios · wiostream · wistream · wistringstream · wmemchr · wmemcmp · wmemcpy · wmemmove · wmemset · wofstream · wostream · wostringstream · wprintf · write position · ws · wscanf · wstreambuf · wstreampos · wstring · wstringbuf · wstringstream X %X · %x · %X · %x · xor · xor_eq Y year input field Z See also the Table of Contents. Copyright © 1989-2001 by P.J. Plauger. All rights reserved.
Dinkumware, Ltd. Genuine Software Copyright and License Notice Dinkumware, Ltd. 398 Main Street Concord MA 01742 USA +1-978-371-2773 Disclaimer for HP NonStop Implementation: This documentation is intended to document the Standard C++ Library ISO/IEC (VERSION3) on HP NonStop systems. However, the part of the documentation that describes the underlying C Library might or might not apply to the C Library implementation on HP NonStop systems.
● You may not copy or distribute, in any form, any part of this Product for any purpose not specifically permitted by this Notice. This copy of the Product is licensed for use by a limited number of developers, which is specified as part of the packaging for this Product. A license for up to ten users, for example, limits to ten the number of developers reasonably able to use the Product at any instant of time.
Software Clause as DFARS 52.227-7013 and FAR 52.227-19. Unpublished rights are reserved under the Copyright Laws of the USA. Contractor/ Manufacturer is DINKUMWARE, LTD., 398 Main Street, Concord MA 01742. The terms of this notice shall be governed by the laws of the Commonwealth of Massachusetts. THE RIGHTS AND OBLIGATIONS OF THE PARTIES SHALL NOT BE GOVERNED BY THE PROVISIONS OF THE U.N. CONVENTION FOR THE INTERNATIONAL SALE OF GOODS, 1980.
Bug Reports The authors welcome reports of any errors or omissions. Please report any bugs or difficulties to: Dinkumware Support Dinkumware, Ltd. 398 Main Street Concord MA 01742-2321 USA +1-978-371-2773 (UTC -4 hours, -5 November through March) +1-978-371-9014 (FAX) support@dinkumware.com See also the Table of Contents and the Index. Copyright © 1989-2001 by P.J. Plauger and Jim Brodie. All rights reserved.