  • string
  • Iterator
    • iterator
    • iterator_traits
  • input
    • istream_iterator
    • istreambuf_iterator
  • output
    • ostream_iterator
    • ostreambuf_iterator
  • insert
    • back_insert_iterator
    • front_insert_iterator
    • insert_iterator
  • reverse
    • reverse(random access)
    • reverse(bidirectional)
  • valarray
The Iterator Hierarchy 


allocator

Class Name            allocator

Header File          <memory>

Classification      Memory Management
Class Description

Member Classes

None

Methods

pointer address(reference x) const;

const_pointer address(const_reference x) const;

pointer allocate(size_type n, typename allocator<void>::const_pointer hint = 0);

allocator() throw();

allocator(const allocator&) throw();

template <class U> allocator(const allocator<U>& a) throw();

~allocator() throw();

void construct(pointer p, const T& val);

void deallocate(pointer p, size_type n);

void destroy(pointer p);

size_type max_size() const throw();

Example

Class Description

The allocator class encapsulates information about the memory model being used by the program. It encapsulates information about pointers and const pointers, references and const references, size of objects, and the difference between pointers allocation and deallocation functions. The information contained in the allocator class is used by any function that performs operation concerning the memory model. A function that inserts, extracts, advances pointers that point to objects in a container needs information from the allocator object in order to determine the size of the object, pointer or reference.

Method             address()

Access             Public

Classification     Accessor

Syntax             pointer address(reference x) const;

Parameters         x is a reference to an object.

Returns            This method returns the address of object x.

Description

The address() method returns the pointer to object x. When passed a reference to an object, address() will return a pointer to that object. The pointer can then be dereferenced returning the actual object.

Method             address()

Access             Public

Classification     Accessor

Syntax             const_pointer address(const_reference x) const;

Parameters         x is a const reference to an object.

Returns            This method returns the address of object x.

Description

The address() method returns the const pointer to object x.

Method             allocator()

Access             Public

Classification     Constructor

Syntax             allocator() throw();

Parameters         None

Returns            None

Description

This constructor constructs an allocator object.

Method             allocator()

Access             Public

Classification     Constructor

Syntax             allocator(const allocator& a) throw();

Parameters         a is a reference to the allocator object in which
                   the newly constructed object is a copy.

Returns            None

Description

This constructor constructs an allocator object which is a copy of allocator object a.

Method             allocator()

Access             Public

Classification     Constructor

Syntax             template <class U> allocator(const allocator<U>& a) throw();

Parameters         a is a reference to the allocator object in which
                   the newly constructed object is a copy.

Returns            None

Description

This constructor constructs an allocator object which is a copy of allocator object a.

Method             allocate()

Access             Public

Classification     Modifier

Syntax             pointer allocate(size_type n,
                   typename allocator<void>::const_pointer hint = 0);

Parameters         n is the number of objects to allocate memory for.

                   hint is used to help to the allocator object for systems
                   where locality is an important factor when allocating
                   memory.

Returns            None

Description

The allocate() method allocates memory for n objects of size_type. The memory is allocated but the objects are not constructed. The default allocator uses new(size_t) to create the memory block. The hint argument is implementation-dependent.

Method             ~allocator()

Access             Public

Classification     Destructor

Syntax             ~allocator() throw();

Parameters         None

Returns            None

Description

The destructor destroys an allocator object.

Method             construct()

Access             Public

Classification     Modifier

Syntax             void construct(pointer p, const T& val);

Parameters         p is a pointer returned by the allocate() method.

                   val is a reference to the object to be constructed.

Returns            None

Description

The construct() method is passed the pointer returned by allocate() then constructs the object val by current its constructor.

Method             deallocate()

Access             Public

Classification     Modifier

Syntax             void deallocate(pointer p, size_type n);

Parameters         p points to the objects to deallocate.

                   n is the number of objects to deallocate
                   its storage.

Returns            None

Description

The deallocate() method deallocates all of the storage of n objects of type size_type pointed to by the pointer p. The default allocator uses the delete() to free the space. This space can now be used. The actual objects should be destroyed before the deallocate() function is called.

Method             destroy()

Access             Public

Classification     Modifier

Syntax             void destroy(pointer p);

Parameters         p points to the object to be destroyed.

Returns            None

Description

The destroy() method destroys an object. It uses the pointer p which is returned by the allocate() method. This method will explicitly invoke T's destructor to destroy the object at p. The objects are destroyed but the space that it occupied has not been deallocated.

Method             max_size()

Access             Public

Classification     Accessor

Syntax             size_type max_size() const throw();

Parameters         None

Returns            This method returns the maximum number of objects
                   that can be stored in an object using the current
                   memory model.

Description

The max_size() method returns the maximum number of objects that can be stored in an object using the current memory model.

#include <memory>
#include <iostream>

void main(void)
{
    allocator<char> Storage;

    cout << Storage.max_size() << endl;

}


The Common Associative Container Methods

Class Name        basic_istringstream

Classification    Associative Containers

Methods

size_type count(const key_type& x) const

void erase(iterator Pos)

size_type erase(const key_type& X)

void erase(iterator First, iterator Last)

pair equal_range(const key_type& X)

pair insert(const value_type& X)

iterator insert(iterator Pos, const value_type& X)

template  void insert(InputIterator First, InputIterator Last)

iterator find(const key_type& X)

const_iterator find(const key_type& X) const

iterator lower_bound(const key_type& X)

const_iterator lower_bound(const key_type& X) const

iterator upper_bound(const key_type& X)

const_iterator upper_bound(const key_type& X) const

Method            count()

Access            Public

Classification    Accessor

Syntax            size_type count(const key_type& x) const

Parameters        X is the object to be counted.

Return            This method returns the number of objects with keys
                  equal to x.

Description

The count() method returns the number of objects with keys equal to X.

Method            insert()

Access            Public

Classification    Modifier

Syntax            pair insert(const value_type& X)

Parameters        X is the object to be inserted into the container.

Return            returns a pair object that contains a bool and a iterator.
                  The bool indicates whether an insertion was made.  If an
                  insertion was made the iterator points to the object.

Description

This insert() method inserts X into the container if there is no other object that
has the same key.

Method            insert()

Access            Public

Classification    Modifier

Syntax            iterator insert(iterator Pos, const value_type& X)

Parameters        X is the object to be inserted after Position Pos.

Return            This method returns the iterator pointing to the newly inserted
                  object.

Description

This insert() method inserts object X after Position Pos in the container.

Method            insert()

Access            Public

Classification    Modifier

Syntax            template  void insert (InputIterator First, InputIterator Last)

Parameters        [First,Last) is the range of objects that will be inserted into the
                  container.

Return             None

Description

This insert() method inserts the objects in the range [First,Last] before position
Pos in the container.

Method            erase()

Access            Public

Classification    Modifier

Syntax            iterator erase(iterator Pos)

Parameters        Pos points to the object to be deleted.

Return            None

Description

This erase() method deletes the object pointed to by Pos.

Method            erase()

Access            Public

Classification    Modifier

Syntax            size_type erase(const key_type& X)

Parameters        X is the key of elements to be erased.

Return            None

Description

This erase() method deletes all objects in the container whose key = X.

Method            erase()

Access            Public

Classification    Modifier

Syntax            iterator erase(iterator First, iterator Last)

Parameters        [First,Last) contains the range of objects to
                  be deleted

Return            None

Description

This erase() method deletes the objects in the range [First,Last).

Method            equal_range()

Access            Public

Classification    Accessor

Syntax            pair equal_range(const key_type& X)

Parameters        X is the object that is being searched for.

Return            This method returns a set of iterators with the first
                  equal to lower_bound(X), and the second equal to upper_bound(X).

Description

This equal_range() method returns a pair object that contains two iterators.  The
first iterator is lower_bound(X), and the second iterator is upper_bound(X).

Method            find()

Access            Public

Classification    Accessor

Syntax            iterator find(const key_type& X)

Parameters        X is the key of the object that is being searched for.

Return            If the object is found this method returns an iterator pointing
                  to the object. Otherwise this method returns end().

Description

The find() method locates an object in a container and returns an iterator pointing to that
object if it is in the container.  Otherwise find() returns end().

Method            lower_bound()

Access            Public

Classification    Accessor

Syntax            iterator lower_bound(const key_type& X)

Parameters        X is the key of the object that is being searched for.

Return            If the object is found this method returns an iterator pointing
                  to the object. Otherwise this method returns an iterator pointing
                  to the next object that has a key greater than X.

Description

The lower_bound() method locates an object in a container and returns an iterator pointing to that
object if it is in the container.  Otherwise it returns an iterator pointing to the next object
whose key is larger than X.  If container is empty lower_bound() returns end().

Method            upper_bound()

Access            Public

Classification    Accessor

Syntax            iterator upper_bound(const key_type& X)

Parameters        X is the key of the object that is being searched for.

Return            This method always returns an iterator pointing
                  to the next object whose key is greater than X.

Description

The upper_bound() method locates an object in a container and returns an iterator pointing to
the next object whose key is greater than X.  If the container is empty upper_bound()
returns end().


auto_ptr

Class Name            auto_ptr

Header File          <memory>

Classification      Memory Management
Class Description

Member Classes

None

Methods

auto_ptr(const auto_ptr&) throw();

explicit auto_ptr(X* p = 0) throw();

template<class Y> auto_ptr(const auto_ptr<Y>& a) throw();

~auto_ptr();

X* get() const throw();

X* release() const throw();

Operators

auto_ptr& operator=(const auto_ptr& a) throw();

template<class Y> auto_ptr& operator=(const auto_ptr<Y>& a) throw();

X& operator*() const throw();

X* operator->() const throw();

Example

Class Description

The auto_ptr is a pointer like object. Like a regular pointer, it points to an object in memory. It can be dereferenced and incremented. However, unlike a regular pointer, when the auto_ptr object goes out of scope, the destructor uses the delete operator to deallocate the memory occupied by the object to which it points.

Method             auto_ptr()

Access             Public

Classification     Constructor

Syntax             explicit auto_ptr(X* p = 0) throw();

Parameters         p is points to the object in which the newly constructed
                   auto_ptr object will own.

Returns            None

Description

This constructor is passed a pointer to an object. The self reference pointer of the auto_ptr object, this, will hold the pointer p and owns the object pointed to by p.

Method             auto_ptr()

Access             Public

Classification     Constructor

Syntax             auto_ptr(const auto_ptr& p) throw();

Parameters         p is a reference to the auto_ptr.

Returns            None

Description

This constructor constructs an object that is a copy of auto_ptr p. The ownersip of the object pointed to by p is passed to the newly constructed object.

Method             auto_ptr()

Access             Public

Classification     Constructor

Syntax             template<class Y>
                   auto_ptr(const auto_ptr<Y>& a) throw();

Parameters         a is a const reference to the auto_ptr.

Returns            None

Description

This constructor constructs an object that is a copy of auto_ptr a. The ownersip of the object pointed to by p is passed to the newly constructed object. It requires that Y* can be implicitly converted to X*. X is the template parameter for auto_ptr. It is the object for which auto_ptr manages dynamic memory.

Method             auto_ptr()

Access             Public

Classification     Destructor

Syntax             ~auto_ptr();

Parameters         None

Returns            None

Description

The destructor destroys an auto_ptr object. It requires that *this owns the pointer returned by get(). If this is true then the delete operator can delete the object and deallocate the memory.

Method             get()

Access             Public

Classification     Accessor

Syntax             X* get() const throw();

Parameters         None

Returns            This method returns the pointer *this holds.

Description

The get() method returns the pointer *this holds. It is a pointer to an object of type X.

Method             release()

Access             Public

Classification     Accessor

Syntax             X* release() const throw();

Parameters         None

Returns

Desription

The release() method returns the pointer *this holds by calling get() method. The purpose of this method is to transfer the ownership of the object to which the pointer returned by get() points.

Method             operator=()

Access             Public

Classification     Modifier

Syntax             auto_ptr& operator=(const auto_ptr& a) throw();

Parameters         a is a reference to the auto_ptr object assigned
                   to the current auto_ptr object.

Returns            This operator returns a pointer to the current object.

Description

This operator=() assigns auto_ptr a to the current object. The assignment operator calls a.release() if and only if *this and a are not the same object. If *this and a are the same object then nothing takes place. *this will now hold the returned pointer. *this will own the object only if a owned the object. *this is returned.

Method             operator=()

Access             Public

Classification     Modifier

Syntax             template<class Y>
                   auto_ptr& operator=(const auto_ptr<Y>& a) throw();

Parameters         a is a const reference to the auto_ptr object assigned
                   to the current auto_ptr object.

Returns            This operator returns a pointer to the current object.

Description

This operator=() assigns auto_ptr a to the current object. The assignment operator calls a.release() if and only if *this and a are not the same object. If *this and a are the same object then nothing takes place. *this will now hold the returned pointer. *this will own the object only if a owned the object. *this is returned. It requires that Y* can be implicitly converted to X*.

Method             operator*()

Access             Public

Classification     Accessor

Syntax             X& operator*() const throw();

Parameters         None

Returns            This method returns *get().

Description

The operator->() returns *get().

Method             operator->()

Access             Public

Classification     Accessor

Syntax             X* operator->() const throw();

Parameters         None

Returns            This method returns get().

Description

The operator->() returns get().

// Listing 10.1

 1    #include
 2    #include
 3    #include
 4
 5    using namespace std;
 6
 7    void main(void)
 8    {
 9        string *Str1 = new string("hello");
10        string *Str2 = new string("out there");
11        auto_ptr AutoPtr1(Str1);
12        auto_ptr AutoPtr2(Str2);
13
14        cout << "auto ptr 1 has object " << *AutoPtr1 << endl;
15        cout << "auto ptr 1 pointer is " << AutoPtr1.get() << endl;
16        cout << "auto ptr 2 has object " << *AutoPtr2 << endl;
17        cout << "auto ptr 2 pointer is " << AutoPtr2.get() << endl;
18        AutoPtr1 = AutoPtr2;
19        cout <<"after assignment" << endl;
20        cout << "auto ptr 1 has object " << *AutoPtr1 << endl;
21        cout << "auto ptr 1 pointer is " << AutoPtr1.get() << endl;
22        cout << "auto ptr 2 has object " << *AutoPtr2 << endl;
23        cout << "auto ptr 2 pointer is " << AutoPtr2.get() << endl;
24
25    }
26


bad_cast

Class Name            bad_cast

Header File          <typeinfo>

Classification      Runtime Object Identification
Class Relationship Diagram

Class Description

Member Classes

None

Methods

bad_cast() throw();

bad_cast(const bad_cast&) throw();

~bad_cast() throw();

virtual const char* what() const throw();

Operators

bad_cast& operator=(const bad_cast&) throw();

Class Description

The bad_cast class describes an object type thrown as a exception by an invalid execution of dynamic cast expression.

Method             bad_cast()

Access             Public

Classification     Constructor

Syntax             bad_cast() throw();

Parameters         None

Returns            None

Description

This constructor constructs a bad_cast object.

Method             bad_cast()

Access             Public

Classification     Constructor

Syntax             bad_cast(const bad_cast& x) throw();

Parameters         x is a reference to a the bad_cast object
                   in which the newly constructed object is a copy.

Returns            None

Description

This constructor constructs a bad_cast object that is a copy of x.

Method             bad_cast()

Access             Public

Classification     Destructor

Syntax             ~bad_cast() throw();

Parameters         None

Returns            None

Description

The destructor destroys a bad_cast object.

Method             what()

Access             Public

Classification     Accessor

Syntax             virtual const char* what() const throw();

Parameters         None

Returns            This method returns a pointer to a message.

Description

The what() method returns a message determined by the implementor.

Method             operator=()

Access             Public

Classification     Modifier

Syntax             bad_cast& operator=(const bad_cast& x) throw();

Parameters         x is a reference to a the bad_cast object
                   in which the newly constructed object is a copy.

Returns            This operator returns a pointer to the current object.

Description

The assignment operator assigns the bad_cast object x to the current object.

The Class Relationship Diagram for bad_cast


bad_typeid

Class Name            bad_typeid

Header File          <typeinfo>

Classification      Runtime Object Identification
Class Relationship Diagram

Class Description

Member Classes

None

Methods

bad_typeid() throw();

bad_typeid(const bad typeid&) throw();

virtual ~bad_typeid() throw();

virtual const char* what() const throw();

Operators

bad_typeid& operator=(const bad_typeid&) throw();

Class Description

The bad_typeid class describes an object type thrown as a exception when a null pointer is used in a typeid expression.

Method             bad_typeid()

Access             Public

Classification     Constructor

Syntax             bad_typeid() throw();

Parameters         None

Returns            None

Description

This constructor constructs a bad_typeid object.

Method             bad_typeid()

Access             Public

Classification     Constructor

Syntax             bad_typeid(const bad_typeid& x) throw();

Parameters         x is a reference to a the bad_typeid object
                   in which the newly constructed object is a copy.

Returns            None

Description

This constructor constructs a bad_typeid object that is a copy of x.

Method             bad_typeid()

Access             Public

Classification     Destructor

Syntax             ~bad_typeid() throw();

Parameters         None

Returns            None

Description

The destructor destroys a bad_typeid object.

Method             what()

Access             Public

Classification     Accessor

Syntax             virtual const char* what() const throw();

Parameters         None

Returns            This method returns a pointer to a message.

Description

The what() method returns a message determined by the implementor.

Method             operator=()

Access             Public

Classification     Modifier

Syntax             bad_typeid& operator=(const bad_typeid& x) throw();

Parameters         x is a reference to a the bad_typeid object
                   in which the newly constructed object is a copy.

Returns            This operator returns a pointer to the current object.

Description

The assignment operator assigns the bad_typeid object x to the current object.

The Class Relationship Diagram for bad_typeid


reverse_iterator

Class Name            reverse_iterator

Header File          <iterator>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

Iterator current

Methods

Iterator base() const;

reverse_iterator();

explicit reverse_iterator(Iterator x);

Operators

Reference operator*() const;

reverse_operator& operator++();

reverse_operator& operator++(int);

reverse_operator& operator--();

reverse_operator operator--(int);

Class Description

This reverse iterator is an adaptation of a bidirectional iterator. It can traverse through a container in the same manner as a bidirectional iterator but in the reverse direction. Because the reverse iterator traverses in the reverse order, iterator that points to the start of the container (rbegin()) actually points to one element after the last element in the container. In order to avoid this type of violation, the dereference operator decrements that iterator by 1 or current -1. Thus the mapping of this type of iteration with the original sequence with bidirectional iterator i is: &*(reverse_iterator(i)) == &*(i - 1). The incrementation, ++, and decrementation, --, operators perform opposite operations. The incrementation operator decrements the current iterator and the decrementation operator increments the current iterator.

Iterator current

The bidirectional iterator which points into the container. This iterator is used to determine the current iterator in reverse order.

Method             reverse_iterator()

Access             Public

Classification     Constructor

Syntax             reverse_iterator();

Parameters         None

Returns            None

Description

This constructor constructs a reverse_iterator object.

Method             reverse_iterator()

Access             Public

Classification     Constructor

Syntax             explicit reverse_iterator(Iterator x);

Paramters          x is the bidirectional iterator which points into
                   the container.

Returns            None

Description

This constructor constructs a reverse_iterator object and initializes Iterator current with x.

Method             operator*()

Access             Public

Classification     Accessor

Syntax             reference operator*() const;

Parameters         None

Returns            This operator returns a reference to the iterator.

Description

The dereference operator of a const object makes a copy of Iterator current, decrements the copy and returns a reference to the copy.

Method             operator++()

Access             Public

Classification     Accessor

Syntax             reverse_iterator& operator++();

Parameters         None

Returns            This operator returns a pointer to the current object.

Description

The pre-incrementation operator decrements Iterator current (--current) and then returns *this.

Method             operator++()

Access             Public

Classification     Accessor

Syntax             reverse_iterator& operator++(int x);

Parameter          x is a dummy argument to distinguish between the
                   postfix and prefix incrementation that is never
                   used.

Returns            This operator returns a pointer to the current object.

Description

The postfix incrementation operator makes a copy of *this, decrements Iterator current (--current) and then returns the copy of *this.

Method             operator--()

Access             Public

Classification     Accessor

Syntax             reverse_iterator& operator--();

Parameters         None

Returns            This operator returns a pointer to the current object.

Description

The pre-decrementation operator increments Iterator current (++current) and then returns *this.

Method             operator--()

Access             Public

Classification     Accessor

Syntax             reverse_iterator& operator--(int x);

Parameters         x is a dummy argument to distinguish between the
                   postfix and prefix incrementation that is never used.

Returns            This operator returns a pointer to the current object.

Description

The postfix decrementation operator makes a copy of *this, increments Iterator current (++current) and then returns the copy of *this.

Method             base()const

Access             Public

Classification     Accessor

Syntax             Iterator base()const;

Parameters         None

Returns            This method returns Iterator current.

Description

The base() method returns Iterator current.

The Class Relationship Diagram for reverse_iterator


back_insert_iterator

Class Name            back_insert_iterator

Header File          <iterator>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

Container& container

Methods

explicit back_insert_iterator(Container& x);

Operators

back_insert_iterator<Container>& operator=
(const typename Container::value_type value);

back_insert_iterator<Container>& operator*();

back_insert_iterator<Container>& operator++();

back_insert_iterator<Container>& operator++(int);

Class Description

The back_insert_iterator is an insert iterator. It inserts elements at the end of a container by using the container's push_back() method to perform the insertion.

Container& container

The container is the container in which elements will be inserted.

Method             back_insert_iterator()

Access             Public

Classification     Constructor

Syntax             explicit back_insert_iterator(Container& x);

Paramters          x is the reference to the container in which elements
                   will be inserted.

Returns            None

Description

The constructor constructs a back_insert_iterator object and initializes Container& container with a x.

Method             operator*()

Access             Public

Classification     Accessor

Syntax             back_insert_iterator<Container>& operator*();

Parameters         None

Returns            This operator returns a pointer to the current object.

Description

The dereference operator returns *this.

Method             operator++()

Access             Public

Classification     Accessor

Syntax             back_insert_iterator<Container>& operator++();

Parameters         None

Returns            This operator returns a pointer to the current object.

Description

This incrementation operator returns *this.

Method             operator++()

Access             Public

Classification     Accessor

Syntax             back_insert_iterator<Container> operator++(int x);

Parameters         x has no bearing on this function.

Returns            This operator returns a pointer to the current object.

Description

This incrementation operator returns *this.

Method             operator=()

Access             Public

Classification     Modifier

Syntax             back_insert_iterator<Container>&
                   operator=(const typename Container::value_type& value);

Parameters         value is the reference to the type value_type that
                   is inserted into the container.

Returns            This operator returns a pointer to the current object.

Description

The assignment operator is converted to an insertion operation using container.push_back(value). The operator returns *this.

The Class Relationship Diagram for back_insert_iterator


architectural view of classes

The Architectural View of the Standard C++ Classes


char_traits

Class Name            char_traits

Header File          <string>

Classification      Runtime Support
Class Relationship Diagram

Class Description

Member Classes

None

Methods

static void assign(char_type& c1, const char_type& c2);

static char_type* assign(char_type* s, size_t n, char_type a);

static int compare(const char_type* s1, const char_type* s2, size_t n);

static char_type* copy(char_type* s1, const char_type* s2, size_t n);

static bool eq(const char_type& c1, const char_type& c2);

static bool eq_int_type(const int_type& c1, const int_type& c2);

static const char_type* find(const char_type* s, int n, const char_type& a);

static state_type get_state(pos_type pos); static int_type eof();

static size_t length(const char_type* s);

static bool lt(const char_type& c1, const char_type& c2);

static char_type* move(char_type* s1, const char_type* s2, size_t n);

static int_type not_eof(const int_type& c);

static char_type to_char_type(const int_type& c);

static int_type to_int_type(const char_type& c);

Class Description

The char_traits class defines the characters used in a string, number, time, date etc. Therefore, any class that manipulates characters is dependent on char_traits class. For example, when two strings are compared for equality, the characters of one string are compared with the characters of another string character-by-character. This string comparison operation calls the comparison operation of the char_traits class defined for that particular character type.The char_traits class declares types and functions needed to manipulate the character type. The functions define comparisons, equality, assignment, etc., between characters. The actual definition of the char_traits class is totally dependent on the character type inuse. Each character type will have its own definition of the char_traits class. The character traits must be specialized for the specific character type in use.

Characters can be narrow or wide. A narrow character is a character represented by 8 bits. A wide character is a character represented by two or more bytes. The ASCII character set has 256 8-bit characters. They are narrow characters. The Unicode charact er set consists of 65,536 16-bit characters. They are wide characters. Narrow characters and wide characters are represented as:

                   char and wchar_T

CHAR_T char_type

The char_type is of type CHAR_T. It refers to the character container type.

INT_T int_type

The int_type is of type INT_T. For certain character container type char_type, container type INT_T shall be a type or class which represents all of the valid characters converted from a corresponding char_type values.

POS_T pos_type;

The pos_type is of type POS_T. For a streambuf or its derived classes specialized for CHAR_T and TRAIT_T, a type or class POS_T is used to hold all the information necessary to reposition the specialized streambuf or its derived classes.

STATE_T state_type;

The state_type is of type STATE_T. For a streambuf or its derived classes whose underlying stream is a multibyte character stream and specialized for CHAR_T and TRAIT_T, a type or class STATE_T is used represent the conversion state type or class which is applied to the codecvt<> facet.

Method             assign()

Access             Public

Clasification      Modifier

Syntax             static void assign(char_type& c1,
                                      const char_type& c2);

Parameters         c1 is a reference to a char_type in which c2 is copied
                   to.

                   c2 is a reference to char_type which is copied to
                   c1.

Returns            None

Description

This assign() method copies c2 to c1.

Method             assign()

Access             Public

Classification     Modifier

Syntax             static char_type* assign(char_type* s, size_t n,
                                            char_type a);

Parameters         s points to a sequence of characters in which the
                   characters are copied.

                   n is the number of characters.

                   a is the character to be copied.

Returns            This method returns a pointer to a sequence of
                   char_type characters.

Description

The assign() method copies n copies of a into s.

Method             compare()

Access             Public

Classification     Accessor

Syntax             static int compare(const char_type* s1,
                                      const char_type* s2, size_t n);

Parameters         s1 points to a sequence of characters which is compared
                   to the characters in the s2 array.

                   s2 points to a sequence of characters which is compared
                   to the characters in the s1 array.

                   n is the number of characters in the arrays to
                   compare.

Returns            This method returns 0 if s1[i] == s2[i] where i is
                   in the range 0 to n.

Description

The compare() method for each char_type in the range of 0 to n, this function returns 0 if s1[i] == s2[i]. A negative value is returned if s1[i] < s2[i] is true and in the range 0 to i, s1[j] == s2[j] is also true. If these conditions are not met then a positive value is returned.

Method             copy()

Access             Public

Classification     Modifier

Syntax             static char_type* copy(char_type* s1,
                                          const char_type* s2,
                                          size_t n);

Parameters         s1 points to a sequence of characters in which
                   characters of array s2 are copied.

                   s2 points to a sequence of characters in which the
                   characters are copied to the array s1.

                   n is the number of characters.

Returns            This method returns a pointer to a sequence of
                   char_type characters.

Description

The copy() method copies n characters from s2 to s1 using the assign(s[i],s2[i]).

Method             eq_int_type()

Access             Public

Classification     Accessor

Syntax             static bool eq_int_type(const int_type& c1,
                                           const int_type& c2);

Parameters         c1 is a reference to a int_type
                   object which is compared to the int_type of c2.

                   c2 is a reference to a int_type
                   object which is compared to the int_type of c1.

Returns            This method returns true if c1 == c2.

Description

The eq_int_type() method determines if c1 == c2. The int_types are compared for equivalence.

Method             eq()

Access             Public

Classification     Accessor

Syntax             static bool eq(const char_type& c1,const char_type& c2);

Parameters         c1 is a reference to a char_type
                   object which is compared to the char_type of c2.

                   c2 is a reference to a char_type
                   object which is compared to the char_type of c1.

Returns            This method returns true if c1 == c2.

Description

The eq_int_type() method determines if c1 == c2. The char_types are compared for equivalence.

Method find() Access Public Classification Accessor Syntax static const char_type* find(const char_type* s, int n, const char_type& a); Parameters s points to a sequence of characters to be searched. n is the number of characters in the array to be searched. a is the character to locate. Returns This method returns a null pointer if not successful.

Description

The find() method finds the smallest char_type in the array s from s to s + n where char_type is equal to a char_type.

Method             get_state()

Access             Public

Classification     Accessor

Syntax             static state_type get_state(pos_type pos);

Parameters         pos is a type pos_type.

Returns            This method returns the state_type of pos.

Description

The get_state() method returns the state_type of pos.

Method             eof()

Access             Public

Classification     Accessor

Syntax             static int_type eof();

Parameters         None

Returns            This method returns an int_type that is the
                   end-of-file.

Description

The eof() method returns an int_type that is the end-of-file.

Method             not_eof()

Access             Public

Classification     Accessor

Syntax             static int_type not_eof(const int_type& c);

Parameters         c is the

Returns            This method returns an int_type c that is not the
                   end-of-file.

Description

The not_eof() method returns an int_type c such that c is not the end-of-file.

Method             length()

Access             Public

Classification     Accessor

Syntax             static size_t length(const char_type* s);

Parameters         s points to a sequence of characters.

Returns            This method returns the length of the sequence s.

Description

The length() method returns the number of elements in character sequence.

Method             lt()

Access             Public

Classification     Accessor

Syntax             static bool lt(const char_type& c1, const char_type& c2);

Parameters         c1 is a reference to a char_type which is compared
                   to c2.

                   c2 is a reference to a char_type which is compared
                   to c1.

Returns            This method returns true if c1 < c2.

Description

The lt() method determines if c1 < c2.

Method             move()

Access             Public

Classification     Accessor

Syntax             static char_type* move(char_type* s1, const char_type* s2,
                                          size_t n);

Parameters         s1 points to a sequence of characters in which
                   characters from array s2 is copied.

                   s2 points to a sequence of characters which
                   are copied to array s1.

                   n is the number of characters.

Returns            This method returns s1.

Description

The move() method moves n characters from s2 to s1 using the assign(s[i],s2[i]). This method will work correctly even if s2 is in the range of s1 + n.

Method             to_char_type()

Access             Public

Classification     Accessor

Syntax             static char_type to_char_type(const int_type& c);

Parameters         c is a reference to an int_type that is
                   to be mapped to a char_type.

Returns            This method returns the corresponding char_type.

Description

The to_char_type() method maps an int_type c to a char_type. The corresponding char_type is returned.

static int_type to_int_type(const char_type& c);

Method             to_int_type()

Access             Public

Classification     Accessor

Syntax             static int_type to_int_type(const char_type& c);

Parameters         c is a reference to a char_type that is
                   to be mapped to an int_type.

Returns            This method returns the corresponding int_type.

Description

The to_int_type() method maps an char_type c to an int_type. The corresponding int_type is returned.

The Class Relationship Diagram for char_traits


codecvt

Class Name            codecvt

Header File          <locale>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

locale::id

Methods

bool always_noconv() const throw();

explicit codecvt(size_t refs = 0);

~codecvt();

virtual bool do_always_noconv() const throw();

virtual int do_encoding() const throw();

virtual result do_in(stateT& state, const externT* from,
const externT* from_end, const externT*& from_next, internT* to,
internT* to_limit, internT*& to_next) const;

virtual int do_length(const stateT&, const externT* from,
const externT* end, size_t max) const;

virtual int do_max_length() const throw();

virtual result do_out(stateT& state, const internT* from,
const internT* from_end, const internT*& from_next, externT* to,
externT* to_limit, externT*& to_next) const;

virtual result do_unshift(stateT& state, externT* to,
externT* to_limit, externT*& to_next) const;

int encoding() const throw();

result in(stateT& state, const externT* from, const externT* from_end,
const externT*& from_next, internT* to, internT* to_limit,
internT*& to_next) const;

int length(const stateT&, const externT* from, const externT* end,
size_t max) const;

int max_length() const throw();

result out(stateT& state, const internT* from, const internT* from_end,
const internT*& from_next, externT* to, externT* to_
limit, externT*& to_next) const;

result unshift(stateT& state, externT* to, externT* to_limit,
externT*& to_next) const;

Class Description

The codecvt template class describes an object that controls conversions between one codeset to another. For example, this class is used to convert wide characters to multibyte characters. The template parameter stateT selects the pair of codesets used in the mapping.

locale::id

The id class is used to provide an identification of a locale facet interfaces used as an index for lookup and to encapsulate initialization.

Method             always_noconv()

Access             Public

Classification     Modifier

Syntax             bool always_noconv() const throw();

Parameters         None

Returns            This method returns true if do_convert() returns
                   noconv for all valid argument values.

Description

The always_noconv() member function returns do_always_noconv().

Method             codecvt()

Access             Public

Classification     Constructor

Syntax             explicit codecvt(size_t refs = 0);

Parameters         refs, if the refs argument = 0 then the destruction
                   of the object is delegated to the locale or locales
                   which contain it. If refs = 1 then the object must
                   be explicitly deleted. The locale will not delete
                   it. The object can then be maintained across the
                   lifetime of multiple locales.

Returns            None

Description

The constructor constructs a codecvt facet object.

Method             codecvt()

Access             Protected

Classification     Destructor

Syntax             ~codecvt();

Parameters         None

Returns            None

Description

The destructor destroys a codecvt facet object.

Method             do_always_noconv()

Access             Protected

Classification     Accessor

Syntax             virtual bool do_always_noconv() const throw();

Parameters         None

Return Type        bool

Description

The do_always_noconv() method will return true only if for all valid arguments value do_convert() returns noconv. (table 55)

Method             do_encoding()

Access             Protected

Classification     Accessor

Syntax             virtual int do_encoding() const throw();

Parameters         None

Return             This method returns an int which contains the
                   constant number of externT characters needed to
                   produce an internal character.

Description

The do_encoding() method returns -1 if the encoding of the externT sequence is state dependent. The method returns the constant number of externT characters that are needed in the encoding to produce an internal character or returns 0 if that number is not a constant.

Method             do_in()

Access             Protected

Classification     Modifier

Syntax             virtual result do_in(stateT& state, const externT* from,
                                        const externT* from_end,
                                        const externT*& from_next,
                                        internT* to, internT* to_limit,
                                        internT*& to_next) const;

Parameters         state is unspecified.

                   from is the beginning of the source character sequence.

                   from_end is the end of the source character sequence.

                   from_next points to character in the source sequence.

                   to is the beginning of the destination sequence.

                   to_limit is the end of the destination sequence.

                   to_next points to character in the destination sequence.

Returns            This method returns the enumerated value of ok,
                   partial, error or noconv.

Description

The do_in() method translates the sequence at [from,from_end) to a destination sequence stored at [to, to_limit). It translates no more than (from_end - from) source character elements and stores no more than (to_limit - to) destination character elements. The method will stop when it encounters a character in the source sequence that it cannot convert. The from_next and to_next pointers will point one beyond the last element that was successfully translated.
If no translation takes place then the member function will return noconv. The pointer to_next will be equal to the argument to and the pointer from_next will be equal to the argument from. If only some of the characters are translated then the method will return partial. If from_next == from_end then either the destination character sequence has not taken in all of the available destination character elements or that additional source character elements are required before any another destination character elements can be produced. (table 54)

Method             do_length()

Access             Protected

Classification     Accessor

Syntax             virtual int do_length(stateT& state, const externT* from,
                                         const externT* end,
                                         size_t max) const throw();

Parameters         state is initialized either for the beginning of a
                   sequence or equal to the result of the previous
                   conversion of the sequence.

                   from is the beginning of the character sequence.

                   end is the end of the character sequence.

                   max is maximum value of internT characters available
                   in the specified range.

Return Type        int

Description

The do_length() method returns the largest number of characters less than max internT characters that are available in the range [from, end].

Method             do_max_length()

Access             Protected

Classification     Accessor

Syntax             virtual int do_max_length() const throw();

Parameters         None

Returns            This method returns an int that contains the maximum
                   value that do_length() returns.

Description

The do_max_length() method returns the maximum value that can be returned by do_length(state, from, from_end, 1) for any valid range [from,from_end) and state value.

Method             do_out()

Access             Protected

Classification     Modifier

Syntax             virtual result do_out(stateT& state,
                                         const internT* from,
                                         const internT* from_end,
                                         const internT*& from_next,
                                         externT* to, externT* to_limit,
                                         externT*& to_next) const;

Parameters         state is unspecified.

                   from is the beginning of the source character
                   sequence.

                   from_end is the end of the source character
                   sequence.

                   from_next points to character in the source
                   sequence.

                   to is the beginning of the destination sequence.

                   to_limit is the end of the destination sequence.

                   to_next points to character in the destination sequence.

Return             This method returns an enumerated value ok, partial,
                   error or noconv.

Description

The do_out() method translates the sequence at [from,from_end) to a destination sequence stored at [to, to_limit). It translates no more than (from_end - from) source character elements and stores no more than (to_limit - to) destination character elements. The method will stop when it encounters a character in the source sequence that it cannot convert. The from_next and to_next pointers will point one beyond the last element that was successfully translated.

If no translation takes place then the method will return noconv. The pointer to_next will be equal to the argument to and the pointer from_next will be equal to the argument from. If only some of the characters are translated then the method will return partial. If from_next == from_end then either the destination character sequence has not taken in all of the available destination character elements or that additional source character elements are required before any another destination character elements can be produced. (table 54)

Method             do_unshift()

Access             Protected

Classification     Modifier

Syntax             virtual result do_unshift(stateT& state, externT* to,
                                             externT* to_limit,
                                             externT*& to_next) const;

Parameters         state reveals the current state.

                   to is the starting position where the results are
                   sequentially placed.

                   to_limit is used to determine the number of
                   characters that are to be stored.

                   to_next points to one beyond the last element if
                   conversion is successful.

Return             This method returns an enumerated value ok, partial,
                   error or noconv.

Description

The do_unshift() method places characters starting at to that should be appended to termintate a sequence when the current stateT is given by the argument state. The method returns the enumerated value error, noconv, ok or partial.

Method             in()

Access             Public

Classification     Modifier

Syntax             virtual result in(stateT& state,
                                     const internT* from,
                                     const internT* from_end,
                                     const internT*& from_next,
                                     externT* to, externT* to_limit,
                                     externT*& to_next) const;

Parameters         state is unspecified. It can be used to shift
                   state, to specify conversion options, or used to
                   identify  cache of seek offsets.

                   from is the beginning of the source character
                   sequence.

                   from_end is the end of the source character
                   sequence.

                   from_next points to character in the source
                   sequence.

                   to is the beginning of the destination sequence.

                   to_limit is the end of the destination sequence.

                   to_next points to character in the destination
                   sequence.

Return             This method returns an enumerated value ok, partial,
                   error or noconv.

Description

The in() method returns do_in(state, from, from_end, from_next, to, to_limit, to_next).

Method             length()

Access             Public

Classification     Accessor

Syntax             int length(const stateT& state, const externT* from,
                              const externT* end, size_t max) const;

Parameters         state is initialized either for the beginning of
                   a sequence or equal to the result of the previous
                   conversion of the sequence.

                   from is the beginning of the character sequence.

                   end is the end of the character sequence.

                   max is maximum value of internT characters available
                   in the specified range.

Return             This method returns the number max or fewer internT
                   characters.

Description

The length() method returns do_length(state, from, end, max).

Method             encoding()

Access             Public

Classification     Accessor

Syntax             int encoding() const throw();

Parameters         None

Return             This method returns the constant number of externT
                   characters needed to produce an internal character.

Description

The encoding() method returns do_encoding().

Method             max_length()

Access             Public

Classification     Accessor

Syntax             int max_length() const throw();

Parameters         None

Return             This method returns the maximum value that
                   do_length() can return.

Description

The max_length() method returns do_max_length().

Method             out()

Access             Public

Classification     Modifier

Syntax             result out(stateT& state, const internT* from,
                              const intern* from_end,
                              const internT*& from_next,
                              externT* to, extern* to_limit,
                              externT*& to_next);

Parameters         state is unspecified. It can be used to shift
                   state, to specify conversion options, or used to
                   identify  cache of seek offsets.

                   from is the beginning of the source range.

                   from_end is the end of the source range.

                   from_next points to one beyond the last element
                   if conversion is successful.

                   to is the starting position where the results are
                   sequentially placed.

                   to_limit is used to determine the number of
                   characters that are to be stored.

                   to_next points to one beyond the last element if
                   conversion is successful.

Return             This method returns an enumerated value ok, partial,
                   error, or noconv.

Description

The out() method returns do_out(state, from, from_end, from_next, to, to_limit, to_next).

Method             unshift()

Access             Public

Classification     Modifier

Syntax             result unshift(stateT state&, externT* to,
                                  externT* to_limit,
                                  externT*& to_next) const;

Parameters         state reveals the current state.

                   to is the starting position where the results are
                   sequentially placed.

                   to_limit is used to determine the number of
                   characters that are to be stored.

                   to_next points to one beyond the last element if
                   conversion is successful.

Return Type        result

Description

The unshift() method returns do_unshift(state, to, to_limit, to_next).

The Class Relationship Diagram for codecvt


codecvt_base

Class Name            codecvt_base

Header File           <locale>

Classification        abstract data type
Class Relationship Diagram

Class Description

Member Classes

None

Class Description

The codecvt_base class describes an enumeration common to all specializations of template class codecvt. The enumeration values describes the possible return values from do_in() or do_out():

     error         If the source sequence contains a from_type character
                   it could not convert.

     noconv        If the function performs no conversion.

     ok            If the conversion succeeds.

     partial       If all the source characters were not converted.

The Class Relationship Diagram for codecvt_base


codecvt

Class Name            codecvt

Header File           <locale>

Classification        abstract data type
Class Relationship Diagram

Class Description

Member Classes

locale::id

Methods

bool always_noconv() const throw();

explicit codecvt(size_t refs = 0);

~codecvt();

virtual bool do_always_noconv() const throw();

virtual int do_encoding() const throw();

virtual result do_in(stateT& state, const externT* from,
const externT* from_end, const externT*& from_next, internT* to,
internT* to_limit, internT*& to_next) const;

virtual int do_length(const stateT&, const externT* from,
const externT* end, size_t max) const;

virtual int do_max_length() const throw();

virtual result do_out(stateT& state, const internT* from,
const internT* from_end, const internT*& from_next, externT* to,
externT* to_limit, externT*& to_next) const;

virtual result do_unshift(stateT& state, externT* to,
externT* to_limit, externT*& to_next) const;

int encoding() const throw();

result in(stateT& state, const externT* from, const externT* from_end,
const externT*& from_next, internT* to, internT* to_limit,
internT*& to_next) const;

int length(const stateT&, const externT* from, const externT* end,
size_t max) const;

int max_length() const throw();

result out(stateT& state, const internT* from, const internT* from_end,
const internT*& from_next, externT* to, externT* to_
limit, externT*& to_next) const;

result unshift(stateT& state, externT* to, externT* to_limit,
externT*& to_next) const;

Class Description

The codecvt template class describes an object that controls conversions between one codeset to another. For example, this class is used to convert wide characters to multibyte characters. The template parameter stateT selects the pair of codesets used in the mapping.

locale::id

The id class is used to provide an identification of a locale facet interfaces used as an index for lookup and to encapsulate initialization.

Method             always_noconv()

Access             Public

Classification     Modifier

Syntax             bool always_noconv() const throw();

Parameters         None

Returns            This method returns true if do_convert() returns
                   noconv for all valid argument values.

Description

The always_noconv() member function returns do_always_noconv().

Method             codecvt()

Access             Public

Classification     Constructor

Syntax             explicit codecvt(size_t refs = 0);

Parameters         refs, if the refs argument = 0 then the destruction
                   of the object is delegated to the locale or locales
                   which contain it. If refs = 1 then the object must
                   be explicitly deleted. The locale will not delete
                   it. The object can then be maintained across the
                   lifetime of multiple locales.

Returns            None

Description

The constructor constructs a codecvt facet object.

Method             codecvt()

Access             Protected

Classification     Destructor

Syntax             ~codecvt();

Parameters         None

Returns            None

Description

The destructor destroys a codecvt facet object.

Method             do_always_noconv()

Access             Protected

Classification     Accessor

Syntax             virtual bool do_always_noconv() const throw();

Parameters         None

Return Type        bool

Description

The do_always_noconv() method will return true only if for all valid arguments value do_convert() returns noconv.

Method             do_encoding()

Access             Protected

Classification     Accessor

Syntax             virtual int do_encoding() const throw();

Parameters         None

Return             This method returns an int which contains the
                   constant number of externT characters needed to
                   produce an internal character.

Description

The do_encoding() method returns -1 if the encoding of the externT sequence is state dependent. The method returns the constant number of externT characters that are needed in the encoding to produce an internal character or returns 0 if that number is not a constant.

Method             do_in()

Access             Protected

Classification     Modifier

Syntax             virtual result do_in(stateT& state, const externT* from,
                                         const externT* from_end,
                                         const externT*& from_next,
                                         internT* to, internT* to_limit,
                                         internT*& to_next) const;

Parameters         state is unspecified.

                   from is the beginning of the source character sequence.

                   from_end is the end of the source character sequence.

                   from_next points to character in the source sequence.

                   to is the beginning of the destination sequence.

                   to_limit is the end of the destination sequence.

                   to_next points to character in the destination sequence.

Return Type        result

Description

The do_in() method translates the sequence at [from,from_end) to a destination sequence stored at [to, to_limit). It translates no more than (from_end - from) source character elements and stores no more than (to_limit - to) destination character elements. The method will stop when it encounters a character in the source sequence that it cannot convert. The from_next and to_next pointers will point one beyond the last element that was successfully translated.

If no translation takes place then the member function will return noconv. The pointer to_next will be equal to the argument to and the pointer from_next will be equal to the argument from. If only some of the characters are translated then the method will return partial. If from_next == from_end then either the destination character sequence has not taken in all of the available destination character elements or that additional source character elements are required before any another destination character elements can be produced.

Method             do_length()

Access             Protected

Classification     Accessor

Syntax             virtual int do_length(stateT& state, const externT* from,
                                         const externT* end,
                                         size_t max) const throw();

Parameters         state is initialized either for the beginning of a
                   sequence or equal to the result of the previous
                   conversion of the sequence.

                   from is the beginning of the character sequence.

                   end is the end of the character sequence.

                   max is maximum value of internT characters available
                   in the specified range.

Return Type        int

Description

The do_length() method returns the largest number of characters less than max internT characters that are available in the range [from, end].

Method             do_max_length()

Access             Protected

Classification     Accessor

Syntax             virtual int do_max_length() const throw();

Parameters         None

Returns            This method returns an int that contains the maximum
                   value that do_length() returns.

Description

The do_max_length() method returns the maximum value that can be returned by do_length(state, from, from_end, 1) for any valid range [from,from_end) and state value.

Method             do_out()

Access             Protected

Classification     Modifier

Syntax             virtual result do_out(stateT& state,
                                         const internT* from,
                                         const internT* from_end,
                                         const internT*& from_next,
                                         externT* to, externT* to_limit,
                                         externT*& to_next) const;

Parameters         state is unspecified.

                   from is the beginning of the source character
                   sequence.

                   from_end is the end of the source character
                   sequence.

                   from_next points to character in the source
                   sequence.

                   to is the beginning of the destination sequence.

                   to_limit is the end of the destination sequence.

                   to_next points to character in the destination sequence.

Return Type        result

Description

The do_out() method translates the sequence at [from,from_end) to a destination sequence stored at [to, to_limit). It translates no more than (from_end - from) source character elements and stores no more than (to_limit - to) destination character elements. The method will stop when it encounters a character in the source sequence that it cannot convert. The from_next and to_next pointers will point one beyond the last element that was successfully translated.

If no translation takes place then the method will return noconv. The pointer to_next will be equal to the argument to and the pointer from_next will be equal to the argument from. If only some of the characters are translated then the method will return partial. If from_next == from_end then either the destination character sequence has not taken in all of the available destination character elements or that additional source character elements are required before any another destination character elements can be produced.

Method             do_unshift()

Access             Protected

Classification     Modifier

Syntax             virtual result do_unshift(stateT& state, externT* to,
                                             externT* to_limit,
                                             externT*& to_next) const;

Parameters         state reveals the current state.

                   to is the starting position where the results are
                   sequentially placed.

                   to_limit is used to determine the number of
                   characters that are to be stored.

                   to_next points to one beyond the last element if
                   conversion is successful.

Return Type        result

Description

The do_unshift() method places characters starting at to that should be appended to termintate a sequence when the current stateT is given by the argument state. The method returns the enumerated value error, noconv, ok or partial.

Method             in()

Access             Public

Classification     Modifier

Syntax             virtual result in(stateT& state,
                                     const internT* from,
                                     const internT* from_end,
                                     const internT*& from_next,
                                     externT* to, externT* to_limit,
                                     externT*& to_next) const;

Parameters         state is unspecified. It can be used to shift
                   state, to specify conversion options, or used to
                   identify  cache of seek offsets.

                   from is the beginning of the source character
                   sequence.

                   from_end is the end of the source character
                   sequence.

                   from_next points to character in the source
                   sequence.

                   to is the beginning of the destination sequence.

                   to_limit is the end of the destination sequence.

                   to_next points to character in the destination
                   sequence.

Return Type        result

Description

The in() method returns do_in(state, from, from_end, from_next, to, to_limit, to_next).

Method             length()

Access             Public

Classification     Accessor

Syntax             int length(const stateT& state, const externT* from,
                              const externT* end, size_t max) const;

Parameters         state is initialized either for the beginning of
                   a sequence or equal to the result of the previous
                   conversion of the sequence.

                   from is the beginning of the character sequence.

                   end is the end of the character sequence.

                   max is maximum value of internT characters available
                   in the specified range.

Return             This method returns the number max or fewer internT
                   characters.

Description

The length() method returns do_length(state, from, end, max).

Method             encoding()

Access             Public

Classification     Accessor

Syntax             int encoding() const throw();

Parameters         None

Return             This method returns the constant number of externT
                   characters needed to produce an internal character.

Description

The encoding() method returns do_encoding().

Method             max_length()

Access             Public

Classification     Accessor

Syntax             int max_length() const throw();

Parameters         None

Return             This method returns the maximum value that
                   do_length() can return.

Description

The max_length() method returns do_max_length().

Method             out()

Access             Public

Classification     Modifier

Syntax             result out(stateT& state, const internT* from,
                              const intern* from_end,
                              const internT*& from_next,
                              externT* to, extern* to_limit,
                              externT*& to_next);

Parameters         state is unspecified. It can be used to shift
                   state, to specify conversion options, or used to
                   identify  cache of seek offsets.

                   from is the beginning of the source range.

                   from_end is the end of the source range.

                   from_next points to one beyond the last element
                   if conversion is successful.

                   to is the starting position where the results are
                   sequentially placed.

                   to_limit is used to determine the number of
                   characters that are to be stored.

                   to_next points to one beyond the last element if
                   conversion is successful.

Return Type        result

Description

The out() method returns do_out(state, from, from_end, from_next, to, to_limit, to_next).

Method             unshift()

Access             Public

Classification     Modifier

Syntax             result unshift(stateT state&, externT* to,
                                  externT* to_limit,
                                  externT*& to_next) const;

Parameters         state reveals the current state.

                   to is the starting position where the results are
                   sequentially placed.

                   to_limit is used to determine the number of
                   characters that are to be stored.

                   to_next points to one beyond the last element if
                   conversion is successful.

Return Type        result

Description

The unshift() method returns do_unshift(state, to, to_limit, to_next).

TABLE 1:

The result values are:

     Value         Meaning

     ok            The conversion was completed

     partial       Not all of the source characters were converted.

     error         A from_type character was encountered and could
                   not be converted.

     noconv        No conversion was needed.

TABLE 2:

The result values are:

     Value         Meaning

     ok            The sequence was completed

     partial       More characters are needed to complete termination.

     error         state has an invalid value.

     noconv        For this state_type, no termination is needed.

The Class Relationship Diagram for codecvt


codecvt

Class Name            codecvt_byname

Header File          <locale>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

None

Methods

explicit codecvt_byname(const char* name, size_t refs = 0);

~codecvt_byname();

virtual bool do_always_noconv() const throw();

virtual int do_encoding() const throw();

virtual result do_in(stateT& state, const externT* from,
const externT* from_end, const externT*& from_next, internT* to,
internT* to_limit, internT*& to_next) const;

virtual int do_length(const stateT&, const externT* from,
const externT* end, size_t max) const;

virtual int do_max_length() const throw();

virtual result do_out(stateT& state, const internT* from,
const internT* from_end, const internT*& from_next, externT* to,
externT* to_limit, externT*& to_next) const;

Class Description

The codecvt_byname template class describes a class that controls conversions between one codeset to another for a named locale.

Method             codecvt_byname()

Access             Public

Classification     Constructor

Syntax             explicit codecvt_byname(size_t refs = 0);

Parameters         refs, if the refs argument = 0 then the destruction
                   of the object is delegated to the locale or locales
                   which contain it. If refs = 1 then the object must
                   be explicitly deleted. The locale will not delete
                   it. The object can then be maintained across the
                   lifetime of multiple locales.

Return             None

Description

The constructor constructs a codecvt_byname facet object.

Method             codecvt_byname()

Access             Protected

Classification     Destructor

Syntax             ~codecvt_byname();

Parameters         None

Return             None

Description

The destructor destroys a codecvt_byname facet object.

Method             do_always_noconv()

Access             Protected

Classification     Accessor

Syntax             virtual bool do_always_noconv() const throw();

Parameters         None

Return Type        bool

Description

The do_always_noconv() method will return true only if for all valid arguments value do_convert() returns noconv.

Method             do_encoding()

Access             Protected

Classification     Accessor

Syntax             virtual int do_encoding() const throw();

Parameters         None

Return             This method returns the constant number of externT
                   characters needed to produce an internal character.

Description

The do_encoding() method returns -1 if the encoding of the externT sequence is state dependent, returns the constant number of externT characters that are needed in the encoding to produce an internal character or returns 0 if that number is not a constant.

Method             do_in()

Access             Protected

Classification     Modifier

Syntax             virtual result do_in(stateT& state,
                                        const externT* from,
                                        const externT* from_end,
                                        const externT*& from_next,
                                        internT* to, internT* to_limit,
                                        internT*& to_next) const;

Parameters         state is unspecified.

                   from is the beginning of the source character
                   sequence.

                   from_end is the end of the source character sequence.

                   from_next points to character in the source sequence.

                   to is the beginning of the destination sequence.

                   to_limit is the end of the destination sequence.

                   to_next points to character in the destination
                   sequence.

Return Type      result

Description

The do_in() method translates the sequence at [from,from_end) to a destination sequence stored at [to, to_limit). It translates no more than (from_end - from) source character elements and stores no more than (to_limit - to) destination character elements. The method will stop when it encounters a character in the source sequence that it cannot convert. The from_next and to_next pointers will point one beyond the last element that was successfully translated. If no translation takes place then the method will return noconv. The pointer to_next will be equal to the argument to and the pointer from_next will be equal to the argument from. If only some of the characters are translated then the method will return partial. If from_next == from_end then either the destination character sequence has not taken in all of the available destination character elements or that additional source character elements are required before any another destination character elements can be produced.

Method             do_length()

Access             Protected

Classification     Accessor

Syntax             virtual int do_length(stateT& state,
                                         const externT* from,
                                         const externT* end,
                                         size_t max) const throw();

Parameters         state is initialized either for the beginning of a
                   sequence or equal to the result of the previous
                   conversion of the sequence.

                   from is the beginning of the character sequence.

                   end is the end of the character sequence.

                   max is maximum value of internT characters available
                   in the specified range.

Return Type        int

Description

The do_length() method returns the largest number of characters less than max internT characters that are available in the range [from, end].

Method             do_max_length()

Access             Protected

Classification     Accessor

Syntax             virtual int do_max_length() const throw();

Parameters         None

Return             This method returns an int that contains the maximum
                   value that do_length() returns.

Description

The do_max_length() method returns the maximum value that can be returned by do_length(state, from, from_end, 1) for any valid range [from,from_end) and state value.

Method             do_out()

Access             Protected

Classification     Modifier

Syntax             virtual result do_out(stateT& state,
                                         const internT* from,
                                         const internT* from_end,
                                         const internT*& from_next,
                                         externT* to, externT* to_limit,
                                         externT*& to_next) const;

Parameters         state is unspecified.

                   from is the beginning of the source character
                   sequence.

                   from_end is the end of the source character
                   sequence.

                   from_next points to character in the source
                   sequence.

                   to is the beginning of the destination sequence.

                   to_limit is the end of the destination sequence.

                   to_next points to character in the destination
                   sequence.

Return Type         result

Description

The do_out() method translates the sequence at [from,from_end) to a destination sequence stored at [to, to_limit). It translates no more than (from_end - from) source character elements and stores no more than (to_limit - to) destination character elements. The method will stop when it encounters a character in the source sequence that it cannot convert. The from_next and to_next pointers will point one beyond the last element that was successfully translated. If no translation takes place then the member function will return noconv. The pointer to_next will be equal to the argument to and the pointer from_next will be equal to the argument from. If only some of the characters are translated then the method will return partial. If from_next == from_end then either the destination character sequence has not taken in all of the available destination character elements or that additional source character elements are required before any another destination character elements can be produced.

The Class Relationship Diagram for codecvt_byname


collate

Class Name            collate

Header File          <locale>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

locale::id

Methods

explicit collate(size_t refs = 0);

~collate();

int compare(const charT* low1, const charT* high1, const charT* low2,
const charT* high2) const;

virtual int do_compare(const charT* low1, const charT* high1,
const charT* low2, const charT* high2) const;

virtual long do_hash (const charT* low, const charT* high) const;

virtual string_type do_transform(const charT* low, const charT* high) const;

long hash(const charT* low, const charT* high) const;

string_type transform(const charT* low, const charT* high) const;

Class Description

The collate template class describes a class used to provide string collation, comparisons, and hashing facilities.

locale::id

locale::id is a class used to provide an identification of a locale facet interfaces used as an index for lookup and to encapsulate initialization.

Method             collate()

Access             Public

Classification     Constructor

Syntax             explicit collate(size_t refs = 0);

Parameters         refs, if the refs argument = 0 then the destruction
                   of the object is delegated to the locale or locales
                   which contain it. If refs = 1 then the object must
                   be explicitly deleted. The locale will not delete it.
                   The object can then be maintained across the lifetime
                   of multiple locales.

Return             None

Description

The constructor constructs a collate facet object.

Method             collate()

Access             Protected

Classification     Destructor

Syntax             ~collate();

Parameters         None

Returns            None

Description

This destructor destroys a collate facet object.

Method             compare()

Access             Public

Classification     Accessor

Syntax             int compare(const charT* low1, const charT* high1,
                               const charT* low2, const charT* high2) const;

Parameters         low1 is the beginning of the character sequence of
                   the first string.

                   high1 is the end of the character sequence of
                   the first string.

                   low2 is the beginning of the character sequence of
                   the second string.

                   high2 is the end of the character sequence of the
                   second string.

Return             This method returns 1 if the first string is
                   greater than the second string.

Description

The compare() member function returns do_compare(low1, high1, low2, high2).

Method             do_compare()

Access             Protected

Classification     Accessor

Syntax             virtual int do_compare(const charT* low1,
                                          const charT* high1,
                                          const charT* low2,
                                          const charT* high2) const;

Parameters         low1 is the beginning of the first string's
                   character sequence.

                   high1 is the end of the first string's
                   character sequence.

                   low2 is the beginning of the second string's
                   character sequence.

                   high2 is the end of the second string's
                   character sequence.

Return Type        int

Description

The compare() method compares the sequence at [low1, high1) with the sequence at [low2, high2). It performs a lexicographical comparison. It returns -1 if the first sequence compares less than the second sequence. It returns 1 if the second sequence compares less. The function returns zero otherwise.

Method             do_hash()

Access             Protected

Classification     Accessor

Syntax             virtual long do_hash(const charT* low,
                                        const charT* high) const;

Parameters         low is the beginning of the string's character
                   sequence.

                   high is the end of the string's character sequence.

Return Type        long

Description

The do_hash() method returns an integer derived from the values of the elements in the string's character sequence [low, high].

Method             do_transform()

Access             Protected

Classification     Accessor

Syntax             virtual string_type do_transform(const charT* low,
                                                    const charT* high) const;

Parameters         low is the beginning of the string's character
                   sequence.

                   high is the end of the string's character sequence.

Return Type        string_type

Description

The do_transfom() method returns a basic_string object that when compared lexicographically with the result of calling the transform() member function on another string will produce the same result as calling do_compare() on the same two strings.

Method             hash()

Access             Protected

Classification     Accessor

Syntax             long hash(const charT* low, const charT* high) const;

Parameters         low is the beginning of the string's character
                   sequence.

                   high is the end of the string's character
                   sequence.

Return Type        long

Description

The hash() member function returns do_hash(low, high).

Method             transform()

Access             Public

Classification     Accessor

Syntax             string_type transform(const charT* low,
                                         const charT* high) const;

Parameters         low is the beginning of the string's character
                   sequence.

                   high is the end of the string's character
                   sequence.

Return Type        string_type

Description

The transform() member function returns do_transform(low, high).

The Class Relationship Diagram for collate


collate_byname

Class Name            collate_byname

Header File          <locale>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

None

Methods

explicit collate_byname(const char*, size_t refs = 0);

~collate_byname();

virtual int do_compare(const charT* low1, const charT* high1,
const charT* low2, const charT* high2) const;

virtual long do_hash( const charT* low, const charT* high) const;

virtual string_type do_transform(const charT* low, const charT* high) const;

Class Description

The collate_byname template class describes an object that can serve as a locale facet of type collate<&charT>. Its behavior is determined by the named locale.

Method             collate_byname()

Access             Public

Classification     Constructor

Syntax             explicit collate_byname(const char *s,
                                           size_t refs = 0);

Parameters         s is the name of the named locale.

                   refs, if the refs argument = 0 then the destruction
                   of the object is delegated to the locale or locales
                   which contain it. If refs = 1 then the object must
                   be explicitly deleted. The locale will not delete it.
                   The object can then be maintained across the lifetime
                   of multiple locales.

Return Type        None

Description

This constructor constructs a collate_byname facet object.

Method             collate_byname()

Access             Protected

Classification     Destructor

Syntax             ~collate_byname();

Parameters         None

Returns            None

Description

The destructor destroys a collate_byname facet object.

Method             do_compare()

Access             Protected

Classification     Accessor

Syntax             virtual int do_compare(const charT* low1,
                                          const charT* high1,
                                          const charT* low2,
                                          const charT* high2) const;

Parameters         low1 is the beginning of the first string's
                   character sequence.

                   high1 is the end of the first string's
                   character sequence.

                   low2 is the beginning of the second string's
                   character sequence.

                   high2 is the end of the second string's character
                   sequence.

Return Type        int

Description

The compare() method compares the sequence at [low1, high1) with the sequence at [low2, high2). It performs a lexicographical comparison. It returns -1 if the first sequence compares less than the second sequence. It returns 1 if the second sequence compares less. The function returns zero otherwise.

Method             do_hash()

Access             Protected

Classification     Accessor

Syntax             virtual long do_hash(const charT* low,
                                        const charT* high) const;

Parameters         low is the beginning of the string's character
                   sequence.

                   high is the end of the string's character sequence.

Return Type        long

Description

The do_hash() method returns an integer derived from the values of the elements in the string's character sequence.

Method             do_transform()

Access             Protected

Classification     Accessor

Syntax             virtual string_type do_transform(const charT* low,
                                                    const charT* high) const;

Parameters         low is the beginning of the string's character
                   sequence.

                   high is the end of the string's character sequence.

Return Type        string_type

Description

The do_transfom() method returns a basic_string<charT> object that when compared lexicographically with the result of calling the transform() member function on another string will produce the same result as calling do_compare() on the same two strings.

The Class Relationship Diagram for collate_byname


The Common Methods For Sequence and Associative Containers

Class Name        Common Container Methods

Classification    Sequence  and Associative Containers

Methods

iterator begin()

const_iterator begin() const

bool empty() const

iterator end()

const_iterator end() const

size_type max_size() const

reverse_iterator rbegin()

const_reverse_iterator rbegin() const

reverse_iterator rend()

const_reverse_iterator rend() const

size_type size() const

Method            begin()

Access            Public

Classification    Accessor

Syntax            iterator begin()

Parameters        None

Return            This method returns a iterator(or const iterator for a const container)
                  that points to the first object in the container.

Description

The begin() method returns a iterator that points to the first object in the container.

Method            empty()

Access            Public

Classification    Accessor

Syntax            bool empty() const

Parameters        None

Return            returns true if the container is empty and false otherwise.

Description

The empty() method returns true if size() == 0 and false otherwise.

Method            max_size()

Access            Public

Classification    Accessor

Syntax            size_type max_size() const

Parameters        None

Return            This method returns the largest number of objects that the
                  container can hold.

Description

The max_size() method returns the largest number of objects that this container
can hold.  This value is influenced by memory model and allocator in effect.

Method            end()

Access            Public

Classification    Accessor

Syntax            iterator end()

Parameters        None

Return            This method returns a iterator(or const iterator for a const container)
                  that points to some value that is past the last object in the container.

Description

The end() method returns a iterator that points to a past-the-end value.  It points to some
value that is after the last object in the container.

Method            rbegin()

Access            Public

Classification    Accessor

Syntax            reverse_iterator rbegin()

Parameters        None

Return            This method returns a reverse_iterator (or a const reverse_iterator  for
                  const containers) that points at the first object in container from
                  end opposite of begin().

Description

The rbegin() method returns a iterator that can be used to traverse the container in reverse
order. Whichever location begin() points to, rbegin points to the opposite end of the container.

Method            rend()

Access            Public

Classification    Accessor

Syntax            reverse_iterator rend()

Parameters        None

Return            This method returns a reverse_iterator (or a const reverse_iterator  for
                  const containers) that points beyond the last object in container from
                  from the reverse order.

Description

The rend() method returns a iterator that can be used to test the end of a reverse
traversal through a container. The rend() method returns a reverse_iterator that points
beyond the last object in the container when moving from last object in the container
to the first object.

Method            size()

Access            Public

Classification    Accessor

Syntax            size_type size() const

Parameters        None

Return            This method returns the number of objects in a container.

Description

This method does not return how much memory the container requires. It returns the number
of objects that are contained in the container.  The memory requirements can be calculated
by using the size() method * the appropriate size of the objects in the container + the
size of the data members of the container.


container classes

  • set
  • multiset
  • map
  • multimap
  • vector
  • deque
  • queue
  • priority queue
  • list
  • stack
Access Methods and Logical View of Containers 


access methods and logical view

Access Methods and Logical View of Containers


ctype_base

Class Name            ctype_base

Header File          <locale>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

None

Class Description

The ctype_base template class describes a class used to provide a set of masks that identify the various classes of characters: space, print, cntrl, upper, lower, alpha, digit, punct, xdigit, alnu, or graph. These masks are passed to methods of ctype in order to obtain the verification of the classifications of a character or sequence of characters.

The Class Relationship Diagram for ctype_base


ctype

Class Name            ctype

Header File          <locale>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

locale::id

Methods

explicit ctype(size_t refs = 0);

~ctype();

virtual bool do_is(mask m, charT c) const;

virtual const charT* do_is(const charT* low, const charT* high,
mask* vec) const;

virtual const charT* do_scan_is(mask m, const charT* low,
const charT* high) const;

virtual const charT* do_scan_not(mask m, const charT* low,
const charT* high) const;

virtual char do_narrow(charT, char dfault) const;

virtual const charT* do_narrow(const charT* low, const charT* high,
char dfault, char* dest) const;

virtual charT do_tolower(charT c) const;

virtual const charT* do_tolower(charT* low, const charT* high) const;

virtual charT do_toupper(charT c) const;

virtual const charT* do_toupper(charT* low, const charT* high) const;

virtual charT do_widen(char) const;

virtual const char* do_widen(const char* low, const char* high,
charT* dest) const;

bool is(mask m, charT c) const;

const charT* is(const charT* low, const charT* high, mask* vec) const;

char narrow(charT c, char dfault) const;

const charT* narrow(const charT* low, const charT*, char dfault,
char* to) const;

const charT* scan_is(mask m, const charT* low, const charT* high) const;

const charT* scan_not(mask m, const charT* low, const charT* high) const;

charT tolower(charT c) const;

const charT* tolower(charT* low, const charT* high) const;

charT toupper(charT) const;

const charT* toupper(charT* low, const charT* high) const;

charT widen(char c) const;

const char* widen(const char* low, const char* high, charT* to) const;

Class Description

The ctype template class describes a class used to provide character classifications and simple conversions.

locale::id

locale::id is a class used to provide an identification of a locale facet interfaces used as an index for lookup and to encapsulate initialization.

Method             ctype()

Access             Public

Classification     Constructor

Syntax             explicit ctype(size_t refs = 0);

Parmeters          refs, if the refs argument = 0 then the destruction
                   of the object is delegated to the locale or locales
                   which contain it. If refs = 1 then the object must
                   be explicitly deleted. The locale will not delete it.
                   The object can then be maintained across the lifetime
                   of multiple locales.

Returns            None

Description

This constructor constructs a ctype facet object.

Method             ctype()

Access             Protected

Classification     Destructor

Syntax             ~ctype();

Parmeters          None

Returns            None

Description

The destructor destroys a ctype facet object.

Method             do_is()

Access             Protected

Classification     Accessor

Syntax             virtual bool do_is(mask m, charT c) const;

Parameters         m is one of the mask available from the ctype_base.

                   c is the character to be classified.

Return             This method returns true if the character matches the
                   classification indicated by the mask.

Description

The do_is() method classifies a character. The method determines if the character matches the classification indicated by the mask argument m. It returns true if the character matches the classification indicated by the mask.

Method             do_is()

Access             Protected

Classification     Accessor

Syntax             virtual const charT* do_is(const charT* low,
                                              const charT* high,
                                              mask* vec) const;

Parameters         low is the beginning of a sequence of characters.

                   high is the end of a sequence of characters.

                   vec is a vector of masks.

Return             This method returns the high argument.

Description

The do_is() method classifies a sequence of characters. The method fills vec with every mask from the ctype_base and applies it to the sequence of characters in the range [low, high).

Method             do_scan_is()

Access             Protected

Classification     Accessor

Syntax             virtual const charT* do_scan_is(mask m,
                                                   const charT* low,
                                                   const charT* high) const;

Parameters         m is one of the mask available from the ctype_base.

                   low is the beginning of a sequence of characters.

                   high is the end of a sequence of characters.

Returns            This method returns the first character in the
                   range that matches the classification indicated
                   by the mask m.

Description

The do_scan_is() method locates a character in the range [low, high) that conforms to the classification indicated by the mask argument m. This method returns the first character in the range that matches the classification indicated by the mask m. If the character is not in the range high is returned.

Method             do_scan_not()

Access             Protected

Classification     Accessor

Syntax             virtual const charT* do_scan_not(mask m,
                                                    const charT* low,
                                                    const charT* high) const;

Parameters         m is one of the mask available from the ctype_base.

                   low is the beginning of a sequence of characters.

                   high is the end of a sequence of characters.

Returns            This method returns the first character in the
                   range that does not match the classification
                   indicated by the mask m.

Description

The do_scan_is() method locates a character in the range [low, high) that does not conform to the classification indicated by the mask argument m. This method returns the first character in the range that does not match the classification indicated by the mask m. If the character is not in the range high is returned.

Method             do_narrow()

Access             Protected

Classification     Modifier

Syntax             virtual char do_narrow(charT c, char dfault) const;

Parameters         c is the character to be transformed.

                   dfault is character that is returned if no
                   transformation takes places.

Returns            This method returns the transformed value or
                   dfault if no transformation takes place.

Description

The do_narrow() method applies the simplest transformation from a charT value to the corresponding char value if it exist. The method returns the transformed value or returns the dfault argument if no transformation is possible.

Method             do_narrow()

Access             Protected

Classification     Modifier

Syntax             virtual const charT* do_narrow(const charT* low,
                                                  const charT* high,
                                                  char dfault,
                                                  char* dest) const;

Parameters         low is the beginning of a sequence of
                   characters.

                   high is the end of a sequence of
                   characters.

                   dfault is used as a default transformation.

                   dest is the destination of the results.

Returns            This method returns high.

Description

The do_narrow() method applies the simplest transformation from a sequence of charT values to the corresponding char values if they exist. If no simple transformation is possible then dfault is used. The method returns the transformed values in dest argument.

Method             do_tolower()

Access             Protected

Classification     Modifier

Syntax             virtual charT do_tolower(charT c) const;

Parameters         c is the character to be converted.

Returns            This method returns the converted character.

Description

The do_tolower() method converts the character argument c to lower case. The method returns the converted character. If no conversion is possible the argument is returned.

Method             do_tolower()

Access             Protected

Classification     Modifier

Syntax             virtual charT do_tolower(charT* low,
                                            const charT* high) const;

Parameters         low is the beginning of a sequence of
                   characters.

                   high is the end of a sequence of
                   characters.

Returns            This method returns high.

Description

The do_tolower() method converts each character in the character sequence [low, high) argument to lower case. Each character in the range is replaced with the lower case character. The method returns high.

Method             do_toupper()

Access             Protected

Classification     Modifier

Syntax             virtual charT do_toupper(charT c) const;

Parameters         c is the character to be converted.

Returns            This method returns the converted character.

Description

The do_tolower() method converts the character argument c to upper case. The method returns the converted character. If no conversion is possible the argument is returned.

Method             do_toupper()

Access             Protected

Classification     Modifier

Syntax             virtual charT do_toupper(charT* low,
                                            const charT* high) const;

Parameters         low is the beginning of a sequence of
                   characters.

                   high is the end of a sequence of
                   characters.

Returns            This method returns high.

Description

The do_tolower() method converts each character in the character sequence [low, high) argument to upper case. Each character in the range is replaced with the upper case character. The method returns high.

Method             do_widen()

Access             Protected

Classification     Modifier

Syntax             virtual charT do_widen(charT c) const;

Parameters         c is the character to be converted.

Returns            This method returns the transformed character.

Description

The do_tolower() method applies the simplest transformation from a char value to the corresponding charT value.

Method             do_widen()

Access             Protected

Classification     Modifier

Syntax             virtual const charT* do_widen(const char* low,
                                                 const char* high,
                                                 charT* dest) const;

Parameters         low is the beginning of a sequence of
                   characters.

                   high is the end of a sequence of
                   characters.

                   dest is the destination of the results.

Returns            This method returns high.

Description

The do_narrow() method applies the simplest transformation from a sequence of char values to the corresponding charT values if they exist. The method returns the transformed values in dest argument. The method returns high.

Method             is()

Access             Public

Classification     Accessor

Syntax             bool is(mask m, charT c) const;

Parameters         m is one of the mask available from the ctype_base.

                   c is the character to be classified.

Return             This method returns true if the character matches the
                   classification indicated by the mask.

Description

The do_is() method returns do_is(m, c).

Method             is()

Access             Public

Classification     Accessor

Syntax             const charT* is(const charT* low,
                                   const charT* high,
                                   mask* vec) const;

Parameters         low is the beginning of a sequence of characters.

                   high is the end of a sequence of characters.

                   vec is a vector of masks.

Return             This method returns the high argument.

Description

The do_is() method returns do_is(low, high, vec).

Method             scan_is()

Access             Public

Classification     Accessor

Syntax             const charT* scan_is(mask m,
                                        const charT* low,
                                        const charT* high) const;

Parameters         m is one of the mask available from the ctype_base.

                   low is the beginning of a sequence of characters.

                   high is the end of a sequence of characters.

Returns            This method returns the first character in the
                   range that matches the classification indicated
                   by the mask m.

Description

The scan_is() method returns do_scan_is(m, low, high).

Method             scan_not()

Access             Public

Classification     Accessor

Syntax             const charT* scan_not(mask m,
                                         const charT* low,
                                         const charT* high) const;

Parameters         m is one of the mask available from the ctype_base.

                   low is the beginning of a sequence of characters.

                   high is the end of a sequence of characters.

Returns            This method returns the first character in the
                   range that does not match the classification
                   indicated by the mask m.

Description

The scan_not() method returns scan_not(m, low, high).

Method             narrow()

Access             Public

Classification     Modifier

Syntax             char narrow(charT c, char dfault) const;

Parameters         c is the character to be transformed.

                   dfault is character that is returned if no
                   transformation takes places.

Returns            This method returns the transformed value or
                   dfault if no transformation takes place.

Description

The narrow() method returns do_narrow(c, dfault).

Method             narrow()

Access             Public

Classification     Modifier

Syntax             const charT* narrow(const charT* low,
                                       const charT* high,
                                       char dfault,
                                       char* to) const;

Parameters         low is the beginning of a sequence of
                   characters.

                   high is the end of a sequence of
                   characters.

                   dfault is used as a default transformation.

                   to is the destination of the results.

Returns            This method returns high.

Description

The narrow() method returns do_narrow(low, high, dfault,to).

Method             tolower()

Access             Public

Classification     Modifier

Syntax             charT tolower(charT c) const;

Parameters         c is the character to be converted.

Returns            This method returns the converted character.

Description

The tolower() method returns do_tolower(c).

Method             tolower()

Access             Public

Classification     Modifier

Syntax             charT tolower(charT* low,
                                 const charT* high) const;

Parameters         low is the beginning of a sequence of
                   characters.

                   high is the end of a sequence of
                   characters.

Returns            This method returns high.

Description

The tolower() method returns do_tolower(low, high).

Method             toupper()

Access             Public

Classification     Modifier

Syntax             charT toupper(charT c) const;

Parameters         c is the character to be converted.

Returns            This method returns the converted character.

Description

The toupper() method returns do_toupper(c).

Method             toupper()

Access             Public

Classification     Modifier

Syntax             charT do_toupper(charT* low,
                                    const charT* high) const;

Parameters         low is the beginning of a sequence of
                   characters.

                   high is the end of a sequence of
                   characters.

Returns            This method returns high.

Description

The toupper() method returns do_toupper(low, high).

Method             widen()

Access             Public

Classification     Modifier

Syntax             charT widen(charT c) const;

Parameters         c is the character to be converted.

Returns            This method returns the transformed character.

Description

The widen() method returns do_widen(c).

Method             widen()

Access             Public

Classification     Modifier

Syntax             const charT* widen(const char* low,
                                      const char* high,
                                      charT* to) const;

Parameters         low is the beginning of a sequence of
                   characters.

                   high is the end of a sequence of
                   characters.

                   to is the destination of the results.

Returns            This method returns high.

Description

The widen() method returns do_widen(low, high, to).

The Class Relationship Diagram for ctype


ctype_byname

Class Name            ctype_byname

Header File          <locale>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

None

Methods

explicit ctype_byname(const char* name, size_t refs = 0);

~ctype_byname();

virtual bool do_is(mask m, charT c) const;

virtual const charT* do_is(const charT* low, const charT* high,
mask* vec) const;

virtual const charT* do_scan_is(mask m, const charT* low,
const charT* high) const;

virtual const charT* do_scan_not(mask m, const charT* low,
const charT* high) const;

virtual char do_narrow(charT, char dfault) const;

virtual const charT* do_narrow(const charT* low, const charT* high,
char dfault, char* dest) const;

virtual charT do_tolower(charT c) const;

virtual const charT* do_tolower(charT* low, const charT* high) const;

virtual charT do_toupper(charT c) const;

virtual const charT* do_toupper(charT* low, const charT* high) const;

virtual charT do_widen(char) const;

virtual const char* do_widen(const char* low, const char* high,
charT* dest) const;

Class Description

The ctype_byname template class describes a class used to provide character classifications and simple conversions for named locales.

Method             ctype_byname()

Access             Public

Classification     Constructor

Syntax             explicit ctype(const char* name, size_t refs = 0);

Parmeters          refs, if the refs argument = 0 then the destruction
                   of the object is delegated to the locale or locales
                   which contain it. If refs = 1 then the object must
                   be explicitly deleted. The locale will not delete it.
                   The object can then be maintained across the lifetime
                   of multiple locales.

                   name is the name of the named locale.

Returns            None

Description

This constructor constructs a ctype facet object for a named locale. The name of the locale is specified by the argument name.

Method             ctype_byname()

Access             Protected

Classification     Destructor

Syntax             ~ctype_byname();

Parmeters          None

Returns            None

Description

The destructor destroys a ctype_byname facet object.

Method             do_is()

Access             Protected

Classification     Accessor

Syntax             virtual bool do_is(mask m, charT c) const;

Parameters         m is one of the mask available from the ctype_base.

                   c is the character to be classified.

Return             This method returns true if the character matches the
                   classification indicated by the mask.

Description

The do_is() method classifies a character. The method determines if the character matches the classification indicated by the mask argument m. It returns true if the character matches the classification indicated by the mask.

Method             do_is()

Access             Protected

Classification     Accessor

Syntax             virtual const charT* do_is(const charT* low,
                                              const charT* high,
                                              mask* vec) const;

Parameters         low is the beginning of a sequence of characters.

                   high is the end of a sequence of characters.

                   vec is a vector of masks.

Return             This method returns the high argument.

Description

The do_is() method classifies a sequence of characters. The method fills vec with every mask from the ctype_base and applies it to the sequence of characters in the range [low, high).

Method             do_scan_is()

Access             Protected

Classification     Accessor

Syntax             virtual const charT* do_scan_is(mask m,
                                                   const charT* low,
                                                   const charT* high) const;

Parameters         m is one of the mask available from the ctype_base.

                   low is the beginning of a sequence of characters.

                   high is the end of a sequence of characters.

Returns            This method returns the first character in the
                   range that matches the classification indicated
                   by the mask m.

Description

The do_scan_is() method locates a character in the range [low, high) that conforms to the classification indicated by the mask argument m. This method returns the first character in the range that matches the classification indicated by the mask m. If the character is not in the range high is returned.

Method             do_scan_not()

Access             Protected

Classification     Accessor

Syntax             virtual const charT* do_scan_not(mask m,
                                                    const charT* low,
                                                    const charT* high) const;

Parameters         m is one of the mask available from the ctype_base.

                   low is the beginning of a sequence of characters.

                   high is the end of a sequence of characters.

Returns            This method returns the first character in the
                   range that does not match the classification
                   indicated by the mask m.

Description

The do_scan_is() method locates a character in the range [low, high) that does not conform to the classification indicated by the mask argument m. This method returns the first character in the range that does not match the classification indicated by the mask m. If the character is not in the range high is returned.

Method             do_narrow()

Access             Protected

Classification     Modifier

Syntax             virtual char do_narrow(charT c, char dfault) const;

Parameters         c is the character to be transformed.

                   dfault is character that is returned if no
                   transformation takes places.

Returns            This method returns the transformed value or
                   dfault if no transformation takes place.

Description

The do_narrow() method applies the simplest transformation from a charT value to the corresponding char value if it exist. The method returns the transformed value or returns the dfault argument if no transformation is possible.

Method             do_narrow()

Access             Protected

Classification     Modifier

Syntax             virtual const charT* do_narrow(const charT* low,
                                                  const charT* high,
                                                  char dfault,
                                                  char* dest) const;

Parameters         low is the beginning of a sequence of
                   characters.

                   high is the end of a sequence of
                   characters.

                   dfault is used as a default transformation.

                   dest is the destination of the results.

Returns            This method returns high.

Description

The do_narrow() method applies the simplest transformation from a sequence of charT values to the corresponding char values if they exist. If no simple transformation is possible then dfault is used. The method returns the transformed values in dest argument.

Method             do_tolower()

Access             Protected

Classification     Modifier

Syntax             virtual charT do_tolower(charT c) const;

Parameters         c is the character to be converted.

Returns            This method returns the converted character.

Description

The do_tolower() method converts the character argument c to lower case. The method returns the converted character. If no conversion is possible the argument is returned.

Method             do_tolower()

Access             Protected

Classification     Modifier

Syntax             virtual charT do_tolower(charT* low,
                                            const charT* high) const;

Parameters         low is the beginning of a sequence of
                   characters.

                   high is the end of a sequence of
                   characters.

Returns            This method returns high.

Description

The do_tolower() method converts each character in the character sequence [low, high) argument to lower case. Each character in the range is replaced with the lower case character. The method returns high.

Method             do_toupper()

Access             Protected

Classification     Modifier

Syntax             virtual charT do_toupper(charT c) const;

Parameters         c is the character to be converted.

Returns            This method returns the converted character.

Description

The do_tolower() method converts the character argument c to upper case. The method returns the converted character. If no conversion is possible the argument is returned.

Method             do_toupper()

Access             Protected

Classification     Modifier

Syntax             virtual charT do_toupper(charT* low,
                                            const charT* high) const;

Parameters         low is the beginning of a sequence of
                   characters.

                   high is the end of a sequence of
                   characters.

Returns            This method returns high.

Description

The do_tolower() method converts each character in the character sequence [low, high) argument to upper case. Each character in the range is replaced with the upper case character. The method returns high.

Method             do_widen()

Access             Protected

Classification     Modifier

Syntax             virtual charT do_widen(charT c) const;

Parameters         c is the character to be converted.

Returns            This method returns the transformed character.

Description

The do_tolower() method applies the simplest transformation from a char value to the corresponding charT value.

Method             do_widen()

Access             Protected

Classification     Modifier

Syntax             virtual const charT* do_widen(const char* low,
                                                 const char* high,
                                                 charT* dest) const;

Parameters         low is the beginning of a sequence of
                   characters.

                   high is the end of a sequence of
                   characters.

                   dest is the destination of the results.

Returns            This method returns high.

Description

The do_narrow() method applies the simplest transformation from a sequence of char values to the corresponding charT values if they exist. The method returns the transformed values in dest argument. The method returns high.

The Class Relationship Diagram for ctype_byname


definitions

Dynamic Casting and bad_cast class

Sometimes casting an object may be necessary. There are four type cast operators:

     const_cast

     reinterpret_cast

     static_cast

     dynamic_cast

The purpose of a dynamic_cast is to upcast an object within a class hierarchy. The object to be upcast has to be a direct or indirect descendant of the type that is casting. For example:

     expression_component* Expression;
     operator_type* Operator;
     ...

     Expression = dynamic_cast Operator;

This statement assigns Expression a pointer to expression_component object. The Operator object of type operator_ type has been cast to expression_component. The expression_component is base class for operator_type. If operator_type had not been derived from expression_component then the operation would have returned a null pointer. It is called an upcast because the hierarchy has the base classes closer to the root of the hierarchy therefore casting to base classes moves upward in the structure.

If the dynamic_cast uses a reference instead of a pointer:

      dynamic_cast (p);

and the reference is not to a direct or indirect base class of type p then a bad_cast exception is thrown by dynamic_cast.

The typeid Operator

The typeid operator will accept a pointer when dereferenced evaluates to a type:

     typeid(*P);

If the pointer points to a null value then the typeid operator will throw a bad_typeid exception.

Bidirectional Iterator

Bidirectional iterators can perform all of the operations of the forward iterators with the additional ability to move in either direction sequentially. The term bidirectional means both directions. This means that the bidirectional iterator must perform postfix and prefix decrementation. These iterators can make multiple passes in either direction. These are the requirements for the bidirectional iterators:

     read, dereference and assign (on right side of assignment)

     write, dereference and assign (on left side of assignment) increment and decrement

     test for equality or inequality

The bidirectional iterator can move in a forward or backward direction as well as read and write elements to a container.

Random Access Iterators

The most powerful iterator and the iterator that completely models a pointer are the random access iterators. Random access operators define postfix and prefix increments and decrements. They are sequential iterators and also direct access iterators. They can read objects from an input source and write objects to an output source. Random access iterators can perform all of the operations of the bidirectional iterators with the additional ability to jump directly to any element in the container. In order for the random access iterator to jump to and access any element in the container, the subscript operator must be defined. The iterator must also have the ability to do relative addressing by using pointer arithmetic. Operators such as '+', '-', '+=', and '-=' must all be defined for this category of iterator. They must also define relational operations for ordering the elements. The '>', '<', '>=', and '<=' operators are defined.

These are the requirements for random access iterators:

     read, dereference and assign (on right side of assignment)

     write, dereference and assign (on left side of assignment)

     increment and decrement

     test for equality or inequality

     subscript operation

     relative addressing with pointer arithmetic (+, - , +=, -= operators)

     relational operations for ordering elements (>, <, >=, <=)

Input and Output Iterators

The least powerful of the iterators are input and output iterators. They are the least powerful because they only perform the basic iterator operations and the output iterator does not have equality and inequality operations defined. The input iterator reads objects from an input source and stores the object. Examples of input sources are containers or istreams. The dereferencing of an input iterator must allow the object to be read and assigned. The input iterator does not have to allow the object to be altered necessarily. Dereferencing appears on the right side of the assignment operation not on the left side:

Input iterators are sequential iterators. If an input iterator points to the first object in the input source, the iterator can be incremented until it points to the past-the-end value. Therefore, all of the objects from the input source must be accessible by means of the post and prefix incrementation. The prefix operation returns a reference to itself. The postfix operation returns a copy of itself before incrementation. Algorithms using input iterators should not attempt to traverse through an input source, copy the value of the iterator and then use it to traverse through an input source a second time. Input iterators should only be used for a single pass through the input source.

Input iterator must also define equality and inequality operations. If two iterators are equal, it does not guarantee that subsequent iterators are also equal. In other words:

     if a == b,does not mean ++a == ++b

But if the iterators are equal it does imply that the objects the iterators are pointing to are equal. In other words:

     if a == b,does mean *a == *b

For this iterator or any other iterator that defines an equality, there must be a difference_type that holds the distance between two elements.

These are the requirements of the input iterators:

     read, dereference and assign (on right sides of assignment)

     increment

     test for equality or inequality

Output iterators write objects. Objects can be written to a container or ostream. The dereferencing of an output iterator must allow objects to be altered and written but does not guarantee that objects can be read. In this case, dereferencing appears on the left side of an assignment operation. Assignment occurs only once. Post and prefix incrementation must be allowed. They are also sequential iterators. Like input iterators, output iterators should be used for a single pass. These are the requirements of the output iterators:

     write, dereference and assign (on left sides of assignment)

     increment

Consider this:

     void new_content(InputIterator first, InputIterator last,
                        OutputIterator out)
     {
          while (first != last){
                  *out++ = *first++;
          }
     }

first and last are both input iterators. Objects pointed to by first are sequentially assigned to the output iterator out. The out iterator can be another container or associated with a file or standard output. If out is associated with standard output then this function will produce the same results as the original function content.

Insert Iterators

Insertion iterators are adaptions of the output iterators that supply the write functionality. When insert iterators are used, the values are inserted into a location in the container and do not overwrite an already existing value. The insert adaptor puts the container into insert mode rather than overwrite mode. The front _insert_iterator insert objects at the beginning of a container and the back_insert_iterator insert objects at the back or end of a container. The insert_iterator insert objects at the location right before where the iterator is pointing. The front_insert_iterator, back_insert_iterator and insert_iterator all require a reference to the container the objects are to be inserted. The insert_iterator also requires an iterator that points to a location in the container. The inserters use the container's methods to do the insertion. The front_insert_iterator uses a container's push_front() method. The push_front() method The back_insert_iterator uses a container's push_back() method. The insert_iterator uses a container's insert() method. Any container that supplies the appropriate method can be used by these inserters.They inherit the base class iterator and contain a reference to the container.

Reverse Iterators

Reverse iterators are adaptations of bidirectional and random access iterators. Reverse iterators transforms the bidirectional and random access iterators to do a traversal in the reverse direction. They move through the container in the opposite direction. The interface is the same as the interface for the bidirectional or random access iterator except the container traversal is done in reverse. There are two types or reverse iterators:

     reverse_iterator

     const_reverse_iterator

The reverse_iterator is mutable and const_reverse_iterator is constant. The reverse iterators are already apart of every container. For example to use the reverse iterator for a list, an object P could be declared of type:

     list<double>::reverse_iterator P;

P can be initialized with an iterator that points to the end of the container MyList:

     list<double> MyList;
     P = MyList.rbegin();

Any traversing through the list, e.g., P++, would actually be moving in the reverse direction. The methods, rbegin() and rend() can return both constant and mutable reverse iterator types. The rbegin() method points to the same element as the end() method. The rend() method points to the same element as the begin() method. Since the end() method actually points to the past-the-end value of the container, an adjustment is made when the reverse iterator returned by rbegin() is dereferenced. The dereference operator will actually return current - 1 to compensate. Therefore, if the iterator is dereferenced it will not attempt to dereference the iterator pointing to the past- the-end location of the container. It will return the element right before that location.

Whether the reverse iterator is random access or bidirectional will depend on which type of iterator the container supports. If the container supports bidirectional iterators then the reverse iterator will be an adaptation of the bidirectional iterator. If the container supports random access iterators then the reverse iterator will be an adaptation of the random access iterator. The rbegin(), rend() will return either a reverse bidirectional or a reverse random access iterator. If the reverse iterator is a random access iterator then all of the iterator arithmetic and subscript operations can be done.

Algorithms can use reverse iterators. The algorithms will function as they do with regular iterators except the algorithms will work with the container in reverse. For example, a sort algorithm would sort the elements of the container in reverse order. The find algorithm would find the last occurrence of an element instead of the first occurrence. With the reverse iterators, incrementation decrements the iterator and decrementation increments the iterator.

Stream and Stream Buffer Iterators

The stream and stream buffer iterators make it possible for algorithms to work with the iostream. They are also the connection between the iostream classes and the standard containers. Stream and stream buffer iterators can be used to read data from a stream and write it to a container or read data from a container and write it to a stream. The standard has two stream iterators and two stream buffer iterators:

     ostream_iterator

     ostreambuf_iterator

     istream_iterator

     istreambuf_iterator

The ostream_iterator and ostreambuf_iterator work with the ostream family of classes. The istream_iterator and istreambuf_iterator work with the istream family. The ostream_iterator and ostreambuf_iterator are output iterator types. The istream_iterator and istreambuf_iterator are input iterator types. These iterators classes inherit the base class iterator. Any algorithm that accepts input iterators can be used with the istream family of classes and any algorithm that accepts output iterators can be used with the ostream family of classes. Stream iterators reads or writes successive elements of a type using the insertion and extraction operators, << and >>. Stream buffers do insertion and extraction at a lower level, character by character. If user-defined types or special characters are used, these operators must be defined for them.


The deque Class

Class Name            deque

Header File           <deque>

Classification      Container
Class Description

Member Classes

None

Methods

template <class InputIterator> void assign(InputIterator First, InputIterator Last)

template <class Size, class U> void assign(Size n, const U& u = U())

reference at(size_type N)

const_reference at(size_type N) const

reference back()

const_reference back() const

iterator begin()

const_iterator begin() const

void clear()

explicit deque(const Allocator& = Allocator())

explicit deque(size_type N, const T& value = T(), const Allocator& X= Allocator())

template <class InputIterator>deque(InputIterator First, InputIterator Last,const Allocator& = Allocator())

deque(const deque& X)

~deque()

iterator end()

const_iterator end() const

iterator erase(iterator Pos)

iterator erase(iterator First, iterator Last)

reference front()

const_reference front() const

allocator_type get_allocator() const

iterator insert(iterator position, const T& x = T())

void insert(iterator position, size_type n, const T& x)

template <class InputIterator> void insert(iterator Pos, InputIterator First, InputIterator Last)

size_type max_size() const

void pop_back()

void push_back(const T& X)

reverse_iterator rbegin()

const_reverse_iterator rbegin() const

reverse_iterator rend()

void resize(size_type Sz, T C = T())

const_reverse_iterator rend() const

size_type size() const

void swap(deque &X)

Operators

deque<T,Allocator>& operator=(const deque<T,Allocator>& X); reference operator[](size_type N); const_reference operator[](size_type N) const;

Example

Description

A Deque (pronounced deck ) is a queue with the restricted access relieved a little. A queue is said to have restricted access because if there are a group of objects stored in a queue they may only be dequeued one at a time from the front of the queue, and may only be enqueued one at a time into the rear of the queue. The deque relaxes this constraint somewhat. In a deque objects may be enqueued into either the rear of the queue or the front of the queue. Likewise objects may be dequeued from either the front of the queue or the rear of the queue. Unlike the priority queues the deques have no inherant sort order. In addition to being able to place remove objects from the front or rear of the queue, the standard C++ deque class allows direct access to objects through the use of the subscript [] operator.

Method            swap()

Access            Public

Classification    Modifier

Syntax            void swap(deque<T,Allocator>& X)

Parameters        X is the deque that will be swapped.

Return            X is the Deque to be swapped.

Description

The swap() method swaps the contents of the current vector with deque X.

Method            deque()

Access            Public

Classification    Constructor

Syntax            explicit deque(const Allocator& X = Allocator())

Parameters        X is a allocator object.

Return            None.

Description

The deque() method constructs an empty deque container.

Method            deque()

Access            Public

Classification    Constructor

Syntax            explicit deque(size_type N, const T& Value = T(),const Allocator& X = Allocator())

Parameters        X is a allocator object.  N is the number of objects that have been initialized
                  with value that will be inserted into the deque.

Return            None.

Description

The deque() method constructs a deque that contains N objects that have been initialized to value.

Method            deque()

Access            Public

Classification    Constructor

Syntax            template <class InputIterator>deque(InputIterator First, InputIterator Last,const Allocator &X = Allocator())

Parameters        The range [First,Last) will be used to construct the deque object. X is an allocator object.

Return            None.

Description

The deque() method constructs a deque that contains copies of the objects that are located in the range [First,Last).

Method            deque()

Access            Public

Classification    Constructor

Syntax            deque(const deque<T,Allocator>& X)

Parameters         X is a deque used to construct a new deque.

Return            None.

Description

The deque() method constructs a deque that contains a copy of deque X.

Method            deque()

Access            Public

Classification    Destructor

Syntax            ~deque()

Parameters        None.

Return            None.

Description

The ~deque() method destructs a deque object.

// This program demonstrates some of the uses
// of the random access iterators, the subscript[]
// operators, and  with the deque container

#include <deque>
#include <iostream>

using namespace std;

void main(void)
{
    deque<double> Dq(10,5);
    deque<double>::iterator P = Dq.begin();
    P = P + 5;
    *P = 25;
    P = P - 3;
    *P = 15;
    P++;
    *P = 30;
    P += 5;
    *P = 125;
    Dq[0] = 0.005;
    Dq[9] = 500.05;
    int N = Dq.size();
    P = Dq.end();
    P--;
    while(N)
    {
       cout << "Dq : " << N << " " << *P << endl;
       P--;
       N--;
    }

}


The domain_error Class

Class Name            domain_error

Header File           <stdexcept>

Classification      Exception
Class Relationship Diagram

Class Description

Member Classes

None

Methods

domain_error(const string &What_Arg)

Example

Class Description

The domain_error class is derived from the logic_error class. The domain_error class represents exceptions that are occur because some piece of the software component that causes the exception is violating some domain specification. Domain specifications are implementation specific and class specific. What constitues a domain error will depend on the context in which the error occurs and what types of attributes, characteristics, and behaviors are acceptable in that context. This class of exception represents a ' wrong subject matter or wrong content' violation as opposed to a 'wrong object type ' violation. This class represents a node class and can therefore be used as a base class for user defined classes. The current version of the C++ standard does not require any method in the standard C++ classes to throw and exception class domain_error.

Method            domain_error()

Access            Public

Classification    Constructor

Syntax            domain_error(const string &What_Arg)

Parameters        The What_Arg parameter should contain a description of the kind of exception
                  that has occurred.

Return            None

Description

The domain_error() method constructs an object of type domain_error. The What_Arg parameter can be used to set a description of the kind of error that this exception represents. A set possible solutions is sometimes supplied with the exception description in addition to the type of error.

The Class Relationship Diagram of domain_error

    1
    2   #include <stdexcept>
    3
    4
    5   void main(void)
    6   {
    7
    8
    9      try{
   10
   11            exception X;
   12            throw(X);
   13      }
   14      catch(const exception &X)
   15      {
   16          cout << X.what() << endl;
   17
   18      }
   19
   20      try
   21      {
   22          domain_error DomainError("Domain Mistake");
   23          throw(DomainError);
   24      }
   25      catch(const exception &X)
   26      {
   27          cout << X.what() << endl;
   28      }
   29
   30
   31
   32   }
   33


The Standard C++ Exception Class Library

Exception Class Architecture

                   logic_error

                   domain_error

                   invalid_argument

                   length_error

                   out_of_range

                   runtime_error

                   range_error

                   overflow_error

                   underflow_error

The Exception Classes Diagram


The exception Class

Class Name        exception

Classification    Error Handling

Header File       <exception>
Class Relationship Diagram

Class Description

Member Classes

None

Methods

exception() throw();
exception(const exception&) throw();
virtual ~exception() throw();
virtual const char* what() const throw();

Operators

exception& operator=(const exception&) throw();

Example

Description

The exception class is the base class for the logic_error and runtime_error family of classes. It is also the base class for bad_alloc, bad_case, bad_exception, bad_typeid, and ios_base::failure. The standard C++ library uses the exception family of classes to report errors that occur in the execution of some of the methods within the class library. Exception objects are not thrown by all methods in the standard class library. Furthermore Exception class objects are not used at all to report errors in the standard library functions that come from the C standard library.

Method            exception()

Access            Public

Classification    Constructor

Syntax            exception throw();

Parameters        None

Return            None

Description

This exception() method constructs an object of type exception.

Method            exception()

Access            Public

Classification    Constructor

Syntax            exception(const exception &X) throw();

Parameters        X is an exception class that will be used in a copy operation.

Return            None

Description

This exception() method is used whenever copies or temporary copies of objects of this type are needed. This method is called whenever an object of this type is:

            passed by value
            used as a return type by value
            used to initialize another object of this type

Method            exception()

Access            Public

Classification    Destructor

Syntax            virtual ~exception() throw();

Parameters        None

Return            None

Description

This method destroys an object of this type. Since this method is virtual it may be overridden in a derived class.

Method            what()

Access            Public

Classification    Destructor

Syntax            virtual const char* what() const throw()

Parameters        None

Return            The what() method returns a description or explanation for the exception
                  that was thrown.

Description

This method returns a description of the error that objects of this class report. This method can also be used to return explanations as well as possible corrective steps.

Method            operator=()

Access            Public

Classification    Operator

Syntax            exception& operator=(const exception &X) throw();

Parameters        X is an exception object that will be copied into the
                  current exception object.

Return            The assignment operator returns a reference to the current
                  object.

Description

This definition of the assignment operator assigns X to the current exception object.

    1
    2   #include <exception>
    3
    4
    5   void main(void)
    6   {
    7
    8
    9      try{
   10
   11            exception X;
   12            throw(X);
   13      }
   14      catch(const exception &X)
   15      {
   16          cout << X.what() << endl;
   17
   18      }
   19
   20      try
   21      {
   22          logic_error Logic("Logic Mistake");
   23          throw(Logic);
   24      }
   25      catch(const exception &X)
   26      {
   27          cout << X.what() << endl;
   28      }
   29
   30
   31
   32   }
   33


exception handling classes

  • logic_error
  • length_error
  • domain_error
  • out_of_range
  • invalid_argument
  • runtime_error
  • range_error
  • overflow_error
  • underflow_error
The logic_error Family of Classes
The runtime_error Family of Classes 


The basic_filebuf Class

Class Name            basic_filebuf

Header File           <fstream>

Classification      Input/Output (Format Class)
Class Relationship Diagram

Class Description

Member Classes

none

Methods

basic_filebuf()

virtual ~basic_filebuf()

basic_filebuf<charT,traits>* close()

bool is_open() const

basic_filebuf<charT,traits>* open(const char* Str, ios_base::openmode Mode)

virtual int_type overflow (int_type C = traits::eof())

virtual int_type pbackfail(int_type C = traits::eof())

virtual pos_type seekoff(off_type Off, ios_base::seekdir Dir, ios_base::openmode WMode = ios_base::in | ios_base::out)

virtual pos_type seekpos(pos_type Sp, ios_base::openmode WMode = ios_base::in | ios_base::out)

virtual basic_streambuf<charT,traits>* setbuf(char_type* Str, streamsize Num)

virtual int showmanyc()

virtual int sync()

virtual int_type underflow()

virtual int_type uflow()

Class Description

The filebuf component is a specialized basic_streambuf. Through the filebuf component the ifstream and ofstream family of classes hav access to the files, block devices and character devices. The standard typedef for basic_filebuf is filebuf.

Method            basic_filebuf()

Access            Public

Classification    Constructor

Syntax            basic_filebuf()

Parameters        None

Return            None

Description

This basic_filebuf() method constructs an object of type basic_filebuf.

Method            basic_filebuf()

Access            Public

Classification    Destructor

Syntax            virtual ~basic_filebuf()

Parameters        None

Return            None

Description

This basic_filebuf() method destructs an object of type basic_filebuf.

Method            close()

Access            Public

Classification    Modifier

Syntax            basic_filebuf<charT,traits>* close()

Parameters        None

Return            On success return the *this pointer for the current filebuf object.
                  Upon failure it returns a NULL pointer.

Description

The close() method flushes the put buffer as necessary and closes the file associated with the filebuf object.

Method            is_open()

Access            Public

Classification    Accessor

Syntax            bool is_open() const

Parameters        None

Return            This method returns either true or false.

Description

The is_open() method returns true if the file was opened successfully and no call to close() has been made.

Method            open()

Access            Public

Classification    Modifier

Syntax            * open(const char* Str, ios_base::openmode Mode)

Parameters        Str contains the name of the file to be connected to the
                  filebuf object.  Mode determines how the stream is
                  opened.

Return            Upon success the method returns the *this pointer for
                  the filebuf object.  Upon failure the method returns
                  a NULL pointer.

Description

The open() method opens the file Str with attributes set to Mode. The Valid open modes are:

                      Open Modes		Description
                     __________________________________________________
                      ios_base:: app		open in append.
                      ios_base:: ate    	create the file.
                      ios_base:: binary  	open as a binary file.
                      ios_base:: in        	open file for input.
                      ios_base:: out       	open file for output.
                      ios_base:: trunc      	truncate file on input.
                     __________________________________________________

Method            overflow()

Access            Protected

Classification    Modifier

Syntax            virtual int_type overflow (int_type C = traits::eof())

Parameters        None

Return            This method returns either traits::eof() or traits::not_eof()

Description

The overflow() method attempts to insert C into the output buffer. If successful the method will return traits::not_eof(), otherwise the method returns traits::eof().

Method            seekoff()

Access            Protected

Classification    Modifier

Syntax            virtual pos_type seekoff(off_type Off, ios_base::seekdir Dir, ios_base::openmode WMode = ios_base::in | ios_base::out)

Parameters        None

Return            Upon success this method returns a valid stream position. Upon failure
                  it returns an invalid position.

Description

The seekoff() method positions the connected stream so that its current get/put position is Off number of characters relative from the seek direction Dir. The valid seek directions are:

                                  ios_base::beg
                                  ios_base::cur
                                  ios_base::end

Method            seekpos()

Access            Protected

Classification    Modifier

Syntax            virtual pos_type seekpos(pos_type Sp, ios_base::openmode WMode = ios_base::in | ios_base::out)

Parameters        None

Return            Upon success this method returns a valid stream position (Sp). Upon failure
                  this method returns a invalid stream position.  If Sp is valid and the
                  operation fails the value will != Sp.

Description

The seekpos() method positions the get/put pointer relative to the begiining of the stream that is connected to the filebuf object.

Method            setbuf()

Access            Protected

Classification    Modifier

Syntax            virtual basic_streambuf<charT,traits>* setbuf(char_type* Str, streamsize Num)

Parameters        Str is a pointer to a buffer that can be used as the get/put area for
                  the filebuf object. Num is the size of the buffer.  If Str and Num
                  is Zero then the stream will be unbuffered.

Return            Upon success this method returns the *this pointer for the filebuf
                  object. Upon failure this method returns a NULL pointer.

Description

The setbuf() method sets up a specific buffer for the filebuf object. If no specific buffer area(array) and setbuf(0,0) is called the stream is unbuffered.

Method            setbuf()

Access            Protected

Classification    Modifier

Syntax            virtual basic_streambuf<charT,traits>* setbuf(char_type* Str, streamsize Num)

Parameters        Str is a pointer to a buffer that can be used as the get/put area for
                  the filebuf object. Num is the size of the buffer.  If Str and Num
                  is Zero then the stream will be unbuffered.

Return            Upon success this method returns the *this pointer for the filebuf
                  object. Upon failure this method returns a NULL pointer.

Description

The setbuf() method sets up a specific buffer for the filebuf object. If no specific buffer area(array) and setbuf(0,0) is called the stream is unbuffered.

The Class Relationship Diagram of filebuf


codecvt_base

The Class Relationship Diagram for codecvt_base


front_insert_iterator

Class Name            front_insert_iterator

Header File          <iterator>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

Container& container

Methods

explicit front_insert_iterator(Container& x);

Operators

front_insert_iterator<Container>& operator=
(const typename Container::value_type value);

front_insert_iterator<Container>& operator*();

front_insert_iterator<Container>& operator++();

front_insert_iterator<Container>& operator++(int);

Class Description

The front_insert_iterator inserts elements at the front of a container by using the container's push_front() method to perform the insertion.

Container& container

The container in which elements will be inserted.

Method             front_insert_iterator()

Access             Public

Classification     Constructor

Syntax             explicit front_insert_iterator(Container& x);

Paramters          x is the reference to the container in which elements
                   will be inserted.

Returns            None

Description

The constructor constructs a front_insert_iterator object and initializes Container& container with a x.

Method             operator*()

Access             Public

Classification     Accessor

Syntax             front_insert_iterator<Container>& operator*();

Parameters         None

Returns            This operator returns a pointer to the invoking object.

Description

The dereference operator returns *this.

Method             operator++()

Access             Public

Classification     Accessor

Syntax             front_insert_iterator<Container>& operator++();

Parameters         None

Returns            This operator returns a pointer to the invoking object.

Description

This incrementation operator returns *this.

Method             operator++()

Access             Public

Classification     Accessor

Syntax             front_insert_iterator<Container> operator++(int x);

Parameters         x has no bearing on this function.

Returns            This operator returns a pointer to the invoking object.

Description

This incrementation operator returns *this.

Method             operator=()

Access             Public

Classification     Modifier

Syntax             front_insert_iterator<Container>&
                   operator=(const typename Container::value_type& value);

Parameters         value is the reference to the type value_type that
                   is inserted into the container.

Returns            This operator returns a pointer to the invoking object.

Description

The assignment operator is converted to an insertion operation using container.push_front(value). The operator returns *this.

The Class Relationship Diagram for front_insert_iterator


exception classes diagram

The logic_error Family of Classes

The runtime_error Family of Classes


The basic_ifstream(ifstream) Class

Class Name            basic_ifstream

Header File           <fstream>

Classification      Input/Output (Format Class)
Class Relationship Diagram

Class Description

Member Classes

basic_filebuf

Methods

basic_ifstream()

explicit basic_ifstream(const char* s,ios_base::openmode mode = ios_base::in)

basic_filebuf<charT,traits>* rdbuf() const

bool is_open()

void open(const char* Str, openmode OMode = in)

void close()

Example

Class Description

The ifstream class is derived from the basic_istream class. The ifstream class models the input file stream. Whereas the basic_istream class focuses on a input stream normally attached to the console, the ifstream focuses on a stream normally attached to a file. The ifstream is a specialized basic_istream class. Through the filebuf component the ifstream class has access to the file. It is important to note that the ANSI/ISO standard for the iostreams does not support the concept of a file descriptor. Older implementations of the iostreams often included file descriptor access through the filebuf class and some type of fd() method. This type of access is no longer supported. The standard typedef for basic_ifstream is ifstream.

Method            basic_ifstream()

Access            Public

Classification    Constructor

Syntax            basic_ifstream()

Parameters        None

Return            None

Description

This basic_ifstream() method constructs a basic_ifstream object. It constructs a stream that is not connected to any file or device. The open() method will have to be called to connect the stream with a file or device.

Method            basic_ifstream()

Access            Public

Classification    Constructor

Syntax            explicit basic_ifstream(const char* Str,ios_base::openmode OMode = ios_base::in)

Parameters        Str points to the name of the file or device that will be opened and
                  connected to the ifstream object. OMode is the mode the stream will
                  be opened in.

Return            None

Description

This basic_ifstream() method constructs a basic_ifstream object. This constructor constructs a stream sthat will be connected to the device named by Str. The device or file will be opened in the mode specified by OMode. This constructor opens the file specified by Str. if the file cannot be opened the buffer state will contain the error condition.

Method            rdbuf()

Access            Public

Classification    Accessor

Syntax            basic_filebuf<charT,traits>* rdbuf() const

Parameters        None

Return            Returns a pointer to the associated streambuf object.

Description

The rdbuf() method returns a pointer to the associated streambuf object.

The Class Relationship Diagram of basic_ifstream

    1   // This program reads in two sorted files and performs a merge sort
    2   // to the predefined stream cout.
    3   // It demonstrates that the programmer can declare an array
    4   // of stream objects.
    5
    6   #include <fstream>
    7   #include <stdlib.h>
    8
    9   ifstream Stream[2];
   10
   11
   12   void main(void)
   13
   14   {
   15
   16          double Object[2];
   17          Stream[0].open("list1.txt");
   18          if(!Stream[0].good()){
   19   	   cerr << "could Not open file 1";
   20   	   exit(0);
   21          }
   22          Stream[1].open("list2.txt");
   23          if(!Stream[1].good()){
   24   	   cerr << "could not open file 2 ";
   25   	   exit(0);
   26          }
   27          Stream[0] >> Object[0];
   28          Stream[1] >> Object[1];
   29          while(!Stream[0].eof() && !Stream[0].fail() &&
   30   	     !Stream[1].eof() && !Stream[1].fail())
   31          {
   32
   33   	  if(Object[0] < Object[1]){
   34   	     cout << Object[0] << endl;
   35   	     Stream[0] >> Object[0];
   36   	  }
   37   	  else
   38   		if(Object[1] < Object[0]){
   39   		   cout << Object[1] << endl;
   40   		   Stream[1] >> Object[1];
   41   		 }
   42   		  else{
   43   			 cout << Object[0] << endl << Object[1] << endl;
   44   			 Stream[0] >> Object[0];
   45   			 Stream[1] >> Object[1];
   46   		  }
   47
   48          }
   49          while(!Stream[0].eof() && !Stream[0].fail())
   50          {
   51   	  Stream[0] >> Object[0];
   52   	  cout << Object[0] << endl;
   53
   54          }
   55          while(!Stream[1].eof() && !Stream[1].fail())
   56          {
   57
   58   	  Stream[1] >> Object[1];
   59   	  cout << Object[1] << endl;
   60
   61          }
   62          Stream[0].close();
   63          Stream[1].close();
   64
   65   }


istreambuf_iterator

Class Name            istreambuf_iterator

Header File          <iterator>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

streambuf_type* proxy

Methods

bool equal(istreambuf_iterator& b);

istreambuf_iterator() throw();

istreambuf_iterator(istream_type& s);

istreambuf_iterator(streambuf_type& s);

istreambuf_iterator(const proxy& p) throw();

Operators

istreambuf_iterator<T,charT,traits>& operator*();

istreambuf_iterator<T,charT,traits>& operator++();

istreambuf_iterator<T,charT,traits>& operator++(int);

Class Description

The istreambuf_iterator is a stream buffer iterator. The istreambuf_iterator class is a low level istream_iterator. Characters of charT are successively read from an input streambuf in a single direction. Only one pass is made over the data. An end-of-stream iterator object is created when an istreambuf_iterator object is constructed using the constructors istreambuf_iterator() or istreambuf_iterator(0) . The end-of-stream is reached when streambuf_type::sgetc() returns traits::eof(). At this point, the istreambuf_iterator is equal to an end-of-stream iterator value. Any two end-of-stream iterators are always equal. When the iterator object is incremented using the operator++ and evaluated (dereferenced or copied), the iterator points to the next input character of type charT. operator* accesses the current input character. Note: The result of operator * on an end-of-stream is not defined. The operator++ is not equality-preserving. If i == j, there is no guarantee that when i and j are incremented they will still be equal (++i != ++j). A new value is used every time operator++ is evaluated.

streambuf_type

The streambuf serves as the input stream type charT values are extracted.

proxy

The proxy class is for exposition only. It provides a temporary holding place for the return value of the post-increment operator(operator++). It holds the character pointed to by the previous value of the iterator in order to retrieve the character in the future.

Method             istreambuf_iterator()

Access             Public

Classification     Constructor

Syntax             istream_iterator() throw();

Parameters         None

Returns            None

Description

This constructor constructs an end-of-stream iterator object.

Method             istreambuf_iterator()

Access             Public

Classification     Constructor

Syntax             istreambuf_iterator(istream_type& s) throw();

Parameters         s is a reference to istream_type in which istream_type's
                   streambuf serves as the input stream type charT values
                   are extracted.

Returns            None

Description

This constructor constructs an istreambuf_iterator object that extracts a value of type charT from the input stream specified by s' streambuf.

Method             istreambuf_iterator()

Access             Public

Classification     Constructor

Syntax             istreambuf_iterator(streambuf_type* s) throw();

Parameters         s is a pointer to streambuf_type in which
                   streambuf_types's streambuf or *(s.rdbuf()) serves
                   as the input stream type charT values are extracted.

Returns            None

Description

This constructor constructs an istreambuf_iterator object that extracts a value of type charT from the input stream specified by s' streambuf. An end-of-stream object is constructed if s.rdbuf() is null.

Method             istreambuf_iterator()

Access             Public

Classification     Constructor

Syntax             istreambuf_iterator(const proxy& p) throw();

Parameters         p is a reference to const proxy in which proxy's
                   streambuf serves as the input stream type charT
                   values are extracted.

Returns            None

Description

This constructor constructs an istreambuf_iterator object that extracts a value of type charT from the input stream specified by p's streambuf. proxy is an implementation defined helper type. When a value is returned by operator++(int), post incrementation operator, proxy serves as a temporary placeholder by keeping the character pointed to by the previous value of the iterator so in the future that character can be accessed.

Method             operator*()

Access             Public

Classification     Accessor

Syntax             charT operator*() const;

Parameters         None

Returns            This operator returns the character extracted from
                   the streambuf by the member sbuf_->sgetc().  It is
                   not defined what will be returned if the dereference
                   operator is used on an end-of-stream value.

Description

The dereferene operator dereferences a const iterator object and returns the current input character.

Method             operator++()

Access             Public

Classification     Accessor

Syntax             istreambuf_iterator<charT,traits>&
                   istreambuf_iterator<charT,traits>::operator++();

Returns            This method returns a pointer to the current object.

Description

The prefix incrementation operator extracts a value of type charT and returns *this. This method effects sbuf_->sbumpc().

Method             operator++()

Access             Public

Classification     Accessor

Syntax             proxy istreambuf_iterator<charT,traits>operator++(int x);

Parameters         x has no effect on  the behavior of this method.

Returns            proxy serves as a temporary placeholder by keeping the
                   character pointed to by the previous value of the
                   iterator so in the future that character can be
                   accessed.

Description

The postfix incrementation operator makes a copy of the object. The streambuf pointer is advanced, and the copy is returned. This method effects proxy(sbuf_->sbumpc(), sbuf_).

Method             equal()

Access             Public

Classification     Accessor

Syntax             bool equal(istreambuf_iterator& b);

Parameters         b is a reference to the istreambuf_iterator object
                   that *this is compared for equality.

Returns            This method returns true if and only if both
                   iterators are at the end-of-stream or neither are
                   at the end-of-stream.

Description

The equal() method determines the equality of the object and an istreambuf_iterator. Regardless of what type of streambuf object is used by the iterators, the returned bool will be true if and only if both iterators are at the end-of-stream or neither are at the end-of-stream.

The Class Relationship Diagram for istreambuf_iterator


istream_iterator

Class Name            istream_iterator

Header File          <iterator>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

basic_istream* T value

Methods

istream_iterator();

istream_iterator(istream_type& s);

istream_iterator(const istream_iterator<T,charT,traits,Distance>& x);

~istream_iterator();

Operators

 const T& operator*() const;

istream_iterator<T,charT,traits,Distance>& operator++();

istream_iterator<T,charT,traits,Distance> operator++(int);

Example

Class Description

The istream_iterator is an input iterator. This object is derived from the class template, iterator. Using the operator>>, values of class T are successively read from an input stream. The elements are read from the input stream successively moving in a single direction. Only one pass is made over the data. An end-of-stream iterator object is created when an istream_iterator object is constructed using the constructor with no arguments (istream_iterator()). The end-of-stream is reached when the iterator is equal to end-of-stream iterator value. When the iterator object is incremented using the ++ operator, a value of class T is read from the input stream and stored within the object. When the iterator is dereferenced, this value is returned. Each time a new value of class T is read from the input, the current value is discarded and the new value is stored.

Note: The result of operator * or operator-< on an end-of-stream is not defined. The operator++ is not equality-preserving. If i == j, there is no guarantee that when i and j are incremented they will still be equal (++i != ++j).

basic_istream

basic_istream is the the input stream in which the elements are read from successively moving in a single direction.

T value

value is the data type the iterator points to.

Method             istream_iterator()

Access             Public

Classification     Constructor

Syntax             istream_iterator();

Parameters         None

Returns            None

Description

This constructor constructs an end-of-stream iterator object.

Method             istream_iterator()

Access             Public

Classification     Constructor

Syntax             istream_iterator(istream_type& s);

Parameters         s is the iterator initialized with the reference to an
                   input stream in which type T values are extracted.

Returns            None

Description

This constructor constructs an istream_iterator object that extracts a value of type T from the input stream specified in the s.

Method	            istream_iterator()

Access             Public

Classification     Constructor

Syntax             istream_iterator(const istream_iterator<T,charT,traits,
                                                              Distance>& x);

Parameters         X is a refererence to a const istream_iterator object
                   in which the newly constructed object will be a copy.

Returns            None

Description

This constructor constructs an istream_iterator object which is a copy of x.

Method             ~istream_iterator()

Access             Public

Classification     Constructor

Syntax             ~istream_iterator();

Parameters         None

Returns            None

Description

The destructor destroys the iterator object.

Method             operator*()

Access             Public

Classification     Accessor

Syntax             const T& operator*() const;

Parameters         None

Returns            This operator returns a reference to const T.
                   It is not defined what will be returned if the
                   dereference operator is used on an end-of-stream.

Description

The deference operator dereferences a const iterator object and returns a reference to const T. This prevents the returned element to be used to write values to the input stream.

Method             operator++()

Access             Public

Classification     Modifier

Syntax             istream_iterator<T,charT,traits,Distance>& operator++();

Parameters         None

Returns            This method returns a reference to the istream_iterator
                   object (*this).

Description

The operator++() reads from the input stream and stores a value of type T each time it is called.

Method             operator++()

Access             Public

Classification     Modifier

Syntax             istream_iterator<T,charT,traits,Distance>&
                   operator++(int x);

Parameters         x determines how many values of type T will be read
                   and stored.

Returns            This operator returns a reference to istream_iterator
                   object.

Description

This operator++() is the incrementation operator. It reads from the input stream and stores as many values of type T as specified by x.

The Class Relationship Diagram for istream_object

 1   #include
 2   #include
 3   #include
 4   #include
 5   #include
 6   #include
 7   #include
 8
 9   using namespace std;
10
11   class discard{
12       list Keys;
13       static float Num;
14   public:
15       discard(void);
16       int operator()(string X);
17       float number(void);
18   };
19
20   float discard::Num = 0;
21
22   discard::discard(void)
23   {
24
25       ifstream Keyfile("key8-1.txt");
26       istream_iterator Inkey(Keyfile);
27       istream_iterator eof;
28       copy(Inkey,eof,back_inserter(Keys));
29       Keyfile.close();
30
31   }
32
33   int discard::operator()(string X)
34   {
35
36       int Temp = 0;
37       Temp = count(Keys.begin(),Keys.end(),X);
38       discard::Num = discard::Num + Temp;
39       return Temp;
40
41   }
42
43   float discard::number(void)
44   {
45
46       return(discard::Num);
47
48   }
49
50
51   void main(void)
52   {
53
54       float Percent = 0;
55       discard Discard;
56       ifstream Infile("in8-1.txt");
57       ofstream Outfile("out8-1.txt");
58       istream_iterator In(Infile),Last;
59       ostream_iterator Out(Outfile," ");
60       deque Dec;
61       copy(In,Last,front_inserter(Dec));
62       remove_copy_if(Dec.begin(), Dec.end(),Out, Discard);
63       cout.precision(2);
64       Percent = (Discard.number() / Dec.size()) * 10;
65       cout << Percent << "%";
66       Infile.close();
67       Outfile.close();
68
69   }
70


c++ classes main index

Logical View of the Standard C++ Classes
Architectural View of the Standard C++ Classes 


insert_iterator

Class Name            insert_iterator

Header File          <iterator>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

Container& container Container::iterator iter

Methods

insert_iterator(Container& x, typename Container::iterator i);

Operators

insert_iterator<Container>& operator=
(const typename Container::value_type& value);

insert_iterator<Container>& operator*();

insert_iterator<Container>& operator++();

insert_iterator<Container>& operator++(int);

Class Desciption

The insert_iterator is an insert iterator. The insert_iterator inserts elements at the position pointed to by the iterator.

Container& container

The container in which elements will be inserted.

Container::iterator iter

The iterator points to the elements of the container in which elements will be inserted.

Method             insert_iterator()

Access             Public

Classification     Constructor

Syntax             insert_iterator(Container& x,
                                   typename Container::iterator i);

Paramters          x is the reference to the container in which elements
                   will be inserted.

                   i is the iterator which points to the elements of the
                   container.

Returns            None

Description

The constructor constructs an insert_iterator object and initializes Container& container with x, and Container::iterator iter with i.

Method             operator*()

Access             Public

Classification     Accessor

Syntax             insert_iterator<Container>& operator*();

Parameters         None

Returns            This operator returns a pointer to the current object.

Description

The dereference operator returns *this.

Method             operator++()

Access             Public

Classification     Accessor

Syntax             insert_iterator<Container>& operator++();

Parameters         None

Returns            This operator returns a pointer to the current object.

Description

This incrementation operator returns *this.

Method             operator++()

Access             Public

Classification     Accessor

Syntax             iterator<Container> operator++(int x);

Parameters         x has no effect on this function.

Returns            This operator returns a pointer to the current object.

Description

The incrementation operator returns *this.

Method             operator=()

Access             Public

Classification     Modifier

Syntax             insert_iterator<Container>&
                   operator=(const typename Container::value_type& value);

Parameters         value is a reference to the type value_type that
                   is inserted into the container.

Returns            This operator returns a pointer to the current object.

Description

The assignment operator is converted to an insertion operation using container.insert(iter,value). The element value is inserted into the container at the position pointed to by iter. iter is then incremented and *this is returned.

The Class Relationship Diagram for insert_iterator


The invalid_argument Class

Class Name            invalid_argument

Header File           <stdexcept>

Classification      Input/Output (Format Class)
Class Relationship Diagram

Class Description

Member Classes

None

Methods

invalid_argument(const string &What_Arg)

Example

Class Description

The invalid_argument class is derived from the logic_error class. The invalid_argument class represents exceptions that are occur because some piece of the software component that causes the exception is violating some argument specification. The invalid argument will either be an in error parameter, or an in error return type. The invalid_argument can be used to describe improper content. However, it is usually used to describe an improper object type. This class represents a node class and can therefore be used as a base class for user defined classes. Objects of this type are thrown by methods that are part of the standard C++ class library.

Method            invalid_argument()

Access            Public

Classification    Constructor

Syntax            invalid_argument(const string &What_Arg)

Parameters        The What_Arg parameter should contain a description of the kind of exception
                  that has occurred.

Return            None

Description

The invalid_argument() method constructs an object of type invalid_argument. The What_Arg parameter can be used to set a description of the kind of error that this exception represents. A set possible solutions is sometimes supplied with the exception description in addition to the type of error.

The Class Relationship Diagram of invalid_argument

    1
    2   #include <stdexcept>
    3
    4
    5   void main(void)
    6   {
    7
    8
    9      try{
   10
   11            exception X;
   12            throw(X);
   13      }
   14      catch(const exception &X)
   15      {
   16          cout << X.what() << endl;
   17
   18      }
   19
   20      try
   21      {
   22          invalid_argument Invalid("Bad Argument");
   23          throw(Invalid);
   24      }
   25      catch(const exception &X)
   26      {
   27          cout << X.what() << endl;
   28      }
   29
   30
   31
   32   }
   33


iostream hierarchy

The Class Relationship Diagram of Iostream Hierarchy


input/output classes

  • basic_streambuf
  • basic_filebuf
  • basic_stringbuf
  • basic_istream
  • basic_ostream
  • basic_ifstream
  • basic_ofstream
  • basic_istringstream
  • basic_ostringstream
  • ios_base
  • basic_ios
The Class Relationship Diagram of the Iostream Hierarchy 


The basic_ios Class

Class Name            basic_ios

Header File           <ios>

Classification      Input/Output (Format Class)
Class Relationship Diagram

Class Description

Member Classes

basic_streambuf

Methods

bool bad() const;

explicit basic_ios(basic_streambuf* sb);

basic_ios();

virtual ~basic_ios();

void clear(iostate state = goodbit);

basic_ios& copyfmt(const basic_ios& rhs);

bool eof() const;

iostate exceptions() const;

void exceptions(iostate except);

bool fail() const;

char_type fill() const;

char_type fill(char_type ch);

bool good() const;

locale imbue(const locale& loc);

void init(basic_streambuf* sb);

char narrow(char_type c, char dfault) const;

basic_streambuf* rdbuf() const;

basic_streambuf* rdbuf(basic_streambuf* sb);

iostate rdstate() const;

void setstate(iostate state);

basic_ostream* tie() const;

basic_ostream* tie(basic_ostream* tiestr);

char_type widen(char c) const;

OPERATORS

operator void*() const operator!">bool operator!() const

Class Description

The basic_ios class is a format class. It encapsulates stream state information. The stream state class basic_ios<T> forms an important base class for the istream, ostream and their descendants. The basic_ios class contains information about how the stream has been opened. For instance, has the stream been opened in the append mode, or can the stream be read from and written to. Some streams are read only, and some streams are write only. Some streams can be opened for both read and write operations. The basic_ios class holds the information that designates the attached stream as a binary stream or a text stream. The basic_ios class controls the information that determines the base that integers will be formatted to when being inserted into a stream or when extracted from a stream. That is, will the integers be formatted as decimal, hexadecimal, or octal or will the floating point numbers be formatted as scientific notation or in a fixed decimal format. The basic_ios class also controls precision information for numbers entering or exiting a stream. The basic_ios class has two standard typdefs:

                    typedef basic_ios<char> ios

                    typedef basic_ios<wchar_t> wios.

The basic_ios class is usually referred to as either ios or wios.

Method            bad()

Access            Public

Classification    Accessor

Syntax            bool bad() const;

Parameters        None

Return            The bad() method returns zero if the badbit is not set or a non zero
                  value otherwise.

Description

The bad() method will return a non zero value if the badbit is set. The badbit is set when some operation on the basic_streambuf object(buffer) has failed. If failbit or badbit is set within the state variable, the buffer is said to be in a fail state. If a buffer is in a bad state it is also in a fail state. However, a buffer can be in a fail state without being in a bad state. If the buffer is in a bad state all insertion and extraction operations will be ignored. The buffer is unusable unless the clear() member function is called.

Method            basic_ios()

Access            Public

Classification    Constructor

Syntax            explicit basic_ios(basic_streambuf<charT,traits>* Sb);

Parameters        Sb is a pointer to a basic_streambuf object.  The Sb
                  object will be used as the buffer for the connected stream.

Return            None

Description

This basic_ios() method constructs a basic_ios object using Sb as the buffer component for the stream. The constructor calls init(Sb) to perform the necessary initializations of its members.

Method            basic_ios()

Access            Protected

Classification    Constructor

Syntax            basic_ios();

Parameters        None

Return            None

Description

This basic_ios() method constructs a basic_ios object Its necessary members are not automatically initialized. The init() method must be manually called.

Method           ~basic_ios()

Classification    Destructor

Access            Protected

Syntax            virtual ~basic_ios();

Parameters        None

Return            None

Description

This ~basic_ios() method destructs a basic_ios object.

Method            clear()

Access            Public

Classification    Modifier

Syntax            void clear(iostate St = goodbit);

Parameters        The value in St is used to reset the  input/output state(iostate)
                  of the associated buffer.

Return            None

Description

The clear() member function serves two primary functions. The first function is to clear the error state of a buffer associated with a ios_base class. The second primary function of the clear member function is to set bits within the state variable. The clear() member function takes an iostate data type as an argument and returns and void. If the clear() member function is called with an argument of zero the state variable for the buffer is reset to zero. If the clear() member function is called with the value of one of the states that the buffer can The state is set to the value of that flag. For instance:

Object.clear(ios_base::goodbit | Object.rdstate());

then the goodbit is set in the state variable. Notice that the technique for doing this involves a bitwise oring of the state variable with the desired bit to be set.

Method            copyfmt()

Access            Public

Classification    Modifier

Syntax            basic_ios& copyfmt(const basic_ios& IosObj);

Parameters        The IosObj is an object that will be copied.

Return            This method returns a referenced to the modified
                  object.

Description

The copyfmt() method updates the current ios object with the values from IosObj. The members of IosObj are copied member by member. The values that the pointers point to in iword and pword are copied. The values of rdstate() and rdbuf() are left unchanged.

Method            eof()

Access            Public

Classification    Accessor

Syntax            bool eof() const;

Parameters        None

Return            The eof() member function  returns a non zero value if the eof bit is set and
                  zero otherwise.

Description

The eof() member function returns a true if the input for the connected stream has been exhausted. A stream's source can be connected to the console, a file, a device or a buffer in memory. Each of these sources has a condition that signals the input has been exhausted. The eof() will return true under those conditions and false otherwise. If the eofbit in rdstate() is set then eof() will return true (non zero).

Method            exceptions()

Access            Public

Classification    Accessor

Syntax            iostate exceptions() const;

Parameters        None

Return            This method returns the current exception mask.

Description

This exceptions() method returns the exception mask that is associated with the ios object. The exception mask determines additional conditions under which the clear() method will throw an exception.

Method            exceptions()

Access            Public

Classification    Modifier

Syntax            void exceptions(iostate except);

Parameters        None

Return            None

Description

This exceptions() method sets the exception mask that is associated with the ios object. The exception mask determines additional conditions under which the clear() method will throw an exception. For example:

cout.execptions(ios_base::badbit | ios_base::failbit);

sets the exception mask so that clear() will throw an exception when badbit or failbit is set.

Method            fail()

Access            Public

Classification    Accessor

Syntax            bool fail() const;

Parameters        None

Return            The fail() method returns true(non zero value) if either the badbit is set or the
                  failbit is set.

Description

If a buffer is in a bad state it is also in a fail state. However, a buffer can be in a fail state without being in a bad state. An operation may fail and the stream may still be usable. However if badbit is set then the stream is not usable. The fail() member function returns true(non zero value) if either the badbit is set or the failbit is set.

Method            fill()

Access            Public

Classification    Accessor

Syntax            char_type fill() const;

Parameters        None

Return            The fill() method returns the current fill character

Description

This fill() method returns the fill character and takes no arguments.

Method            fill()

Access            Public

Classification    Modifier

Syntax            char_type fill(char_type Ch);

Parameters        None

Return            The fill() method returns the previous fill character

Description

The fill() method will set the fill character to Ch and return the previous fill character.

Method            good()

Access            Public

Classification    Accessor

Syntax            bool good() const;

Parameters        None

Return            If no iostate flags are set then good() returns true.

Description

The good() member function returns a non zero value if the buffer component is in a good state.

Method            init()

Classification    Modifier

Access            Protected

Syntax            void init(basic_streambuf<charT,traits>* Sb);

Parameters        Sb is a pointer to a basic_streambuf object.  The Sb
                  object will be used as the buffer for the connected stream.

Return            None

Description

The init() method helps to initialize the data members of the ios_base and basic_ios components. The flags are initialized to either goodbit or badbit. After init(Sb) the width() method will return zero. The default precision will be set to 6. The fill character will be ' '. Locale is set to the standard locale. Both iword and pword are set to null.

Method            rdbuf()

Access            Public

Classification    Accessor

Syntax            basic_streambuf<charT,traits>* rdbuf() const;

Parameters        None

Return            This method returns a pointer to the current streambuf object that is contained
                  in the ios component.

Description

This rdbuf() method returns the buffer component of the ios object.

Method            rdbuf()

Syntax            basic_streambuf<charT,traits>* rdbuf(basic_streambuf<charT,traits>* Sb);

Classification    Modifier

Access            Public

Parameters        The pointer to the buffer component of the ios object will be set to
                  to the value of Sb.

Return            This method returns a pointer to the previous streambuf object that is contained
                  in the ios component.

Description

This rdbuf() method updates the streambuf pointer to the pointer stored in Sb. The method returns a pointer to the previous buffer.

Method            rdstate()

Access            Public

Classification    Accessor

Syntax            iostate rdstate() const;

Parameters        None

Return            This method returns a copy of the stream state variable.

Description

This method returns the stream state.

Method            setstate()

Classification    Modifier

Access            Public

Syntax            void setstate(iostate State);

Parameters        The value of State is the new value for the corresponding bit in the
                  stream state variable.

Return            None

Description

The setstate() method resets the iostate variable to the value stored in State.

Method            tie()

Access            Public

Classification    Accessor

Syntax            basic_ostream* tie() const;

Parameters        None

Return            a pointer to the stream that is currently tied.

Description

This tie() method returns a pointer the stream (if any) that is tied to the stream connected to this ios object.

Method            tie()

Access            Public

Classification    Modifier

Syntax            basic_ostream<charT,traits>* tie(basic_ostream<charT,traits>* Str);

Parameters        Str will point to a new stream to tie the current stream to.

Return            a pointer to the previously tied stream.

Description

This tie() method will tie Str to the stream that is currently connected to this ios object. This tie() method returns a pointer the stream (if any) that was tied to the stream connected to this ios object.

The Class Relationship Diagram of basic_ios


The ios_base Class

Class Name            ios_base

Header File           <ios>

Classification      Input/Output (Format Class)
Class Relationship Diagram

Class Description

Member Classes

init
failure

Methods

fmtflags flags() const;

fmtflags flags(fmtflags fmtfl);

locale getloc() const;

locale imbue(const locale& loc);

~ios_base();

long& iword(int index);

streamsize precision() const;

streamsize precision(streamsize prec);

void*& pword(int index);

void register_callback(event_call_back fn, int index);

fmtflags setf(fmtflags fmtfl);

fmtflags setf(fmtflags fmtfl, fmtflags mask);

static bool sync_with_stdio(bool sync = true);

void unsetf(fmtflags mask);

streamsize width(streamsize wide);

streamsize width(void);

static int xalloc();

Example

Class Description

The ios_base class is the ultimate base class of the entire iostream family of classes. Every major class in the iostream class hierarchy except for basic_streambuf family has a ios component. This class encapsulates the format state of the stream classes; istream, ofstream, istringstream, ostringstream, ifstream and ofstream. The ios_base class defines most of the state methods as well as the manipulators for the iostream classes.

failure

The failure class is derived from the exception class and is used to encapsulate the exceptions that will be thrown by iostream classes.

Init

The Init class is used during the construction of ios component to enforce the preconditions and the prefix conditions

Method            flags()

Access            Public

Classification    Accessor

Syntax            fmtflags flags() const;

Parameters        None

Return Type       fmtflags

Description

This flags() method returns the format flags for the ios component.

Method            flags(fmtflags FlagArg)

Classification    Modifier

Access            Public

Syntax            fmtflags flags(fmtflags FlagArg)

Parameters        None

Return Type       fmtflags

Description

This flags() method changes the format state of the ios component. This effects the state of the stream connected to the ios component. The format state determines what type of conversion takes place when objects are inserted into the stream or when objects are extracted from the stream. The format state describes whether objects are left justified or right justified as they are inserted into a stream. The format state describes how integers are represented as they are inserted or extracted to or from a stream. The base of the integers can be decimal, hexadecimal, or octal. The floats and doubles can be formatted as fixed floating point or in scientific notation. The format state describes the fill character that will be used for padding during stream operations. Table ios1-1 shows the format states that the flags() methods can be used to set.

Method            getloc()

Access            Public

Classification    Accessor

Syntax            locale getloc() const;

Parameters        None

Return Type       locale

Description

The getloc() method returns a copy of the locale object that is contained in ios_base
Method            imbue()

Classification    Modifier

Access            Public

Syntax            locale imbue(const locale& Lc);

Parameters        Lc

Return Type       locale

Description

The imbue() method sets the locale object of ios_base to Lc. The imbue() function returns a copy of the previous locale object. If the ios_base object has a call back function i.e. a function registered with the register_callback() function, then a call to imbue() will also cause the registered function to be called

Method            ios_base()

Classification    Destructor

Access            Public

Syntax            ~ios_base();

Parameters        None

Return Type       None

Description

The ios_base() method is the destructor for the ios_base class. If the ios_base object has a call back function i.e. a function registered with the register_callback() function, then when the destructor for ios_base is invoked, the registered function will also be called.

Method            iword()

Access            Modifier

Classification    Accessor

Syntax            long& iword(int Ndx);

Parameters        Ndx is the index into an array that is used
                  to store the user defined format flags.

Return Type       long

Description

The iword() method gives access to any user defined format flags that were allocated with the xalloc() method.

Method            precision()

Access            Public

Classification    Accessor

Syntax            streamsize precision() const;

Parameters        none

Return Type       streamsize

Description

This precision() method returns the current precision settings for the ios_base component. The precision setting determines the number of digits displayed after the decimal point during output functions or formatting functions. The default precision is 6. The precision affects both the e-notation(scientific) and fixed formats for real numbers.

Method            precision()

Classification    Modifier

Access            Public

Syntax            streamsize precision(streamsize P);

Parameters        The current precision will be assigned
                  the value stored in P.

Return Type       streamsize

Description

This precision() method changes the current precision settings for the ios_base component the value stored in P. It returns the previous precision setting. The precision setting determines the number of digits displayed after the decimal point during output functions or formatting functions. The default precision is 6. The precision affects both the e-notation(scientific) and fixed formats for real numbers. The effects of this method are not persistent. The precision will have to be set for each input/output operation unless the default value is desired.

Method            pword()

Access            Public

Classification    Modifier

Syntax            void* &pword(int Ndx);

Parameters        Ndx is position in the array that is
                  maintained for user defined format flags.

Return Type       void*

Description

The pword() method returns a reference to a memory object that can be used for user defined format flags. This method will dynamically allocate memory for the format flags when necessary and if possible. If the function fails for some reason badbit will be set and a exception may be thrown.

Method            register_callback()

Access            Public

Classification    Modifier

Syntax            void register_callback(event_call_back Fn,
                                         int Ndx);

Parameters        Fn is a pointer to a function and will be
                  called with the argument Ndx. Ndx is position
                  in the array that represents a format flag.

Return            None

Description

The register_callback() method is used to register functions and indexes that can be used when a call back event occurs. The functions are called in LIFO(last in first out) manner. The ios_base class supports three call back events.

Event Call Backs

Event                     Occurs
________________________________________________________________

imbue_event               during a call to imbue()

erase_event               during a call to ~ios_base() or
                          copyfmt()

copyfmt_event             during a call to copyfmt()
________________________________________________________________

Method            setf()

Access            Public

Classification    Modifier

Syntax            fmtflags setf(fmtflags FlagArg);

Parameters        FlagArg contains the new value for the
                  format flags

Return            The previous value of the ios_base
                  format flags.

Description

This setf() method changes the value of the ios_base format flags to the value in FlagArg. It returns the previous value for the format flags.

Method            setf()

Access            Public

Classification    Modifier

Syntax            fmtflags setf(fmtflags FlagArg,
                                   fmtflags Mask);

Parameters        FlagArg contains the new value for the
                  format flags, Mask contains the value
                  to be cleared in the format flags.

Return            The previous value of the ios_base
                  format flags.

Description

This setf() method clears the value of the Mask value in the corresponding format flags. It sets the value of the ios_base format flags to the value of (FlagArg & Mask). It returns the previous value for the format flags.

Method            sync_width_stdio()

Access            Public

Classification    Modifier

Syntax            static bool sync_with_stdio(bool Sync = true);

Parameters        Sync contains the new value for the
                  input/output synchronization flag.The
                  default value is true.

Return            The previous synchronization value

Description

The sync_with_stdio() method sets the input/output synchronization flag. If synchronization is true then the iostreams I/O will be synchronized with the standard C library input/output. If it is false there is no guarantee that the I/O calls will be synchronized. However performance is usually improved with synchronization is false.

Method            unsetf()

Access            Public

Classification    Modifier

Syntax            void unsetf(fmtflags Mask);

Parameters        Mask the value to be cleared in the format
                  flags

Return            None

Description

The unsetf() method clears the bits in the format flags that correspond to Mask.

Method            width()

Access            Public

Classification    Accessor

Syntax            streamsize width(void);

Parameters        None

Return            The current settings of the stream width.

Description

This width() method returns the current width setting for the stream.

Method            width()

Access            Public

Classification    Modifier

Syntax            streamsize width(streamsize Wd);

Parameters        Wd the size that the new field width will
                  be set to.

Return            The previous width of the stream.

Description

This width method sets the new field width to Wd. It returns the previous field width.

Method            xalloc()

Access            Public

Classification    Modifier

Syntax            static int xalloc();

Parameters        None

Return            An index into array of values that can be
                  used for user defined format flags.

Description

The xalloc() method returns a value that can be used for user defined format flags. It is used in conjunction with the iword() and pword() methods.

The Class Relationship Diagram of ios_base

    2   // This program demonstrates the use of the format flags, and
    3   // formatting capabilities of the ios_base component
    4
    5   #include <iostream>
    6   #include <sys/stat.h>
    7   #include <dirent.h>       // Requires POSIX compatibility
    8   #include <string.h>
    9   #include <dir.h>
   10   #include <time.h>
   11
   12   using namespace std;
   13
   14   int main(int Argc,char *Argv[])
   15   {
   16        if(Argc == 2){
   17   	DIR *Directory;
   18   	Directory = opendir(Argv[1]);
   19   	chdir(Argv[1]);
   20   	if(!Directory == NULL){
   21   	   float DirectorySize = 0;
   22   	   struct dirent *Entry;
   23   	   struct stat Buffer;
   24   	   Entry = readdir(Directory);
   25   	   while(Entry != NULL)
   26   	   {
   27   		 if (stat(Entry->d_name,&Buffer) == 0){
   28   		     DirectorySize = DirectorySize + Buffer.st_size;
   29   		 }
   30   		 else{
   31   		      cerr << "could not stat " << Entry->d_name << endl;
   32   		 }
   33   		 Entry = readdir(Directory);
   34   	   }
   35   	   rewinddir(Directory);
   36   	   cout << "\f";
   37   	   cout.precision(4);
   38   	   Entry = readdir(Directory);
   39   	   while(Entry != NULL)
   40   	   {
   41   	     cout.setf(ios::left | ios::fixed);
   42   	     cout.fill('*');
   43   	     cout.width(20);
   44   	     stat(Entry->d_name,&Buffer);
   45   	     cout << Entry->d_name << "\t";
   46   	     cout.width(12);
   47   	     cout.setf(ios::right);
   48   	     cout.fill(' ');
   49   	     cout.setf(ios::dec);
   50   	     cout << Buffer.st_size << "\t ";
   51   	     cout.width(12);
   52   	     cout.setf(ios::right);
   53   	     cout.fill(' ');
   54   	     cout.setf(ios::hex);
   55   	     cout << Buffer.st_size << "\t";
   56   	     cout.width(9);
   57   	     cout.setf(ios::right | ios::showpoint);
   58   	     cout.fill(' ');
   59   	     cout << (Buffer.st_size/DirectorySize*100) << '%' << "\t";
   60   	     cout.width(9);
   61   	     cout.setf(ios::right);
   62   	     cout.setf(ios::scientific);
   63   	     cout.fill(' ');
   64   	     cout << (Buffer.st_size/DirectorySize * 100) << '%' << "\t";
   65   	     cout.width(12);
   66   	     cout.setf(ios::left);
   67   	     cout << ctime(&Buffer.st_atime) << endl;
   68   	     Entry = readdir(Directory);
   69   	   }
   70   	   cout.precision(0);
   71   	   cout.setf(ios::oct | ios::fixed);
   72   	   cout << "Directory Size: " << DirectorySize << endl;
   73   	}
   74   	else{
   75   	      cerr << "could not open " << Argv[1] << endl;
   76   	}
   77   	closedir(Directory);
   78   	return(1);
   79        }
   80        return(0);
   81
   82   }


ostreambuf_iterator

Class Name            ostreambuf_iterator

Header File          <iterator>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

streambuf_type

Methods

bool failed() const throw();

ostreambuf_iterator(ostream_type& s) throw();

ostreambuf_iterator(streambuf_type* s) throw();

Operators

ostreambuf_iterator& operator=(charT c);

ostreambuf_iterator& operator*();

ostreambuf_iterator& operator++();

ostreambuf_iterator& operator++(int);

Class Description

The ostreambuf_iterator is an stream buffer iterator. The ostreambuf_iterator is a low level ostream_iterator. Characters of charT are successively written to an output streambuf in a single direction. Only one pass is made over the data. Characters cannot be extracted from the output iterator.

streambuf_type

The streambuf serves as the output stream type charT values are inserted.

Method             ostreambuf_iterator()

Access             Public

Classification     Constructor

Syntax             ostreambuf_iterator(ostream_type& s) throw();

Parameters         s is a reference to ostream_type in which
                   ostream_type's streambuf serves as the output
                   stream type charT values are inserted.

Returns            None

Description

This constructor constructs an ostreambuf_iterator object that writes a value of type charT into the output stream specified by s' streambuf. The constructor requires that s not be null. This method effects sbuf_(s.rdbuf()).

Method             ostreambuf_iterator()

Access             Public

Classification     Constructor

Syntax             ostreambuf_iterator(streambuf_type* s) throw();

Parameters         s is a pointer to streambuf_type in which
                   streambuf_types's streambuf serves as the output
                   stream type charT values are inserted.

Returns            None

Description

This constructor constructs an ostreambuf_iterator object that writes a value of type charT to the output stream specified by s' streambuf. This method effects sbuf_(s).

Method             operator*()

Access             Public

Classification     Accessor

Syntax             ostreambuf_iterator<charT,traits>& operator*();

Returns            This method returns a pointer to the current object.

Description

The dereference operator dereferences an iterator object and returns *this.

Method             operator++()

Access             Public

Classification     Accessor

Syntax             ostreambuf_iterator<charT,traits>& operator++();

Parameters         None

Returns            This operator returns a pointer to the current object.

Description

The prefix incrementation operator returns *this.

Method             operator++()

Access             Public

Classification     Accessor

Syntax             ostreambuf_iterator& operator++(int x);

Parameters         x has no effect on the behavior of this method.

Returns            This operator returns a pointer to the current object.

Description

The postfix incrementation operator returns *this.

Method             failed()

Access             Public

Classification     Accessor

Syntax             bool failed() const throw();

Parameters         None

Returns            This method returns true if there has been any prior
                   use of the operator=().

Description

The failed() method is called to determine if there has been a prior call to the assignment operator or more particularly a call to sbuf_->sputc() returned a value of traits::eof(). If sbuf_-sputc() returned traits::eof() then the return value will be true. Otherwise the return value will be false.

Method             operator=()

Access             Public

Classification     Modifier

Syntax             ostreambuf_iterator& operator=(chartT c);

Parameters         c is the character of type charT written to
                   the output stream.

Returns            This operator returns a pointer to the current
                   object.

Description

The assignment operator assigns a character c of type charT to the output stream by calling sbuf_->sputc(c). If this method fails to write the character to the stream, a call to the method failed() will return false.

The Class Relationship Diagram for ostreambuf_iterator


The basic_istringstream (istringstream) Class

Class Name            basic_istringstream

Header File           <sstream>

Classification      Input/Output (Format Class)
Class Relationship Diagram

Class Description

Member Classes

basic_stringbuf

Methods

explicit basic_istringstream(ios_base::openmode OMode = ios_base::in)

explicit basic_istringstream(const basic_string& Str,ios_base::openmode OMode = ios_base::in)

basic_stringbuf* rdbuf() const

basic_string str() const

void str(const basic_string& Str)

Example

Class Description

The basic_istringstream class implements the functionality of an object oriented input memory device. Whereas the cin type basic_istream object is normally tied to the console, and the ifstream class is connected to a file, or a device that is recognized as a file. The basic_istringstream class is connected to a block of memory, or a character array. The basic_istringstream class is a model of a character, or byte array. The istringstream class is derived from the basic_istream class. The standard typedef for basic_istringstream is istringstream.

Whereas the basic_istream class has a basic_streambuf component, and the ifstream has a filebuf component, the istringstream class has a stringbuf component. The stringbuf component is a specialized basic_streambuf. It is derived from basic_streambuf. The stringbuf component is connected to a character array, as opposed to a file. The source of a stringbuf is intended to be a memory device. The programmer can have direct access to the istringstream memory device through the stringbuf component. The stringbuf component can be reached by the rdbuf() member function.

Method            basic_istringstream()

Access            Public

Classification    Constructor

Syntax            explicit basic_istringstream(ios_base::openmode OMode = ios_base::in)

Parameters        OMode is the open mode the buffer will be constructed with.
                  Basic open modes are:

                                Open Mode       Function
                                ________________________________________
                                app             append
                                ate             open at end
                                in              open for reading
                                trunc           erase buffer start at 0
                                ________________________________________

Return            None

Method            basic_istringstream()

Access            Public

Classification    Constructor

Syntax            explicit basic_istringstream(const basic_string& Str,ios_base::openmode OMode = ios_base::in)

Parameters        OMode is the open mode the buffer will be constructed with.
                  Basic open modes are:

                                Open Mode       Function
                                ________________________________________
                                app             append
                                ate             open at end
                                in              open for reading
                                trunc           erase buffer start at 0
                                ________________________________________

                 Str is a reference  to a character buffer that will be used as the get area for the
                 istringstream object.

Return            None

Description

This basic_istringstream() method constructs a basic_istringstream object. It constructs a stream that is uses Str as its buffer or get area.

Method            rdbuf()

Access            Public

Classification    Accessor

Syntax            basic_filebuf<charT,traits>* rdbuf() const

Parameters        None

Return            Returns a pointer to the associated streambuf object.

Description

The rdbuf() method returns a pointer to the associated streambuf object.

The Class Relationship Diagram of basic_istringstream

    1   #include <iostream>
    2   #include <sstream>
    3   #include <string>
    4
    5   using namespace std;
    6
    7   void main(void)
    8   {
    9         string Source("These are the voyages....");
   10         char Dest[81] = "";
   11         istringstream InputStream(Source);
   12         if(!InputStream){
   13              cerr << "Error Setting up stream";
   14         }
   15         InputStream.get(Dest,81,'e');
   16         cout << Dest << endl;
   17         InputStream.seekg(0,ios_base::beg);
   18         InputStream.get(Dest,InputStream.rdbuf()->in_avail(),'\n');
   19         cout << Dest << endl;
   20         InputStream.seekg(0,ios_base::beg);
   21         InputStream.get(Dest,5,'\n');
   22         cout << Dest << endl;
   23   }


The basic_istream(istream) Class

Class Name            basic_istream

Header File           <istream>

Classification      Input/Output (Format Class)
Class Relationship Diagram

Class Description

Member Classes

basic_ios

Methods

explicit basic_istream(basic_streambuf* Sb)

virtual ~basic_istream()

streamsize gcount() const

int_type get()

basic_istream<charT,traits>& get(char_type& CharValue)

basic_istream<charT,traits>& get(char_type* Str, streamsize Num)

basic_istream<charT,traits>& get(char_type* Str, streamsize Num, char_type delim)

basic_istream<charT,traits>& get(basic_streambuf<char_type,traits>& Sb)

basic_istream<charT,traits>& get(basic_streambuf<char_type,traits>& Sb, char_type Delim)

basic_istream<charT,traits>& getline(char_type* Str, streamsize Num)

basic_istream<charT,traits>& getline(char_type* Str, streamsize Num, char_type Delim)

basic_istream<charT,traits>& ignore (streamsize N = 1, int_type Delim = traits::eof())

int_type peek()

basic_istream<charT,traits>& read (char_type* Str, streamsize Num)

streamsize readsome(char_type* Str, streamsize Num)

basic_istream<charT,traits>& putback(char_type CharValue)

basic_istream<charT,traits>& unget()

int sync()

pos_type tellg()

basic_istream<charT,traits>& seekg(pos_type X)

basic_istream<charT,traits>& seekg(off_type X, ios_base::seekdir Dir)

Example

Class Description

The basic_istream class models an input stream in C++. When data is taken from a stream of type basic_ostream and stored in a variable, it is called an extraction. The data is extracted from a stream in order to be input to a variable. The >> is called the extraction operator. The right shift operator is overloaded to perform input operations on built in and user defined data types. The basic_istream has member functions that accept into the stream generic sequences of data and converts them to built in types, user defined types, or user defined structures. This class represents a node class and can therefore be used as a base class for user defined classes. The basic_istream class has a typedef and is often referred to as istream.

Method            basic_istream()

Access            Public

Classification    Constructor

Syntax            explicit basic_istream(basic_streambuf* Sb)

Parameters        Sb is the buffer object that will be used for the istream
                  object.

Return            None

Description

This basic_istream() method is used to construct an object of type basic_istream.

Method            basic_istream()

Access            Public

Classification    Destructor

Syntax            ~basic_istream()

Parameters        None

Return            None

Description

This basic_istream() method is destructs an object of type basic_istream.

Method            gcount()

Access            Public

Classification    Accessor

Syntax            streamsize gcount() const

Parameters        None

Return            This method returns the number of characters read
                  by the last unformatted input operation.

Description

This gcount() method returns the number of characters successfully extracted during the last call to one of the unformatted input operations such as:

                                  get()
                                  getline()
                                  read()
                                  readsome()

Method            get()

Access            Public

Classification    Modifier

Syntax            int_type get()

Parameters        None

Return            This method returns the character extracted. If there
                  is no character to extract and no error has occurred
                  this method returns eof().

Description

This get() method extracts a single character from the input stream. An error during this operation could result in an thrown exception. E.g.

                            ios_base::failure

Method            get()

Access            Public

Classification    Modifier

Syntax            basic_istream<charT,traits>& get(char_type& CharValue)

Parameters        The value extracted from the stream will be assigned to
                  CharValue.

Return            This method returns a reference to the current istream object.

Description

This get() method extracts a single character from the input stream. Since the iostreams are template classes, the type character extracted from the input stream will be charT, based on whatever the instantiation for the basic_istream is. A reference to the basic_istream object will be returned. It will perform no translation or conversion on the character. The character will be taken from a stream of type basic_istream and stored into CharValue. If this method cannot extract a character failbit will be set. An error during this operation could result in an thrown exception. E.g.

                            ios_base::failure

Method            get()

Access            Public

Classification    Modifier

Syntax            basic_istream<charT,traits>& get(char_type* Str, streamsize Num)

Parameters        Num -1  is the number of character extracted and stored in memory beginning
                  at the location pointed to Str.

Return            This method returns a reference to the current istream object.

Description

This get() method extracts Num characters and stores them at the location pointed to by Str, It will perform no translation or conversion on the characters. An error during this operation could result in an thrown exception. E.g.

                            ios_base::failure

Method            get()

Access            Public

Classification    Modifier

Syntax            basic_istream<charT,traits>& get(char_type* Str, streamsize Num, char_type Delim)

Parameters        Num - 1  is the number of character extracted and stored in memory beginning
                  at the location pointed to Str. Delim is a delimiter that signals a stopping
                  place for the get() method.

Return            This method returns a reference to the current istream object.

Description

This get() method will extract characters from the attached buffer until either Num number of characters has been extracted, the Delim is reached, or some error condition is caused, whichever happens first. The error condition could be the get() member function trying to extract beyond the EOF. The streamsize Num is the most characters that will be extracted from the input stream. Delim is a character that will cause the extraction process to terminate. Obviously if the extraction process does not encounter the Delim then it will attempt to extract n characters. An error condition occurs if the source of the extraction does not contain n characters. This form of the get() member function will leave the delimiter Delim in the stream. It will not extract Delim and store it in destination. An error during this operation could result in an thrown exception. E.g.

                            ios_base::failure

Method            get()

Access            Public

Classification    Modifier

Syntax            basic_istream<charT,traits>& get(basic_streambuf<char_type,traits>& Sb)

Parameters        Sb is a streambuf object that will receive characters extracted from the
                  input stream.

Return            This method returns a reference to the current istream object.

Description

This get() method will extract characters from the attached buffer until either '\n' or its equivalent is reached. An error during this operation could result in an thrown exception. E.g.

                            ios_base::failure

Method            get()

Access            Public

Classification    Modifier

Syntax            basic_istream<charT,traits>& get(basic_streambuf<char_type,traits>& Sb, char_type Delim)

Parameters        Sb is a streambuf object that will receive characters extracted from the
                  input stream. Delim is a character that will cause the extraction
                  to terminate.

Return            This method returns a reference to the current istream object.

Description

This get() method will extract characters from the attached buffer until

                 eof() condition occurs
                 Delim  is reached
                 An exception occurs (In this case it is not propagated)
Delim is not stored in the Streambuf object. If no characters are extrated during this operation a exception can be thrown. E.g. If eof() is reached the eofbit is set.
                            ios_base::failure

Method            getline()

Access            Public

Classification    Modifier

Syntax            basic_istream<charT,traits>& getline(char_type* Str, streamsize Num)

Parameters        Num - 1 is the number of character extracted and stored in memory beginning
                  at the location pointed to Str.

Return            This method returns a reference to the current istream object.

Description

This getline() method extracts Num characters and stores them at the location pointed to by Str, It will perform no translation or conversion on the characters. Delim is extracted from the stream. If no characters are extrated during this operation a exception can be thrown. E.g. If eof() is reached the eofbit is set.

                            ios_base::failure

Method            getline()

Access            Public

Classification    Modifier

Syntax            basic_istream<charT,traits>& getline(char_type* Str, streamsize Num, char_type Delim)

Parameters        Num - 1 is the number of character extracted and stored in memory beginning
                  at the location pointed to Str. Delim is the character that causes
                  the get operation to terminate.

Return            This method returns a reference to the current istream object.

Description

This getline() method extracts Num characters and stores them at the location pointed to by Str, It will continue to extract characters until

                 Num - 1 characters have been extracted
                 eof() condition occurs
                 Delim  is reached
It will perform no translation or conversion on the characters. Delim is extracted from the stream and is not stored. If no characters are extracted during this operation a exception can be thrown. E.g. If eof() is reached the eofbit is set.
                            ios_base::failure

Method            ignore()

Access            Public

Classification    Modifier

Syntax            basic_istream<charT,traits>& ignore (streamsize N = 1, int_type Delim = traits::eof())

Parameters        N is the number of characters to ignore in the input stream. Delim is a
                  character that can cause the ignore() operation to terminate.

Return            This method returns a reference to the current istream object.

Description

The ignore() method extracts up to N Characters and discards them. It will continue to extract characters until

                 N characters have been extracted
                 eof() condition occurs
                 Delim  is reached
Delim is extracted from the stream and is not stored. If no characters are extracted during this operation a exception can be thrown. E.g. If eof() is reached the eofbit is set.
                            ios_base::failure

Method            peek()

Access            Public

Classification    Accessor

Syntax            int_type peek()

Parameters        None

Return            This method returns a copy of the next character in the input
                  stream.

Description

The peek() returns a copy of the next character from the input stream without extracting the character.

Method            read()

Access            Public

Classification    Modifier

Syntax            basic_istream<charT,traits>& read (char_type* Str, streamsize Num)

Parameters        Str is a Pointer to a location where Num characters will be stored.

Return            This method returns a reference to the current istream object.

Description

The read() method will accept an array or a pointer to a charT and the number of bytes to be read. The pointer points to a buffer or an array that will store the block of characters. It points to a buffer of charT. The read() member function has been overloaded and can be used to extract data from the attached stream buffer and store it into a character array.

Method            readsome()

Access            Public

Classification    Modifier

Syntax            streamsize readsome(char_type* Str, streamsize Num)

Parameters        Str is a Pointer to a location where Num characters will be stored.

Return            gcount()

Description

The readsome() method will accept an array or a pointer to a charT and the number of bytes to be read. The pointer points to a buffer or an array that will store the block of characters. This method will read the min(rdbuf()->in_avail(),Num) of bytes.

Method            putback()

Access            Public

Classification    Modifier

Syntax            basic_istream<charT,traits>& putback(char_type CharValue)

Parameters        The character value to be stored back into the stream.

Return            This method returns a reference to the current istream object.

Description

The putback() method pushes the character CharValue back onto the input stream.

Method            unget()

Access            Public

Classification    Modifier

Syntax            basic_istream<charT,traits>& unget()

Parameters        None

Return            This method returns a reference to the current istream object.

Description

The unget() method rewinds the current pointer to the input stream one character.

Method            sync()

Access            Public

Classification    Modifier

Syntax            int sync()

Parameters        None

Return            If rdbuf() returns Null this method returns -1. Otherwise it
                  returns rdbuf()->pubsync().

Description

The sync() method attempts to synchronize the internal arrays that are kept by its streambuf object with the connected stream and any external buffers.

Method            tellg()

Access            Public

Classification    Accessor

Syntax            pos_type tellg()

Parameters        None

Return            The tellg() method returns the current location of the get pointer.

Description

The tellg() method returns the current location of the get pointer(the current location in the input stream).

Method            seekg()

Access            Public

Classification    Modifier

Syntax            basic_istream<charT,traits>& seekg(pos_type X)

Parameters        None

Return            This method returns a reference to the current istream object.

Description

This seekg() moves the get pointer to position X relative to the beginning of the istream. This method action is interpreted as an absolute position from the beginning of the stream. The absolute position that X refers to is normally obtained through a call to tellg().

Method            seekg()

Access            Public

Classification    Accessor

Syntax            basic_istream<charT,traits>& seekg(off_type X, ios_base::seekdir Dir)

Parameters        X is an offset in the input stream relative to Dir.  Dir can take on
                  the following values.

                                   ios_base::beg
                                   ios_base::cur
                                   ios_base::end

Return            This method returns a reference to the current istream object.

Description

This seekg() moves the get pointer to position X relative to Dir in the input stream.

The Class Relationship Diagram of basic_istream

    6   #include <iostream>
    7   #include <sstream>
    8   #include <string>
    9
   10   using namespace std;
   11
   12   void main(void)
   13   {
   14      string Source("These are the voyages....");
   15      char Dest[81] = "";
   16      stringbuf Buffer(Source);
   17      istream InputStream(&Buffer);
   18      if(!InputStream){
   19          cerr << "Error Setting up stream";
   20      }
   21      InputStream.get(Dest,81,'e');
   22      cout << Dest << endl;
   23      InputStream.seekg(0,ios_base::beg);
   24      InputStream.get(Dest,InputStream.rdbuf()->in_avail(),'\n');
   25      cout << Dest << endl;
   26      InputStream.seekg(0,ios_base::beg);
   27      InputStream.get(Dest,5,'\n');
   28      cout << Dest << endl;
   29   }


iterator

Class Name            iterator

Header File          <iterator>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

None

Types

T value_type

Distance difference_type

Pointer pointer

Reference reference

Category iterator_category

Class Description

The iterator template class describes the types associated with an iterator. This class is the base class for all iterators. If new iterators are to be defined and the default definition types are not adequate, this class can be used for the specializatio n of a new iterator class.

These types must be defined:

                   iterator_traits::difference_type

                   iterator_traits::value_type

                   iterator_traits::iterator_category

as the iterator's distance type, value type and iterator category.

For output iterators:

                   iterator_traits::difference_type

                   iterator_traits::value_type

are defined as void.

T value_type

value _type is of type T, the class of objects that the iterator is pointing.

Distance difference_type

difference_type has a default value of ptrdiff_t which is used to represent the difference between two iterators.

Pointer pointer

pointer has a default Pointer to type T.

Reference reference

reference has a default Reference to type T.

Category iterator_category

The iterator type defined by an iterator tag of the most specific iterator behavior. These are the five iterator tags which represent the five types of iterators:

                   input_iterator_tag

                   output_iterator_tag

                   forward_iterator_tag

                   bidirectional_iterator_tag

                   random_access_iterator_tag

The Class Relationship Diagram for iterator


Iterator Hierarchy


ostream_iterator

Class Name            ostream_iterator

Header File          <iterator>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

basic_ostream*

Methods

ostream_iterator(ostream_type& s);

ostream_iterator(ostream_type& s, const charT* delimiter);

ostream_iterator(const ostream_iterator<T,charT,traits>& x);

~ostream_iterator();

Operators

ostream_iterator<T,charT,traits>& operator*();

ostream_iterator<T,charT,traits> operator=(const T& value);

ostream_iterator<T,charT,traits>& operator++();

ostream_iterator<T,charT,traits>& operator++(int);

Example

Class Description

The ostream_iterator is an output iterator. The ostream_iterator class uses the operator <'<. Values of class T are successively written into the output stream. When the object is constructed given the delimter string as a parameter, the delimter is inserted into the output stream after every value of class T is written. If no delimter is given, a null is used as the delimter.

basic_ostream

The basic_ostream is the output stream in which the elements are written to successively moving in a single direction.

Method             ostream_iterator()

Access             Public

Classification     Constructor

Syntax             ostream_iterator(ostream_type& s);

Paramters          s is the output stream in which values of type T
                   is written.

Returns            None

Description

This constructor constructs an ostream_iterator object. s is the output stream in which values of type T is written.

Method             ostream_iterator()

Access             Public

Classification     Constructor

Syntax             ostream_iterator(ostream_type& s,
                                    const charT* delimter);

Paramters          s is the output stream in which values of type T
                   is written.

                   delimter is the character string delimter is appended
                   after every value of type T is written to s.

Returns            None

Description

This constructor constructs an ostream_iterator object. s is the output stream in which values of type T is written.

Method             ostream_iterator()

Access             Public

Classification     Constructor

Syntax             ostream_iterator(const ostream_iterator<T,charT,traits>& x);

Parameters         x is a refererence to a const ostream_iterator object

Returns            None

Description

This constructor constructs an ostream_iterator object which is a copy of x.

Method             ostream_iterator()

Access             Public

Classification     Destructor

Syntax             ~ostream_iterator();

Parameters         None

Returns            None

Description

The destructor destroys the ostream iterator object.

Method             operator*()

Access             Public

Classification     Accessor

Syntax             ostream_iterator<T,charT,traits>& operator*();

Parameters         None

Returns            This operator returns a pointer to the current object.

Description

The dereference operator returns *this.

Method             operator++()

Access             Public

Classification     Accessor

Syntax             ostream_iterator<T,charT,traits>& operator++();

Parameters         None

Returns            This operator returns a pointer to the current object.

Description

The incrementation operator returns *this.

Method             operator++()

Access             Public

Classification     Accessor

Syntax             ostream_iterator& operator++(int x);

Parameters         x has no effect on this function.

Returns            This operator returns a pointer to the current object.

Description

This incrementation operator returns *this.

Method             operator=()

Access             Public

Classification     Modifier

Syntax             ostream_iterator<T,charT,traits>&
                   operator=(const T& value);

Parameters         value has no effect on this function.

Returns            This operator returns a pointer to the current object.

Description

The assignment operator returns *this.

The Class Relationship Diagram for ostream_iterator


iterator_traits

Class Name            iterator_traits

Header File          <iterator>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

None

Types

Iterator::difference_type difference_type

Iterator::value_type value_type

Iterator::pointer pointer

Iterator::reference reference

Iterator::iterator_category iterator_category

Class Description

The iterator_traits template class describes the types associated with an iterator. They are described as type definitions. There is a iterator_traits defined for every iterator type. If there is to be a new iterator type to be defined and the d efault type definitions are not adequate, a new iterator_traits<Iterator> is implicitly generated.

Iterator::difference_type difference_type

difference_type is of type Distance used to represent the difference between two iterators.

Iterator::value_type value_type

value_type is of type T, a class of objects that the iterator is pointing,

Iterator::pointer pointer

pointer has a default Pointer to type T.

Iterator::reference reference

reference has a default Reference to type T.

Iterator::iterator_category iterator_category

The iterator type defined by an iterator tag of the most specific iterator behavior. These are the five iterator tags which represent the five types of iterators:

                   input_iterator_tag

                   output_iterator_tag

                   forward_iterator_tag

                   bidirectional_iterator_tag

                   random_access_iterator_tag

The Class Relationship Diagram for iterator_traits


language and runtime support classes

  • locale
    • locale
  • numeric
    • num_get
    • num_put
    • numpunct
    • numpunct_byname
  • monetary
    • money_get
    • money_put
    • moneypunct
    • moneypunct_byname
  • time
    • time_get
    • time_get_byname
    • time_put
    • time_put_byname
  • ctype
    • ctype_base
    • ctype
    • ctype_byname
  • codecvt
    • codecvt
    • codecvt_base
    • codecvt_byname
  • collate
    • collate
    • collate_byname
  • messages
    • messages
    • messages_base
    • messages_byname
  • char_traits
  • type_info
  • bad_cast
  • bad_typeid
The General Layout of the Facet Classes 


general layout of facet classes

The General Layout of the Facet Classes


The length_error Class

Class Name            length_error

Header File           <stdexcept>

Classification      Exception
Class Relationship Diagram

Class Description

Member Classes

None

Methods

length_error(const string &What_Arg)

Description

Description The length_error class is derived from the logic_error class. The length_error class represents exceptions that are occur because some piece of the software component that causes the exception is attempting to produce an object whose length is larger than the maximum allowable size. What a length_error exception means is class dependent and is determined by context. This class represents a node class and can therefore be used as a base class for user defined classes. Objects of type length_error are thrown by methods in the standard C++ class library.

Method            length_error()

Access            Public

Classification    Constructor

Syntax            length_error(const string &What_Arg)

Parameters        The What_Arg parameter should contain a description of the kind of exception
                  that has occurred.

Return            None

Description

The length_error() method constructs an object of type length_error. The What_Arg parameter can be used to set a description of the kind of error that this exception represents. A set possible solutions is sometimes supplied with the exception description in addition to the type of error.

length_error Class Relationship Diagram

    1
    2   #include <stdexcept>
    3
    4
    5   void main(void)
    6   {
    7
    8
    9      try{
   10
   11            exception X;
   12            throw(X);
   13      }
   14      catch(const exception &X)
   15      {
   16          cout << X.what() << endl;
   17
   18      }
   19
   20      try
   21      {
   22          length_error LengthError("Some Size Error");
   23          throw(LengthError);
   24      }
   25      catch(const exception &X)
   26      {
   27          cout << X.what() << endl;
   28      }
   29
   30
   31
   32   }
   33


The list Class

Class Name            list

Header File           <list>

Classification      Container
Class Description

Member Classes

None

Methods

template <class InputIterator> void assign(InputIterator first, InputIterator last)

template <class Size, class T> void assign(Size n, const T& t = T())

reference back()

const_reference back() const

iterator begin()

const_iterator begin() const

void clear()

bool empty() const

iterator end()

const_iterator end() const

iterator erase(iterator position)

iterator erase(iterator position, iterator last)

reference front()

const_reference front() const

allocator_type get_allocator() const

iterator insert(iterator position, const T& x = T())

void insert(iterator position, size_type n, const T& x)

template <class InputIterator> void insert(iterator position, InputIterator first, InputIterator last)

explicit list(const Allocator& = Allocator())

explicit list(size_type Num, const T& Value = T(), const Allocator& = Allocator())

template <class InputIterator> list(InputIterator First, InputIterator Last, const Allocator& = Allocator())

list(const list<T,Allocator>& X)

size_type max_size() const

template <class Compare> void merge(list& X, Compare comp)

void merge(list<T,Allocator>& x)

void pop_back()

void pop_front()

void push_back(const T& X)

void push_front(const T& X)

reverse_iterator rbegin()

const_reverse_iterator rbegin() const

void remove(const T& value)

template <class Predicate> void remove_if(Predicate pred)

reverse_iterator rend()

const_reverse_iterator rend() const

void resize(size_type sz, T C = T)

void reverse()

size_type size() const

void sort()

template <class Compare> void sort(Compare comp)

void swap(list<T,Allocator>&)

void splice(iterator Pos, list<T,Allocator>& X)

void splice(iterator Pos, list<T,Allocator>& X, iterator I)

void splice(iterator Pos, list<T,Allocator>& X, iterator First, iterator Last)

void unique()

template <class BinaryPredicate> void unique(BinaryPredicate binary_pred);

Operators

list& operator=(const list& x);

Example

Description

The list container is object oriented implementation of the classic list data structure. The list container class abstracts a sequence of objects that can only be accessed from either the front of the list or the rear of the list.

Method            assign()

Access            Public

Classification    Modifier

Syntax            template <class InputIterator> void assign(InputIterator first, InputIterator last)

Parameters       [first,last] is the range of objects that will be assigned to the list.

Return            None

Description

This assign() method is assigns the objects in the range [first,last] to the objects in the list in the range [first,last].

Method            assign()

Access            Public

Classification    Modifier

Syntax            template <class Size, class T> void assign(Size n, const T& t = T())

Parameters        n is the number of t objects to be assigned to the list.

Return            None

Description

This assign() method is assigns n objects with value t to the list.

Method            back()

Access            Public

Classification    Modifier

Syntax            reference back()

Parameters        none

Return            returns  the last element in the list.

Description

This back() method returns the last element in the list.

Method            clear()

Access            Public

Classification    Modifier

Syntax            void clear()

Parameters        none

Return            none

Description

The clear() method erases every object from the container.

Method            front()

Access            Public

Classification    Accessor

Syntax            reference front()

Parameters        none

Return            This method returns the object at the head of the list.

Description

The front() method returns object at the beginning(head) of the list.

Method            get_allocator

Access            Public

Classification    Accessor

Syntax            allocator_type get_allocator() const

Parameters        none

Return            This method returns a copy of the allocator object.

Description

The get_allocator() method returns a copy of this object's allocator object.

Method            list

Access            Public

Classification    Constructor

Syntax            list(const Allocator& = Allocator())

Parameters        Allocator object.

Return            None

Description

This list() method constructs and object of type list and supplies the allocator.

Method            list

Access            Public

Classification    Constructor

Syntax            explicit list(size_type Num, const T& Value = T(), const Allocator& = Allocator())

Parameters        Num is the of objects that are initialized with Value that will be used
                  to construct the list. Allocator is an allocator object.

Return            None

Description

This list() method constructs and object of type list and supplies the allocator. The list is constructed to contain Num objects that have been initialized with Value.

Method            list

Access            Public

Classification    Constructor

Syntax            template <class InputIterator> list(InputIterator First, InputIterator Last, const Allocator& = Allocator())

Parameters        [First,Last) is the range of objects that will be used to construct
                  the list.

Return            None

Description

This list() method constructs and object of type list and supplies the allocator. The list is constructed to contain copies of the objects in the range [First,Last).

Method            list

Access            Public

Classification    Constructor

Syntax            list(const list<T,Allocator>& X)

Parameters        X is a list object that will be used to construct this
                  container.

Return            None

Description

This list() method constructs a new list object using the list object X.

Method            merge

Access            Public

Classification    Modifier

Syntax            template <class Compare> void merge(list& X, Compare comp)

Parameters        X is a list to merger with this container. comp is the comparison object
                  that will be used in the merge.

Return            None

Description

This merge() method merges the list object X with the current list object.

Method            merge

Access            Public

Classification    Modifier

Syntax            void merge(list<T,Allocator>& x)

Parameters        X is a list to merger with this container.

Return            None

Description

This merge() method merges the list object X with the current list object.

Method            pop_back

Access            Public

Classification    Modifier

Syntax            void pop_back()

Parameters        None

Return            None

Description

This pop_back() method removes/erases the last element from the list.

Method            pop_front

Access            Public

Classification    Modifier

Syntax            void pop_front()

Parameters        None

Return            None

Description

This pop_front() method removes/erases the element from front/beginning of the list.

Method            push_back

Access            Public

Classification    Modifier

Syntax            void push_back(const T& x)

Parameters        X is the object  to add to the list.

Return            None

Description

The push_back() method inserts the object X at the rear of the list.

Method            push_front

Access            Public

Classification    Modifier

Syntax            void push_front(const T& X)

Parameters        X is the object  to add to the front of the list.

Return            None

Description

The push_front() method inserts the object X at the front/head of the list.

Method            remove

Access            Public

Classification    Modifier

Syntax            void remove(const T& Value)

Parameters        Objects that are equivalent to Value are removed from
                  the list.

Return            None

Description

The remove() method removes all objects from the list that are equal to Value.

Method            remove_if

Access            Public

Classification    Modifier

Syntax            template <class Predicate> void remove_if(Predicate pred)

Parameters        pred is a predicate that will evaluate to either true or false for
                  each object in the container.

Return            None

Description

The remove_if() method removes all objects from the list where pred evaluates to true for that object.

Method            resize

Access            Public

Classification    Modifier

Syntax            void resize(size_type sz, T C = T)

Parameters        sz is the new size the list will be set to. T is the object
                  to initalize any new elements to (if any).

Return            None

Description

The resize() method makes size() == sz. If size() and sz are equal resize() does nothing. If sz < size() then the appropriate number of objects are removed from the end of the list. If sz > size() then the list is expanded and the new elements are assigned the value of T.

Method            reverse

Access            Public

Classification    Modifier

Syntax            void reverse()

Parameters        None

Return            None

Description

The reverse() method reverses the order of the elements in the list.

Method            sort

Access            Public

Classification    Modifier

Syntax            void sort()

Parameters        None

Return            None

Description

This sort() method sorts the objects in the list according the operator < defined for the object.

Method            sort

Access            Public

Classification    Modifier

Syntax            template <class Compare> void sort(Compare comp)

Parameters        comp is the comparison object that will be used to sort
                  the elements in the list. The ordering will be based on
                  the definition of the () operator for the comp object.

Return            None

Description

This sort() method sorts the objects in the list according the comp function object.

Method            swap

Access            Public

Classification    Modifier

Syntax            void swap(list<T,Allocator>&X)

Parameters        X is the list to be swapped.

Return            None

Description

The swap() method swaps the contents of the current list with the contents of list X.

Method            splice

Access            Public

Classification    Modifier

Syntax            void splice(iterator Pos, list<T,Allocator>& X)

Parameters        X is the list to be inserted into the current list.

Return            None

Description

This splice() method inserts all the elements from list X before position Pos in the current list. Those elements are then deleted from list X.

Method            splice

Access            Public

Classification    Modifier

Syntax            void splice(iterator Pos, list<T,Allocator>& X, iterator I)

Parameters        The element pointed to by I in list X will be inserted into the
                  current list.

Return            None

Description

This splice() method inserts the element pointed to by I from list X before position Pos in the current list. That element is then deleted from list X.

Method            splice

Access            Public

Classification    Modifier

Syntax            void splice(iterator Pos, list<T,Allocator>& X, iterator First, iterator Last)

Parameters        The elements in the range [First,Last)in list X will be inserted into the
                  current list before position Pos.

Return            None

Description

This splice() method inserts the elements in the range [First,Last)from list X before position Pos in the current list. Those elements are then deleted from list X.

Method            unique

Access            Public

Classification    Modifier

Syntax            void unique()

Parameters        None

Return            None

Description

This unique() method erases all duplicate elements from the list and leaves only the first object of each value in the list.

Method unique Access Public Classification Modifier Syntax template <class BinaryPredicate> void unique(BinaryPredicate binary_pred) Parameters binary_pred is predicate that evaluates true or false for every pair of objects in the list. Return None

Description

This unique() method erases all duplicate elements from the list where binary_pred evaluates to true. and leaves only the first object of each value in the list.

    6   #include <list>
    7   #include <iostream>
    8
    9   using namespace std;
   10
   11   void main(void)
   12   {
   13       list<double> MyList;
   14       int N = 0;
   15       while(N < 6)
   16       {
   17          MyList.push_back(N + 3.14);
   18          N++;
   19       }
   20       list<double>::iterator M = MyList.begin();
   21       while(N)
   22       {
   23          cout << "MyList : " << *M << endl;
   24          M++;
   25          N--;
   26       }
   27       N = MyList.size();
   28       M = MyList.end();
   29       M--;
   30       cout << " Reverse Direction-----------" << endl;
   31       while(N)
   32       {
   33          cout << "MyList : " << *M << endl;
   34          M--;
   35          N--;
   36       }
   37   }


locale

Class Name            locale

Header File           <locale>

Classification        abstract data type
Class Relationship Diagram

Class Description

Member Classes

locale::id
facet

Methods

static const locale& classic();

static locale global(const locale&);

locale() throw();

locale(const locale& other) throw();

explicit locale(const char* std_name);

locale(const locale& other, const char* std_name, category cats);

template <class Facet> locale(const locale& other, Facet* f);

template <class Facet> locale(const locale& other, const locale& one);

locale(const locale& other, const locale& one, category cats);

~locale() throw();

basic_string<char> name() const;

Operators

bool operator!=(const locale& other) const;

const locale& operator=(const locale& other) throw();

bool operator==(const locale& other) const;

template <class charT, class Traits, class Allocator>
bool operator()(const basic_string<charT,Traits,Allocator>& s1,
const basic_string<charT,Traits,Allocator>& s2) const;

Class Description

The locale class is used to provide a localization interface and a set of indexed facets in which each facet covers a particular localization issue. In order to access the facets of locale, the use_facet<Facet>(loc) and has_facet< > is called. These are not locale methods but global template functions. Successive calls to a locale facet method during extraction, insertion, or streambuf method, returns identical results. Named locales can be compared for equality. Unnamed locales are equal only to copies of itself.

locale::id

locale::id is a class used to provide an identification of a locale facet interfaces used as an index for lookup and to encapsulate initialization.

facet

facet is the base class for any derived facet classes. All classes must derive from this class directly or indirectly.

category

category is an int value that includes bitmask elements: none, collate, ctype, monetary, numeric, time and messages. it can also have the value all defined as the expression: (collate | ctype | monetary | numeric | time | messages | all) == all is true. The | and & operators can be applied to any two valid values.

Method             classic()

Access             Public

Classification     Accessor

Syntax             static locale global(const locale& loc) const;

Parameters         loc is the locale used to set the global locale.

Return             This method returns a locale that is the previous
                   value of locale().

Description

The global() method sets the global locale to the argument loc. This will cause any future calls to the constructor locale() to return a copy of the argument. The locale returned is the previous value of locale().

Method             locale()

Access             Public

Classification     Constructor

Syntax             locale() throw();

Parameters         None

Returns            None

Description

The constructor constructs a locale object. This is the default constructor. It constructs a copy of the last argument passed to the locale::global(locale&). If it has not been called, it will construct a locale object identical to locale::classic().

Method             locale()

Access             Public

Classification     Constructor

Syntax             locale(const locale& other) throw();

Parameters         other is the locale in which the newly constructed
                   locale is a copy.

Returns  None

Description

The constructor constructs a locale object that is a copy of the argument other.

Method             locale()

Access             Public

Classification     Constructor

Syntax             explicit locale(const char* std_name);

Parameters         std_name is the name that will be associated with
                   the newly constructed locale object.

Returns            None

Description

The constructor constructs a named locale object with the argument std_name.

Method             locale()

Access             Public

Classification     Constructor

Syntax             locale(const locale& other, const char* std_name,
                          category cats);

Parameters         other is the locale in which the newly constructed
                   locale is a copy.

                   std_name is the locale object that supplies the
                   facets identified by the argument cats.

                   cats is the category object that supplies
                   the name of a facet or facets. The newly constructed
                   locale object will not have a copy of the facet or
                   facets identified by this argument.

Return             None

Description

The constructor constructs a locale object that is a copy of the argument locale other. All facets are copied except for the facets identified by the argument cats. This facet is supplied by the named locale identified by the argument std_name. The newly constructed locale object will have a name if other is a named locale. The constructor will throw a runtime_error exception if the argument std_name is not valid or null.

Method             locale()

Access             Public

Classification     Constructor

Syntax             template <class Facet> locale(const locale& other,
                                                 Facet* f);

Parameters         other is the locale in which the newly constructed
                   locale is a copy.

                   f is the facet type not supplied by the locale
                   facet object other.

Returns            None

Description

This constructor is a template function. The constructor constructs a locale object that is a copy of the argument locale other. All facets are copied except for the facet type identified by the argument f, the facet f supplies that facet. The newly constructed locale has no name.

Method             locale()

Access             Public

Classification     Constructor

Syntax             template <class Facet> locale(const locale& other,
                                                 const locale& one);

Parameters         other is the locale in which the newly constructed
                   locale is a copy.

                   one is the locale object that supplies the missing
                   facet.

Return             None

Description

This constructor is a template function. The constructor constructs a locale object that is a copy of the argument locale other. All facets are copied except for the facet type identified by the template argument Facet. That facet is supplied from the locale one. The constructor will throw a runtime_error exception if the has_facet<Facet>(one) is false.

Method             locale()

Access             Public

Classification     Constructor

Syntax             locale(const locale& other, const locale& one,
                          category cats);

Parameters         other is the locale in which the newly constructed
                   locale is a copy.

                   one is the locale object that supplies the facets
                   identified by the argument cats.

                   cats is the category object that supplies the
                   name of a facet or facets. The newly constructed locale
                   object will not have a copy of the facet or facets
                   identified by this argument.

Returns            None

Description

The constructor constructs a locale object that is a copy of the argument locale other. All facets are copied except for the facets identified by the argument cats. This facet is supplied by the locale identified by the argument one. The newly constructed locale object will have a name if other and one are named locales.

Method             locale()

Access             Public

Classification     Destructor

Syntax             ~locale() throw();

Parameters         None

Returns            None

Description

The destructor destroys a locale object.

Method             operator=()

Access             Public

Classification     Assignment Operator

Syntax             const locale& operator=(const locale& other) throw();

Parameters         other is the locale in which the newly constructed
                   locale is a copy.

Return             This method returns *this.

Description

The operator=() method constructs a copy of the locale argument other. This will replace the current value.

Method             name()

Access             Public

Classification     Accessor

Syntax             basic_string<char> name() const;

Parameters         None

Return             This method returns a basic_string object which
                   contains the name of the locale if it has one.

Description

The name() method returns the name of the locale object. If the locale does not have a name the method will return "*".

Method             operator==()

Access             Public

Classification     Relational Operator

Syntax             bool operator==(const locale& other) const;

Parameters         other is the locale used for comparison with the
                   calling object.

Return             This method returns true if both locales are equal.

Description

The operator==() method returns true if the calling object and the locale other are the same locales, one is a copy of the other, or each has a name or names that are identical.

Method             operator!=()

Access             Public

Classification     Relational Operator

Syntax             bool operator!=(const locale& other) const;

Parameters         other is the locale used for comparison with the
                   calling object.

Return             This method returns true if the locales are not
                   equal.

Description

The operator==() method returns the results of the expression !(*this == other).

Method             operator()()

Access             Public

Classification     Function Operator

Syntax             template<class charT, class Traits, class Allocator>
                   bool operator()(const basic_string<charT,
                                                      Traits,
                                                      Allocator>& s1,
                                   const basic_string<charT,
                                                      Traits,
                                                      Allocator>& s2) const;

Parameters         s1 is used in the comparison.

                   s2 is used in the comparison.

Returns            The method returns the results of the expression:

                   use_facet<collate<charT> >(*this).
                   compare(s1.data(), s1.data() + s1.size(),
                                      s2.data(),
                                      s2.data() + s2.size()) < 0;

Description

The operator()() method compares two strings according to the collate<charT> facet.

Method             global()

Access             Public

Classification     Modifier

Syntax             static locale global(const locale& loc) const;

Parameters         loc is the locale used to set the global locale.

Returns            This method returns the previous value of locale().

Description

The global() method sets the global locale to the argument loc. This will cause any future calls to the constructor locale() to return a copy of the argument.

The Class Relationship Diagram for locale


The logic_error Class

Class Name            logic_error

Header File          <stdexcept>

Classification      Error Handling (Node Class)
Family of logic_error Classes

Class Description

Member Classes

None

Methods

logic_error(const string &What_Arg)

Example

Class Description

The logic_error class is derived from the exception class. The logic_error class represents exceptions that are the result of violating a functional specification for the software component that is throwing the exception. The logic_error class of exceptions is distinguished from the runtime_error class of exceptions by the fact that runtime_error class exceptions represent run time or execution time hardware or software anomalies. Where as the logic_error class of exceptions represent defects in the implementation of the algorithms, procedures, or functions that make up the software component that throws the exception. Further, the defects of the logic_error class variety can potentially be identified before the software component is executed. This class represents a node class and can therefore be used as a base class for user defined classes. The current version of the C++ standard does not require any method in the standard C++ classes to throw and exception of the base class logic_error.

Method            logic_error()

Access            Public

Classification    Constructor

Syntax            logic_error(const string &What_Arg)

Parameters        The What_Arg parameter should contain a description of the kind of exception
                  that has occurred.

Return            None

Description

The logic_error() method constructs an object of type logic_error. The What_Arg parameter can be used to set a description of the kind of error that this exception represents. A set possible solutions is sometimes supplied with the exception description in addition to the type of error.

Family of logic_error Classes

    1
    2   #include <stdexcept>
    3
    4
    5   void main(void)
    6   {
    7
    8
    9      try{
   10
   11            exception X;
   12            throw(X);
   13      }
   14      catch(const exception &X)
   15      {
   16          cout << X.what() << endl;
   17
   18      }
   19
   20      try
   21      {
   22          logic_error Logic("Logic Mistake");
   23          throw(Logic);
   24      }
   25      catch(const exception &X)
   26      {
   27          cout << X.what() << endl;
   28      }
   29
   30
   31
   32   }
   33


The map Class

Class Name            map

Header File           <map>

Classification      container
Class Description

Member Classes

None

Methods

iterator begin()

const_iterator begin() const

void clear()

size_type count(const key_type& x) const

bool empty() const

iterator end()

const_iterator end() const

void erase(iterator position)

size_type erase(const key_type& x)

void erase(iterator first, iterator last)

pair<iterator,iterator> equal_range(const key_type& x) const

iterator find(const key_type& x) const

const_iterator find(const key_type& x) const

allocator_type get_allocator() const

pair<iterator,bool> insert(const value_type& x)

iterator insert(iterator position, const value_type& x)

template <class InputIterator>void insert(InputIterator first, InputIterator last)

iterator lower_bound(const key_type& x) const

const_iterator lower_bound(const key_type& x) const

explicit map(const Compare& comp = Compare(), const Allocator& = Allocator())

template <class InputIterator> map(InputIterator first, InputIterator last, const Compare& comp = Compare(), const Allocator& = Allocator())

map(const map<Key,T,Compare,Allocator>& x)

~map()

size_type max_size() const

reverse_iterator rbegin()

const_reverse_iterator rbegin() const

reverse_iterator rend()

void resize(size_type Sz, T C = T())

const_reverse_iterator rend() const

size_type size() const

void swap(map&)

iterator upper_bound(const key_type& x) const

const_iterator upper_bound(const key_type& x) const

Operators

reference operator[](const key_type& x); map<Key,T,Compare,Allocator>& operator=(const map<Key,T,Compare,Allocator>& x);

Example

Class Description

A Map container is a special type of 'set'. The map collection, also called a dictionary or associative array, is used to create a collection of related pairs. The map collection associates the elements of one set to the elements of another set. The map collection is an indexed structure similar to a vector. Where a vector uses integers as the index values, a map collection can use any type as the index value. The map collection consists of related ordered pairs. The first element of the pair serves as the key and the other element the value. The value can be accessed by using the key as the index value within a subscript operator. The key and the value can be of the same type or any mix of types. Map containers are associative structures where the key is one dimension and the value is another. It can be considered multidimensional. Maps and multimaps are mathematical notions that implement the concept of relations. A map associates the elements in one set with the elements in another set

Method            swap()

Access            Public

Classification    Modifier

Syntax            void swap(map<Key,T,Compare,Allocator>& X)

Parameters        X is the map to be swapped with the contents of the current map.

Return            X is the map to be swapped.

Description

The swap() method swaps the contents of the current map with map X.

Method            map()

Access            Public

Classification    Constructor

Syntax            explicit map(const Compare& Comp = Compare(), const Allocator &X = Allocator())

Parameters        Comp is the function object that will be used to order the map.
                   X is a allocator object.

Return            None.

Description

The map() method constructs an empty set container.

Method            map()

Access            Public

Classification    Constructor

Syntax            template  map(InputIterator first, InputIterator last,const Compare& Comp = Compare(), const Allocator&X = Allocator())

Parameters        elements from the range [first,last) will be used to construct the map. X is a allocator object.
                  Comp is the function object that will be used to order the map.

Return            None.

Description

The map() method constructs a map that contains copies of the objects that are pointed to by the iterators in the range [first,last].

Method            map()

Access            Public

Classification    Constructor

Syntax            map(const map<Key,Compare,Allocator>& X)

Parameters        X is the map that will be used to construct the new map.

Return            None.

Description

The map() method constructs a new set from map X.

Method            map()

Access            Public

Classification    Destructor

Syntax            ~map()

Parameters        None.

Return            None.

Description

The ~map() method destructs a map object.

Example

// demonstrates how map elements can be accessed
// using associations.  The last loop demonstrates
// how a set iterator can be used as a association
// element for a map.

#include <string>
#include <map>
#include <set>
#include <iostream>

void main(void)
{

     map<string,string,less<string> > MapA;
     pair<string,string> Group[4];
     Group[0].first = "orange";
     Group[0].second = "clock work";
     Group[1].first = "red";
     Group[1].second = "Herring";
     Group[2].first = "white";
     Group[2].second = "Knight";
     Group[3].first = "silver";
     Group[3].second = "bullet";
     MapA["blue"] = "bird";
     MapA["brown"] = "bear";
     MapA["green"] = "goblin";
     map<string,string,less<string> > MapB(MapA);
     cout << MapB["green"] << endl;
     cout << MapB["blue"]  << endl;
     cout << MapB["brown"] << endl;
     map<string,string,less<string > > MapC(Group,Group+4);
     set<string,less<string> > SetA;
     SetA.insert("white");
     SetA.insert("silver");
     SetA.insert("orange");
     SetA.insert("red");
     set<string,less<string> >::iterator P = SetA.begin();
     while(P != SetA.end())
     {
    cout << *P << " " << MapC[*P] << endl;
    P++;
     }
}


memory managemnet classes

  • allocator class
  • auto_ptr class


messages

Class Name            messages

Header File          <locale>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

locale::id

Methods

void close(catalog c) const;

virtual void do_close(catalog) const;

virtual string_type do_get(catalog, int set, int msgid,
const string_type& dfault) const;

virtual catalog do_open(const basic_string&, const locale&) const;

string_type get(catalog c, int set, int msgid,
const string_type& dfault) const;

explicit messages(size_t refs = 0);

~messages();

catalog open(const basic_string& fn, const locale&) const;

Class Description

The messages class describes a class used to provides a facility for the retrieval of strings from the message catalogs.

locale::id

locale::id is a class used to provide an identification of a locale facet interfaces used as an index for lookup and to encapsulate initialization.

Method             close()

Access             Public

Classification     Modifier

Syntax             void close(catalog c) const;

Parameters         c is the message catalog obtained from open().

Returns            None

Description

The close() method calls do_close(cat).

Method             do_close()

Access             Protected

Classification     Modifier

Syntax             virtual void do_close(catalog cat) const;

Parameters         cat is the message catalog obtained from open().

Returns            None

Description

The do_close() method closes the catalog opened by an earlier call to do_open().

Method             do_get()

Access             Protected

Classification     Accessor

Syntax             virtual string_type do_get(catalog cat, int set,
                                              int msgid,
                                              const string_type& dfault) const;

Parameters         cat is the message catalog obtained from open().

                   set is used to identify the message.

                   msgid is used to identify the message.

                   dfault is returned if the message cannot be found.

Returns            This method returns a string_type that is a copy
                   of the message or a copy of the dfault message if
                   a failure occurs.

Description

The do_get() method returns the message sequence from the message catalog cat. It makes use of set, msgid, and dfault in doing so. It returns a copy of the specified message sequence. If failure occurs, it returns a copy of dfault on failure.

Method             do_open()

Access             Protected

Classification     Modifier

Syntax             virtual catalog do_open(const string& name,
                                           const locale& loc) const;

Parameters         name is the name of the message catalog.

                   loc is used for the codeset conversion when
                   retrieving messages if needed.

Returns            This method returns a catalog value that is passed
                   to get() in order to retrieve a message.

Description

The do_open() opens a message catalog specified by name argument. The method returns a value less than 0 if no such catalog can be opened. The loc argument is used for codeset conversion when retrieving messages.

Method             get()

Access             Public

Classification     Accessor

Syntax             string_type get(catalog c, int set, int msgid,
                                   const string_type& dfault) const;

Parameters         c is the message catalog obtained from open().

                   set is used to identify the message.

                   msgid is used to identify the message.

                   dfault is returned if the message cannot be found.

Returns            This method returns a string_type that is a copy
                   of the message or a copy of the dfault message if
                   a failure occurs.

Description

The get() method returns do_get(c, set, msgid, dfault).

Method             messages()

Access             Public

Classification     Constructor

Syntax             explicit messages(size_t refs = 0);

Parameters         refs, if the refs argument = 0 then the destruction
                   of the object is delegated to the locale or locales
                   which contain it. If refs = 1 then the object must
                   be explicitly deleted. The locale will not delete
                   it. The object can then be maintained across the
                   lifetime of multiple locales.

Returns            None

Description

The constructor constructs a messages facet object.

Method             messages()

Access             Protected

Classification     Destructor

Syntax             ~messages();

Parameters         None

Returns            None

Description

The destructor destroys a messages facet object.

Method             open()

Access             Public

Classification     Modifier

Syntax             catalog open(const string& fn,
                                const locale& loc) const;

Parameters         fn is the name of the message catalog.

                   loc is used for the codeset conversion when
                   retrieving messages if needed.

Returns            This method returns a value that is passed to get() in order
                   to retrieve a message.

Description

The open() method returns do_open(fn, loc).

The Class Relationship Diagram for messages


message_base

Class Name            messages_base

Header File          <locale>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

None

Class Description

The messages_base class describes a class that provides a catalog type for messages. It defines a typedef catalog defined as an int type.

The Class Relationship Diagram for messages_base


messages_byname

Class Name            message_byname

Header File          <locale>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

None

Methods

virtual void do_close(catalog) const;

virtual string_type do_get(catalog, int set, int msgid,
const string_type& dfault) const;

virtual catalog do_open(const basic_string&, const locale&) const;

explicit messages_byname(const char*, size_t refs = 0);

~messages_byname();

Class Description

The messages_byname class describes a class that provides facility for the retrieval of strings from the message catalogs for a named locale.

Method             do_close()

Access             Protected

Classification     Modifier

Syntax             virtual void do_close(catalog cat) const;

Parameters         cat is the message catalog obtained from open().

Returns            None

Description

The do_close() method closes the catalog opened by an earlier call to do_open().

Method             do_get()

Access             Protected

Classification     Accessor

Syntax             virtual string_type do_get(catalog cat, int set,
                                              int msgid,
                                              const string_type& dfault) const;

Parameters         cat is the message catalog obtained from open().

                   set is used to identify the message.

                   msgid is used to identify the message.

                   dfault is returned if the message cannot
                   be found.

Returns            This method returns a string_type that is a copy of
                   the message or a copy of the dfault if a failure
                   occurs.

Description

The do_get() method returns the message sequence from the message catalog cat. It makes use of set, msgid, and dfault in doing so. It returns a copy of the specified message sequence. If failure occurs, it returns a copy of dfault on failure.

Method             do_open()

Access             Protected

Classification     Modifier

Syntax             virtual catalog do_open(const string& name,
                                           const locale& loc) const;

Parameters         name is the name of the message catalog.

                   loc is used for the codeset conversion when
                   retrieving messages if needed.

Returns            This method returns catalog that is passed to get()
                   in order to retrieve a message.

Description

The do_open() opens a message catalog specified by name argument. The method returns a value less than 0 if no such catalog can be opened. The loc argument is used for codeset conversion when retrieving messages.

Method             messages_byname()

Access             Public

Classification     Constructor

Syntax             explicit messages_byname(size_t refs = 0);

Parameters         refs, if the refs argument = 0 then the destruction
                   of the object is delegated to the locale or locales
                   which contain it. If refs = 1 then the object must
                   be explicitly deleted. The locale will not delete
                   it. The object can then be maintained across the
                   lifetime of multiple locales.

Returns            None

Description

The constructor constructs a messages_byname facet object for the named locale specified by name argument.

Method             messages_byname()

Access             Protected

Classification     Destructor

Syntax             ~messages_byname();

Parameters         None

Returns            None

Description

The destructor destroys a messages_byname facet object.

The Class Relationship Diagram for messages_byname


The multimap Class

Class Name            multimap

Header File           <map>

Classification      Container
Class Description

Member Classes

None

Methods

iterator begin()

const_iterator begin() const

void clear()

size_type count(const key_type& x) const

bool empty() const

iterator end()

const_iterator end() const

void erase(iterator position)

size_type erase(const key_type& x)

void erase(iterator first, iterator last)

pair<iterator,iterator> equal_range(const key_type& x) const

iterator find(const key_type& x) const

const_iterator find(const key_type& x) const

allocator_type get_allocator() const

pair<iterator,bool> insert(const value_type& x)

iterator insert(iterator position, const value_type& x)

template <class InputIterator>void insert(InputIterator first, InputIterator last)

iterator lower_bound(const key_type& x) const

const_iterator lower_bound(const key_type& x) const

explicit multimap(const Compare& comp = Compare(), const Allocator& = Allocator())

template <class InputIterator> multimap(InputIterator first, InputIterator last, const Compare& comp = Compare(), const Allocator& = Allocator())

multimap(const map<Key,T,Compare,Allocator>& x)

~multimap()

size_type max_size() const

reverse_iterator rbegin()

const_reverse_iterator rbegin() const

reverse_iterator rend()

void resize(size_type Sz, T C = T())

const_reverse_iterator rend() const

size_type size() const

void swap(multimap&)

iterator upper_bound(const key_type& x) const

const_iterator upper_bound(const key_type& x) const

Operators

reference operator[](const key_type& x); multimap<Key,T,Compare,Allocator>& operator=(const multimap<Key,T,Compare,Allocator>& x);

Class Description

The multimap collection is a special type of multiset. The multimap collection is used to create a collection of related pairs. Whereas the map includes the unique pairs of related items, the multimap may include duplicate pairs. The multimap collection associates the elements of one set to the elements of another set. Multimap collections are structured in the same way as the map collection. The elements in the collection are pairs. The difference between a multimap and a map collection is the multimap collection allows key duplication. In other words, the same key can be associated with different values.

Method            swap()

Access            Public

Classification    Modifier

Syntax            void swap(multimap<Key,T,Compare,Allocator>& X)

Parameters        X is the multimap to be swapped with the contents of the current multimap.

Return            X is the multimap to be swapped.

Description

The swap() method swaps the contents of the current multimap with multimap X.

Method            multimap()

Access            Public

Classification    Constructor

Syntax            explicit multimap(const Compare& Comp = Compare(), const Allocator &X = Allocator())

Parameters        Comp is the function object that will be used to order the multimap.
                  X is a allocator object.

Return            None.

Description

The multimap() method constructs an empty set container.

Method            multimap()

Access            Public

Classification    Constructor

Syntax            template <class InputIterator> multimap(InputIterator first, InputIterator last,const Compare& Comp = Compare(), const Allocator&X = Allocator())

Parameters        elements from the range [first,last) will be used to construct the multimap. X is a allocator object.
                  Comp is the function object that will be used to order the multimap.

Return            None.

Description

The multimap() method constructs a multimap that contains copies of the objects that are pointed to by the iterators in the range [first,last].

Method            multimap()

Access            Public

Classification    Constructor

Syntax            multimap(const multimap<Key,Compare,Allocator>& X)

Parameters        X is the multimap that will be used to construct the new multimap.

Return            None.

Description

The multimap() method constructs a new set from multimap X.

Method            multimap()

Access            Public

Classification    Destructor

Syntax            ~multimap()

Parameters        None.

Return            None.

Description

The ~multimap() method destructs a multimap object.


moneypunct_byname

Class Name            moneypunct_byname

Header File          <locale>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

None

Methods

virtual string_type do_curr_symbol() const;

virtual charT do_decimal_point() const;

virtual int do_frac_digits() const;

virtual string do_grouping() const;

virtual pattern do_neg_format() const;

virtual string_type do_negative_sign() const;

virtual pattern do_pos_format() const;

virtual string_type do_positive_sign() const;

virtual charT do_thousands_sep() const;

explicit moneypunct_byname(const char*, size_t refs = 0);

~moneypunct_byname();

Class Description

The moneypunct_byname class describes a class used to provide money punctuation for a named locale.

Method             do_curr_symbol()

Access             Protected

Classification     Accessor

Syntax             virtual string_type do_curr_symbol() const;

Parameters         None

Returns            This method returns a string_type used as the
                   currency symbol.

Description

The do_curr_symbol() method returns a sequence of elements used as the currency symbol.

Method             do_decimal_point()

Access             Protected

Classification     Accessor

Syntax             virtual charT do_decimal_point() const;

Parameters         None

Returns            This method returns a charT used as the decimal point.

Description

The do_decimal_point() method returns a character used as the decimal point.

Method             do_frac_digits()

Access             Protected

Classification     Accessor

Syntax             virtual int do_frac_digits() const;

Parameters         None

Return Type        int

Description

The do_frac_digits() method returns the number of digits in the fractional part (displayed to the right of the decimal point) of the monetary value.

Method             do_grouping()

Access             Protected

Classification     Accessor

Syntax virtual     string do_grouping() const;

Parameters         None

Returns            This method returns a string that is used as a
                   pattern of the number of digits in a particular
                   grouping.

Description

The do_grouping() method returns a string in which each character of the string is used as an integer value which represents the number of digits in a particular grouping, starting with the rightmost group. A group is the digits between the adjacent thousands' separators. The returned value has the same result as the numpunct<charT>::do_grouping().

Method             do_neg_format()

Access             Protected

Classification     Accessor

Syntax             virtual pattern do_neg_format() const;

Parameters         None

Returns            This method returns a pattern which is a four element
                   array that specifies the order in which syntactic
                   elements appear in the monetary format.

Description

The do_neg_format() method returns a pattern that is a four element array. The array specifies the order in which syntactic elements appear in the monetary format. Each enumeration value in the array (symbol, sign, value, and either space or none) appears only once. none, if present, will never occupy the first position. space, if present, will not appear in the first or last position. Otherwise, the elements may appear in any order.

Method             do_negative_sign()

Access             Protected

Classification     Accessor

Syntax             virtual string_type do_negative_sign() const;

Parameters         None

Returns            This method returns a string_type that is used to
                   indicate a negative monetary value.

Description

The do_negative_sign() methods returns a sequence of elements used as a negative sign.

Method             do_pos_format()

Access             Protected

Classification     Accessor

Syntax             virtual pattern do_pos_format() const;

Parameters         None

Returns            This method returns a pattern which is a four element
                   array that specifies the order in which syntactic
                   elements appear in the monetary format.

Description

The do_pos_format() method returns a pattern that is a four element array. The array specifies the order in which syntactic elements appear in the monetary format. Each enumeration value in the array (symbol, sign, value, and either space or none) appears only once. none, if present, will never occupy the first position. space, if present, will not appear in the first or last position. Otherwise, the elements may appear in any order.

Method             do_positive_sign()

Access             Protected

Classification     Accessor

Syntax             string_type do_positive_sign() const;

Parameters         None

Returns            This method returns a string_type that is used to
                   indicate a positive monetary value.

Description

The do_postive_sign() methods returns a sequence of elements used as a positive sign.

Method             do_thousands_sep()

Access             Protected

Classification     Accessor

Syntax             virtual charT do_thousands_sep() const;

Parameters         None

Returns            This method returns a charT that is used as a digit
                   group separator.

Description

The do_thousands_sep() method returns an element to use as a group separator to the left of any decimal point. It is used when the do_grouping() method specifies a digit grouping pattern.

Method             moneypunct_byname()

Access             Public

Classification     Constructor

Syntax             explicit moneypunct_byname(const char* name,
                                              size_t refs = 0);

Parameters         name is the name of the named locale.

                   refs, if the refs argument = 0 then the destruction
                   of the object is delegated to the locale or locales
                   which contain it. If refs = 1 then the object must
                   be explicitly deleted. The locale will not delete
                   it. The object can then be maintained across the
                   lifetime of multiple locales.

Returns            None

Description

The constructor constructs a moneypunct_byname facet object. Uses the named locale specified by name argument.

Method             moneypunct_byname()

Access             Public

Classification     Destructor

Syntax             ~moneypunct_byname();

Parameters         None

Returns            None

Description

The destructor destroys a moneypunct_byname facet object.

The Class Relationship Diagram for moneypunct_byname


moneypunct

Class Name            moneypunct

Header File          <locale>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

locale::id

Methods

string_type curr_symbol() const;

charT decimal_point() const;

virtual string_type do_curr_symbol() const;

virtual charT do_decimal_point() const;

virtual int do_frac_digits() const;

virtual string do_grouping() const;

virtual pattern do_neg_format() const;

virtual string_type do_negative_sign() const;

virtual pattern do_pos_format() const;

virtual string_type do_positive_sign() const;

virtual charT do_thousands_sep() const;

int frac_digits() const;

string grouping() const;

explicit moneypunct(size_t refs = 0);

~moneypunct();

pattern neg_format() const;

string_type negative_sign() const;

pattern pos_format() const;

string_type positive_sign() const;

charT thousands_sep() const;

Class Description

The moneypunct class describes a class used to provide money punctuation.

locale::id

locale::id is a class used to provide an identification of a locale facet interfaces used as an index for lookup and to encapsulate initialization.

Method             curr_symbol()

Access             Public

Classification     Accessor

Syntax             string_type curr_symbol() const;

Parameters         None

Returns            This method returns a string_type used as the
                   currency symbol.

Description

The curr_symbol() method returns do_curr_symbol().

Method             decimal_point()

Access             Public

Classification     Accessor

Syntax             charT decimal_point() const;

Parameters         None

Returns            This method returns a charT used as the decimal
                   point.

Description

The decimal_point() method returns do_decimal_point().

Method             do_curr_symbol()

Access             Protected

Classification     Accessor

Syntax             virtual string_type do_curr_symbol() const;

Parameters         None

Returns            This method returns a string_type used as the
                   currency symbol.

Description

The do_curr_symbol() method returns a sequence of elements used as the currency symbol.

Method             do_decimal_point()

Access             Protected

Classification     Accessor

Syntax             virtual charT do_decimal_point() const;

Parameters         None

Returns            This method returns a charT used as the decimal point.

Description

The do_decimal_point() method returns a character used as the decimal point.

Method             do_frac_digits()

Access             Protected

Classification     Accessor

Syntax             virtual int do_frac_digits() const;

Parameters         None

Return Type        int

Description

The do_frac_digits() method returns the number of digits in the fractional part (displayed to the right of the decimal point) of the monetary value.

Method             do_grouping()

Access             Protected

Classification     Accessor

Syntax             virtual string do_grouping() const;

Parameters         None

Returns            This method returns a string used as a pattern of
                   the number of digits in a particular grouping.

Description

The do_grouping() method returns a string in which each character of the string is used as an integer value which represents the number of digits in a particular grouping, starting with the rightmost group. A group is the digits between the adjacent thousands' separators. The returned value has the same result as the numpunct<charT>::do_grouping().

Method             do_neg_format()

Access             Protected

Classification     Accessor

Syntax             virtual pattern do_neg_format() const;

Parameters         None

Returns            This method returns a pattern which is a four
                   element array that specifies the order in which
                   syntactic elements appear in the monetary format.

Description

The do_neg_format() method returns a pattern that is a four element array. The array specifies the order in which syntactic elements appear in the monetary format. Each enumeration value in the array (symbol, sign, value, and either space or none) appears only once. none, if present, will never occupy the first position. space, if present, will not appear in the first or last position. Otherwise, the elements may appear in any order.

Method             do_negative_sign()

Access             Protected

Classification     Accessor

Syntax             virtual string_type do_negative_sign() const;

Parameters         None

Return             This method returns a string_type that is used to
                   indicate a negative monetary value.

Description

The do_negative_sign() methods returns a sequence of elements used as a negative sign.

Method             do_pos_format()

Access             Protected

Classification     Accessor

Syntax             virtual pattern do_pos_format() const;

Parameters         None

Returns            This method returns a pattern that is a four element
                   array which specifies the order in which syntactic
                   elements appear in the monetary format.

Description

The do_pos_format() method returns a pattern that is a four element array. The array specifies the order in which syntactic elements appear in the monetary format. Each enumeration value in the array (symbol, sign, value, and either space or none) appears only once. none, if present, will never occupy the first position. space, if present, will not appear in the first or last position. Otherwise, the elements may appear in any order.

Method             do_positive_sign()

Access             Protected

Classification     Accessor

Syntax             string_type do_positive_sign() const;

Parameters         None

Returns            This method returns a string_type that is used to
                   indicate a positive monetary value.

Description

The do_postive_sign() methods returns a sequence of elements used as a positive sign.

Method             do_thousands_sep()

Access             Protected

Classification     Accessor

Syntax             virtual charT do_thousands_sep() const;

Parameters         None

Returns            This method returns a charT used as a digit group
                   separator.

Description

The do_thousands_sep() method returns an element to use as a group separator to the left of any decimal point. It is used when the do_grouping() method specifies a digit grouping pattern.

Method             frac_digits()

Access             Public

Classification     Accessor

Syntax             int frac_digits() const;

Parameters         None

Returns            This method returns the number of digits in the
                   fractional part (displayed to the right of the
                   decimal point) of the monetary value.

Description

The frac_digits() method returns do_frac_digits().

Method             grouping()

Access             Public

Classification     Accessor

Syntax             string grouping() const;

Parameters         None

Returns            This method returns a string that is used as a
                   pattern of the number of digits in a particular
                   grouping.

Description

The grouping() method returns do_grouping().

Method             moneypunct()

Access             Public

Classification     Constructor

Syntax             explicit moneypunct(size_t refs = 0);

Parameters         refs, if the refs argument = 0 then the destruction
                   of the object is delegated to the locale or locales
                   which contain it. If refs = 1 then the object must
                   be explicitly deleted. The locale will not delete
                   it. The object can then be maintained across the
                   lifetime of multiple locales.

Returns            None

Description

The constructor constructs a moneypunct facet object.

Method             moneypunct()

Access             Public

Classification     Destructor

Syntax             ~moneypunct();

Parameters          None

Returns             None

Description

The destructor destroys a moneypunct facet object.

Method             neg_format()

Access             Public

Classification     Accessor

Syntax             pattern neg_format() const;

Parameters         None

Returns            This method returns pattern that is a four element
                   array that specifies the order in which syntactic
                   elements appear in the monetary format.

Description

The neg_format() method returns do_neg_format().

Method             negative_sign()

Access             Public

Classification     Accessor

Syntax             string_type negative_sign() const;

Parameters         None

Returns            This method returns a string_type that is used to
                   indicate a negative monetary value.

Description

The negative_sign() methods returns do_negative_sign().

Method             pos_format()

Access             Public

Classification     Accessor

Syntax             pattern pos_format() const;

Parameters         None

Returns            This method returns a pattern that is a four element
                   array that specifies the order in which syntactic
                   elements appear in the monetary format.

Description

The pos_format() method returns do_pos_format().

Method             positive_sign()

Access             Public

Classification     Accessor

Syntax             string_type positive_sign() const;

Parameters         None

Returns            This method returns a string_type that is used to
                   indicate a positive monetary value.

Description

The postive_sign() methods returns do_positive_sign().

Method             thousands_sep()

Access             Public

Classification     Accessor

Syntax             charT thousands_sep() const;

Parameters         None

Returns            This method returns a charT that is used as a
                   digit group separator.

Description

The thousands_sep() method returns do_thousands_sep().

TABLE 1:

The meaning of the elements are:

     value         To match or generate a monetary value.

     none          To match zero or more spaces or generate nothing.

     sign          To match or generate a negative or postive sign.

     space         To match zero or more spaces or generate a space.

     symbol        To match or generate a currency symbol.

The Class Relationship Diagram for moneypunct


money_put

Class Name            money_put

Header File          <locale>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

locale::id

Methods

virtual iter_type do_put(iter_type, bool, ios_base&, char_type fill,
long double units) const;

virtual iter_type do_put(iter_type, bool, ios_base&, char_type fill,
const string_type& digits) const;

explicit money_put(size_t refs = 0);

~money_put();

iter_type put(iter_type s, bool intl, ios_base& f, char_type fill,
long double units) const;

iter_type put(iter_type s, bool intl, ios_base& f, char_type fill,
const string_type& digits) const;

Class Description

The money_put class describes a class used to take a sequence of digits and writes out a formatted representation of the monetary value.

locale::id

locale::id is a class used to provide an identification of a locale facet interfaces used as an index for lookup and to encapsulate initialization.

Method             do_put()

Access             Protected

Classification     Accessor

Syntax             virtual iter_type do_put(iter_type s, bool intl,
                                            ios_base& str,
                                            char_type fill,
                                            string_type& digits) const;

                   virtual iter_type do_put(iter_type s, bool intl,
                                            ios_base& str,
                                            char_type fill,
                                            long double units) const;

Parameters         s is an iterator pointing to the character buffer
                   used for output.

                   intl is set to true or false for international
                   formatting.

                   str is the reference of ios_base object used for
                   formatting information.

                   fill is the character used for padding.

                   units/digits contains the monetary value.

Returns            The methods return an iterator that points to the
                   character past the last character produced.

Description

The do_put() method generates a monetary value contained in the parameter units or digits. It writes out a character string that is placed character buffer pointed to by s. The character sequence is formatted according to the format specified by str.flags() and the moneypunct<charT, true> or moneypunct<charT, false> facet of loc. This will depend on whether intl is true or false. Since the monetary value stored in the arguments units or digits is the smallest possible unit of currency, any fractional portions units and any characters in digits beyond the optional leading '-' and immediately contiguous digits are ignored. The currency symbol is generated only if (str.flags() & ios_base::showbase) is true. If ((str.flags() & ios_base:adjustfield) == ios_base::internal) then the fill argument will be placed where none or space appears in the formatting pattern. The methods return an iterator that points to the character past the last character produced.

Method             put()

Access             Public

Classification     Accessor

Syntax             iter_type put(iter_type s, bool intl, ios_base& f,
                                 char_type fill,
                                 string_type& quant) const;

                   iter_type put(iter_type s, bool intl, ios_base& f,
                                 char_type fill,
                                 long double quant) const;

Parameters         s is an iterator pointing to the character buffer
                   used for output.

                   intl is set to true or false for international
                   formatting.

                   f is the reference of ios_base object used for
                   formatting information.

                   fill is the character used for padding.

                   quant contains the monetary value.

Returns            The methods return an iterator that points to the
                   character past the last character produced.

Description

The put() member functions return do_put(s, intl, f, fill, quant).

Method             money_put()

Access             Public

Classification     Constructor

Syntax             explicit money_put(size_t refs = 0);

Parameters         refs, if the refs argument = 0 then the destruction
                   of the object is delegated to the locale or locales
                   which contain it. If refs = 1 then the object must
                   be explicitly deleted. The locale will not delete
                   it. The object can then be maintained across the
                   lifetime of multiple locales.

Returns            None

Description

The constructor constructs a money_put facet object.

Method             money_put()

Access             Protected

Classification     Destructor

Syntax             ~money_put();

Parameters         None

Returns            None

Description

The destructor destroys a money_put facet object.

The Class Relationship Diagram for money_put


money_base

Class Name            money_base

Header File          <locale>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

None

Class Description

The money_base class provides a structure and an enumeration. The struct pattern specifies the order of syntactic elements in monetary value. It is an array of characters in which each value associated with an index represents an enumeration value that indicates the location of a syntactic element. The enumerations are as follows:

     none          No grouping separator

     sign          Sign of the money value

     space         Use space for grouping separator

     symbol        Symbol for currency

     value         The actual money value

The Class Relationship Diagram for money_base


money_get

Class Name            money_get

Header File          <locale>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

locale::id

Methods

virtual iter_type do_get(iter_type, bool, iter_type, ios_base&,
ios_base::iostate& err, long double& units) const;

virtual iter_type do_get(iter_type, bool, iter_type, ios_base&,
ios_base::iostate& err, string_type& digits) const;

iter_type get(iter_type s, iter_type end, bool intl, ios_base& f,
ios_base::iostate& err, long double& units) const;

iter_type get(iter_type s, iter_type end, bool intl, ios_base& f,
ios_base::iostate& err, string_type& digits) const;

explicit money_get(size_t refs = 0);

~money_get();

Class Description

The money_get class describes a class used to interpret formatted monetary string values.

locale::id

locale::id is a class used to provide an identification of a locale facet interfaces used as an index for lookup and to encapsulate initialization.

Method             do_get()

Access             Protected

Classification     Accessor

Syntax             virtual iter_type do_get(iter_type s, iter_type end,
                                            bool intl,
                                            ios_base& str,
                                            ios_base::iostate& err,
                                            string_type& digits) const;

                   virtual iter_type do_get(iter_type s, iter_type end,
                                            bool intl,
                                            ios_base& str,
                                            ios_base::iostate& err,
                                            long double& units) const;

Parameters         s is an input iterator that points to the beginning
                   character of a character sequence.

                   end is an input iterator that points to the end
                   character of a character sequence.

                   intl is set to true or false for international
                   formatting.

                   str is the reference of ios_base object used for
                   formatting information.

                   err is used to set error conditions in the calling
                   stream.

                   units/digits is used to store the extracted
                   sequence.

Returns            This method returns an iterator that points to one
                   past the last character of a valid monetary sequence.

Description

Each version of the do_get() method reads a sequence of characters in the range [in, end) and extracts a monetary value. Characters are read in the range until a monetary value is assembled, an error occurs or until no more characters are available. The characters are interpreted according to str.flags(), moneypunct<charT, true>, or moneypunct<charT,false> facet str.getloc(). This will depend on whether the intl argument is true or false. The extracted sequence is the smallest possible unit of currency stored in the arguments digits as a string or calculated as a long double and stored in the argument units. If an error occurs then digits and units will remain unchanged. The do_get() method returns an iterator pointing immediately beyond the last character that has been recognized as part of a valid monetary value.

The digit group separators are optional. But if no grouping is specified then the thousands separator will not be considered part of the monetary format. If the space or none are apart of the format pattern in moneypunct facet then the whitespaces, unless its at the end of the sequence, will be consumed. The currency symbol will be optional if (str.flags() & ios_base::showbase) is false. If true then the currency symbol is required and always consumed. If the currency symbol appears after all other required elements then it will not be consumed.

Method             get()

Access             Public

Classification     Modifier

Syntax             iter_type get(iter_type s, iter_type end, bool intl,
                                 ios_base& f, ios_base::iostate& err,
                                 long double& quant) const;

                   iter_type get(iter_type s, iter_type end, bool intl,
                                 ios_base& f, ios_base::iostate& err,
                                 string_type& quant) const;

Parameters         s is an input iterator that points to the beginning
                   character of a character sequence.

                   end is an input iterator that points to the end
                   character of a character sequence.

                   intl is set to true or false for international
                   formatting.

                   f is the reference of ios_base object used for
                   formatting information.

                   err is used to set error conditions in the
                   calling stream.

                   quant is used to store the extracted sequence.

Returns            This method returns an iterator that points to one
                   past the last character of a valid monetary sequence.

Description

The get() member functions return do_get(s, end, intl, f, err, quant).

Method             money_get()

Access             Public

Classification     Constructor

Syntax             explicit money_get(size_t refs = 0);

Parameters         refs, if the refs argument = 0 then the destruction
                   of the object is delegated to the locale or locales
                   which contain it. If refs = 1 then the object must
                   be explicitly deleted. The locale will not delete
                   it. The object can then be maintained across the
                   lifetime of multiple locales.

Returns            None

Description

The constructor constructs a money_get facet object.

Method             money_get()

Access             Protected

Classification     Destructor

Syntax             ~money_get();

Parameters         None

Returns            None

Description

The destructor destroys a money_get facet object.

The Class Relationship Diagram for money_get


The multiset Class

Class Name            multiset

Header File           <set>

Classification      Container
Class Description

Member Classes

None

Methods

iterator begin()

const_iterator begin() const

void clear()

size_type count(const key_type& x) const

bool empty() const

iterator end()

const_iterator end() const

void erase(iterator position)

size_type erase(const key_type& x)

void erase(iterator first, iterator last)

pair<iterator,iterator> equal_range(const key_type& x) const

iterator find(const key_type& x) const

allocator_type get_allocator() const

pair<iterator,bool> insert(const value_type& x)

iterator insert(iterator position, const value_type& x)

template <class InputIterator>void insert(InputIterator first, InputIterator last)

iterator lower_bound(const key_type& x) const

size_type max_size() const

explicit multiset(const Compare& comp = Compare(), const Allocator& = Allocator())

template <class InputIterator> multiset(InputIterator first, InputIterator last, const Compare& comp = Compare(), const Allocator& = Allocator())

multiset(const multiset<Key,Compare,Allocator>& x)

~multiset()

reverse_iterator rbegin()

const_reverse_iterator rbegin() const

reverse_iterator rend()

void resize(size_type Sz, T C = T())

const_reverse_iterator rend() const

size_type size() const

void swap(muliset<Key,Compare,Allocator>& X)

iterator upper_bound(const key_type& x) const

Operators

multiset<Key,Compare,Allocator<& operator=(const multiset<Key,Compare,Allocator>& x)

Class Description

A multiset is a set that can contain duplicates of members. A set is a unordered collection of unique elements. A multiset is a unordered collection of not necessarily unique elements.

Method            swap()

Access            Public

Classification    Modifier

Syntax            void swap(multiset<Key,Compare,Allocator>& X)

Parameters        X is the multiset to be swapped with the contents of the current multiset.

Return            X is the multiset to be swapped.

Description

The swap() method swaps the contents of the current multiset with multiset X.

Method            multiset()

Access            Public

Classification    Constructor

Syntax            explicit multiset(const Compare& Comp = Compare(), const Allocator &X = Allocator())

Parameters        Comp is the function object that will be used to order the multiset.
                   X is a allocator object.

Return            None.

Description

The multiset() method constructs an empty multiset container.

Method            multiset()

Access            Public

Classification    Constructor

Syntax            template <class InputIterator> multiset(InputIterator first, InputIterator last,const Compare& Comp = Compare(), const Allocator&X = Allocator())

Parameters        elements from the range [first,last) will be used to construct the multiset. X is a allocator object.
                  Comp is the function object that will be used to order the multiset.

Return            None.

Description

The multiset() method constructs a multiset that contains copies of the objects that are pointed to by the iterators in the range [first,last].

Method            multiset()

Access            Public

Classification    Constructor

Syntax            multiset(const multiset<Key,Compare,Allocator>& X)

Parameters        X is the multiset that will be used to construct the new multiset.

Return            None.

Description

The multiset() method constructs a new multiset from multiset X.

Method            multiset()

Access            Public

Classification    Destructor

Syntax            ~multiset()

Parameters        None.

Return            None.

Description

The ~multiset() method destructs a multiset object.


num_get

Class Name            num_get

Header File          <locale>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

locale::id

Methods

virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, bool& v) const;

virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, long& v) const;

virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, unsigned short& v) const;

virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, unsigned int& v) const;

virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, unsigned long& v) const;

virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, float& v) const;

virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, double& v) const;

virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, long double& v) const;

virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, void*& v) const;

iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, bool& v) const;

iter_type get(iter_type in, iter_type end, ios_base& ,
ios_base::iostate& err, long& v) const;

iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, unsigned short& v) const;

iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, unsigned int& v) const;

iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, unsigned long& v) const;

iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, float& v) const;

iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, double& v) const;

iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, long double& v) const;

iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, void*& v) const;

explicit num_get(size_t refs = 0);

~num_get();

Class Description

The num_get class describes a class used to parse numeric values from an input sequence.

locale::id

locale::id is a class used to provide an identification of a locale facet interfaces used as an index for lookup and to encapsulate initialization.

Method             do_get()

Access             Protected

Classification     Modifier

Syntax             virtual iter_type do_get(iter_type in, iter_type end,
                                            ios_base& str,
                                            ios_base::iostate& err,
                                            long& val) const;

                   virtual iter_type do_get(iter_type in, iter_type end,
                                            ios_base& str,
                                            ios_base::iostate& err,
                                            unsigned short& val) const;

                   virtual iter_type do_get(iter_type in, iter_type end,
                                            ios_base& str,
                                            ios_base::iostate& err,
                                            unsigned int& val) const;

                   virtual iter_type do_get(iter_type in, iter_type end,
                                            ios_base& str,
                                            ios_base::iostate& err,
                                            unsigned long& val) const;

                   virtual iter_type do_get(iter_type in, iter_type end,
                                            ios_base& str,
                                            ios_base::iostate& err,
                                            float& val) const;

                   virtual iter_type do_get(iter_type in, iter_type end,
                                            ios_base& str,
                                            ios_base::iostate& err,
                                            double& val) const;

                   virtual iter_type do_get(iter_type in, iter_type end,
                                            ios_base& str,
                                            ios_base::iostate& err,
                                            long double& val) const;

                   virtual iter_type do_get(iter_type in, iter_type end,
                                            ios_base& str,
                                            ios_base::iostate& err,
                                            void*& val) const;

Parameters         in is an input iterator that points to the beginning
                   character of a character sequence.

                   end is an input iterator that points to the end
                   character of a character sequence.

                   str is the reference of ios_base object used for
                   formatting information.

                   err is used to set error conditions in the calling
                   stream.

                   val stores the numeric value.

Returns            This methods returns in.

Description

Each version of the do_get() method reads a sequence of characters of the range [in, end) and extracts a numeric value. The characters are interpreted according to str.flags(), use_facet<ctype<charT> > (loc), and use_facet<numpunct<charT> > (loc). If successful, the numeric value is returned in val. If an error does occur then val remains unchanged, err argument is assigned failbit.

The process of inputting characters that represent numbers can be summarized in two stages:

Stage 1: Determine a conversion specifier:

    *   initialize local variables using str.flags().

      *   conversion to a integral type, floating point or void*
            using specifiers.

    *   determine length specifier if needed.

Stage 2: Extract characters from input source and tranform them into char according to conversion specification:

    *   if the input iterator points to the end of the sequence,
            terminate this stage.

    *   determine if the character extracted is a decimal point

    *   detemine if the character is a thousands separator and
            determine if digit grouping length != 0. If both are true
            then the position of the character in the sequence is
            remembered.

    *   if the character is allowed to be the next character in
            the sequence according to the conversion specification
            then the character is accumulated.

    *   advance the input iterator to the next character and restart
            stage 2.

The possible results of processing the characters are:

    *   ios_base::goodbit is assigned to err:
        a sequence of characters has been accumulated and the value
            is stored in val.

    *   ios_base::failbit is assigned to err:
        digit grouping has been checked and the positions of discarded
        separators is not consistent or scanf reports an input failure.

    *   ios_base::eofbit is assigned to err:
        the end of the input sequence has been reached.

Method             get()

Access             Public

Classification     Modifier

Syntax             virtual iter_type get(iter_type in, iter_type end,
                                         ios_base& str,
                                         ios_base::iostate& err,
                                         long& val) const;

                   virtual iter_type get(iter_type in, iter_type end,
                                         ios_base& str,
                                         ios_base::iostate& err,
                                         unsigned short& val) const;

                   virtual iter_type get(iter_type in, iter_type end,
                                         ios_base& str,
                                         ios_base::iostate& err,
                                         unsigned int& val) const;

                   virtual iter_type get(iter_type in, iter_type end,
                                         ios_base& str,
                                         ios_base::iostate& err,
                                         unsigned long& val) const;

                   virtual iter_type get(iter_type in, iter_type end,
                                         ios_base& str,
                                         ios_base::iostate& err,
                                         short& val) const;

                   virtual iter_type get(iter_type in, iter_type end,
                                         ios_base& str,
                                         ios_base::iostate& err,
                                         double& val) const;

                   virtual iter_type get(iter_type in, iter_type end,
                                         ios_base& str,
                                         ios_base::iostate& err,
                                         long double& val) const;

                   virtual iter_type get(iter_type in, iter_type end,
                                         ios_base& str,
                                         ios_base::iostate& err,
                                         void*& val) const;

Parameters         in is an input iterator that points to the beginning
                   character of a character sequence.

                   end is an input iterator that points to the end
                   character of a character sequence.

                   str is the reference of ios_base object used for
                   formatting information.

                   err is used to set error conditions in the calling
                   stream.

                   val stores the numeric value.

Returns            This methods returns in.

Description

The get() member function returns do_get(in, end, str, err, val).

Method             num_get()

Access             Public

Classification     Constructor

Syntax             explicit num_get(size_t refs = 0);

Parameters         refs, if the refs argument = 0 then the destruction
                   of the object is delegated to the locale or locales
                   which contain it. If refs = 1 then the object must
                   be explicitly deleted. The locale will not delete
                   it. The object can then be maintained across the
                   lifetime of multiple locales.

Returns            None

Description

This constructor constructs a num_get facet object.

Method             num_get()

Access             Protected

Classification     Destructor

Syntax             ~num_get();

Parameters         None

Returns            None

Description

This destructor destroys a num_get facet object.

The Class Relationship Diagram for num_get


numpunct_byname

Class Name            numpunct_byname

Header File          <locale>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

None

Methods

virtual char_type do_decimal_point() const;

virtual string_type do_falsename() const;

virtual string do_grouping() const;

virtual char_type do_thousands_sep() const;

virtual string_type do_truename() const;

explicit numpunct_byname(const char*, size_t refs = 0);

~numpunct_byname();

Class Description

The numpunct_byname class describes a class that provides the same functionality as the numpunct class. Its behavior is determined by a particular named locale. This class is specialized for char and wchar_t.

Method             do_decimal_point()

Access             Protected

Classification     Accessor

Syntax             char_type do_decimal_point() const;

Parameters         None

Return Type        char_type

Description

The do_decimal_point() method returns a a locale-specific character used as the decimal radix separator.

Method             do_falsename()

Access             Protected

Classification     Accessor

Syntax             string_type do_falsename() const;

Parameters         None

Return Type        string_type

Description

The do_falsename() method returns a locale-specific sequence that is used as text to represent the boolean value of false.

Method             do_grouping()

Access             Protected

Classification     Accessor

Syntax             string do_grouping() const;

Parameters         None

Return Type        string

Description

The do_grouping() returns a locale-specific basic_string<char> vec that is vector of integer values. Each element of the vector is used to represent the number of digits in a grouping starting at position 0 as the rightmost group.

Method             do_thousands_sep()

Access             Protected

Classification     Accessor

Syntax             string_type do_thousands_sep() const;

Parameters         None

Return Type        string_type

Description

The do_thousands)sep() method returns a locale-specific character used to as a digit group separator.

Method             do_truename()

Access             Protected

Classification     Accessor

Syntax             string_type do_truename() const;

Parameters         None

Return Type        string_type

Description

The do_truename() method returns a locale-specific sequence that is used as text to represent the boolean value of true.

Method             numpunct_byname()

Access             Public

Classification     Constructor

Syntax             explicit numpunct_byname(const char* name,
                                            size_t refs = 0);

Parameters         name is the name of the named locale.

                   refs, if the refs argument = 0 then the destruction
                   of the object is delegated to the locale or locales
                   which contain it. If refs = 1 then the object must
                   be explicitly deleted. The locale will not delete
                   it. The object can then be maintained across the
                   lifetime of multiple locales.

Returns            None

Description

The constructor constructs a numpunct_byname facet object.

Method             ~numpunct_byname()

Access             Public

Classification     Accessor

Syntax             ~numpunct_byname();

Parameters         None

Returns            None

Description

The destructor destroys a numpunct_byname facet object.

The Class Relationship Diagram for numpunct_byname


numpunct

Class Name            numpunct

Header File          <locale>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

locale::id

Methods

char_type decimal_point() const;

virtual char_type do_decimal_point() const;

virtual string_type do_falsename() const;

virtual string do_grouping() const;

virtual char_type do_thousands_sep() const;

virtual string_type do_truename() const;

string_type falsename() const;

string grouping() const;

explicit numpunct(size_t refs = 0);

~numpunct();

char_type thousands_sep() const;

string_type truename() const;

Class Description

The numpunct class describes a class used to specify the numeric punctuation by providing the classic "C" numeric formats.

The syntax for the number formats are as follows:

Integer values have this format:

     integer       : : = [sign} units

     sign          : : = plusminus [whitespace]

     units         : : = digits [thousands-sep units]

     digits        : : = digit [digits]

digit represents the radix set specified by fmtflags argument value. whitespace is determined by the facet ctype<charT>. thousands-sep amd decimal-point are the results of the corresponding numpunct<charT> members.

The floating-point values have:

     floatval      : : = [sign] units [decimal-point [digits]] [e [sign] digits] |
                         [sign]        decimal-point  digits   [e [sign] digits]

     e             : : = 'e' | 'E'

The number of digits between thousands-seps is as specified by do_grouping(). For parsing, if the digits portion contains no thousands-separators then no grouping constraint is used.

locale::id

locale::id is a class used to provide an identification of a locale facet interfaces used as an index for lookup and to encapsulate initialization.

Method             decimal_point()

Access             Public

Classification     Accessor

Syntax             char_type decimal_point() const;

Parameters         None

Returns            This method returns the decimal radix separator.

Description

The decimal_point() member function returns do_decimal_point().

Method             do_decimal_point()

Access             Protected

Classification     Accessor

Syntax             char_type do_decimal_point() const;

Parameters         None

Return Type        char_type

Description

The do_decimal_point() method returns a a locale-specific character used as the decimal radix separator.

Method             do_falsename()

Access             Protected

Classification     Accessor

Syntax             string_type do_falsename() const;

Parameters         None

Return Type        string_type

Description

The do_falsename() method returns a locale-specific sequence that is used as text to represent the boolean value of false.

Method             do_grouping()

Access             Protected

Classification     Accessor

Syntax             string do_grouping() const;

Parameters         None

Return Type        string

Description

The do_grouping() method returns a locale-specific basic_string<char> vec that is vector of integer values. Each element of the vector is used to represent the number of digits in a grouping starting at position 0 as the rightmost group.

Method             do_thousands_sep()

Access             Protected

Classification     Accessor

Syntax             string_type do_thousands_sep() const;

Parameters         None

Return Type        string_type

Description

The do_thousands_sep() method returns a locale-specific character used to as a digit group separator.

Method             do_truename()

Access             Protected

Classification     Accessor

Syntax             string_type do_truename() const;

Parameters         None

Return Type        string_type

Description

The do_truename() method returns a locale-specific sequence that is used as text to represent the boolean value of true.

Method             falsename()

Access             Public

Classification     Accessor

Syntax             string_type falsename() const;

Parameters         None

Returns            This method returns a sequence to represent the
                   boolean value of false.

Description

The falsename() method returns do_falsename().

Method             grouping()

Access             Public

Classification     Accessor

Syntax             string grouping() const;

Parameters         None

Returns            This method returns a vector in which each element
                   is an integer value used to represent the number
                   of digits in a grouping starting at position
                   0 as the rightmost group.

Description

The grouping() method returns do_grouping().

Method             numpunct()

Access             Public

Classification     Constructor

Syntax             explicit numpunct(size_t refs = 0);

Parameters         refs, if the refs argument = 0 then the destruction
                   of the object is delegated to the locale or locales
                   which contain it. If refs = 1 then the object must
                   be explicitly deleted. The locale will not delete
                   it. The object can then be maintained across
                   the lifetime of multiple locales.

Returns            None

Description

The constructor constructs a numpunct facet object.

Method             numpunct()

Access             Public

Classification     Destructor

Syntax             ~numpunct();

Parameters         None

Returns            None

Description

The destructor destroys a numpunct facet object.

Method             thousands_sep()

Access             Protected

Classification     Accessor

Syntax             char_type thousands_sep() const;

Parameters         None

Returns            This method returns a character used to as a digit
                   group separator.

Description

The thousands_sep() member function returns do_thousands_sep();

Method             truename()

Access             Public

Classification     Accessor

Syntax             string_type truename() const;

Parameters         None

Returns            This method returns a sequence to represent the
                   boolean value of true.

Description

The truename() member function returns do_truename().

The Class Relationship Diagram for numpunct


num_put

Class Name            num_put

Header File          <locale>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

locale::id

Methods

virtual iter_type do_put(iter_type, ios_base&, char_type fill, bool v) const;

virtual iter_type do_put(iter_type, ios_base&, char_type fill, long v) const;

virtual iter_type do_put(iter_type, ios_base&, char_type fill, unsigned long) const;

virtual iter_type do_put(iter_type, ios_base&, char_type fill, double v) const;

virtual iter_type do_put(iter_type, ios_base&, char_type fill, long double v) const;

virtual iter_type do_put(iter_type, ios_base&, char_type fill, void* v) const;

explicit num_put(size_t refs = 0);

~num_put();

iter_type put(iter_type s, ios_base& f, char_type fill, bool v) const;

iter_type put(iter_type s, ios_base& f, char_type fill, long v) const;

iter_type put(iter_type s, ios_base& f, char_type fill, unsigned long v) const;

iter_type put(iter_type s, ios_base& f, char_type fill, double v) const;

iter_type put(iter_type s, ios_base& f, char_type fill, long double v) const;

iter_type put(iter_type s, ios_base& f, char_type fill, void* v) const;

Class Description

The num_put class describes a class used to format numeric values to an output sequence.

locale::id

locale::id is a class used to provide an identification of a locale facet interfaces used as an index for lookup and to encapsulate initialization.

Method             do_put()

Access             Protected

Classification     Accessor

Syntax             virtual iter_type do_put(iter_type out, ios_base& str,
                                            char_type fill,
                                            bool v) const;

                   virtual iter_type do_put(iter_type out, ios_base& str,
                                            char_type fill,
                                            long v) const;

                   virtual iter_type do_put(iter_type out, ios_base& str,
                                            char_type fill,
                                            unsigned long v) const;

                   virtual iter_type do_put(iter_type out, ios_base& str,
                                            char_type fill,
                                            double v) const;

                   virtual iter_type do_put(iter_type out, ios_base& str,
                                            char_type fill,
                                            long double v) const;

                   virtual iter_type do_put(iter_type out, ios_base& str,
                                            char_type fill,
                                            void* m v) const;

Parameters         out is an iterator that points to the destination
                   sequence.

                   str supplies the formatting specifications.

                   fill is a character used for padding.

                   v is the value to be formatted.

Returns            This method returns out.

Description

Each version of the do_put() method reads the value v and formats it according to the formatting specifications obtained from str argument. The fill character is used for padding. The formatted character string is inserted into out argument.

The process of outputting characters that represent numbers can be summarized in four stages:

Stage 1: If the current locale is the "C" locale, determine a printf conversion specifier (spec) and determine the characters that are to be printed:

    *   initialize local variables using this->flags().
      *   conversion to an integral type, floating point or void*
            using specifiers.

    *   determine length specifier needed.

    *   representation would be char's printed by printf(s, val)
            where s is the conversion specifier.

Stage 2: Convert each char to charT using a conversion:

    *   the conversion and the values are returned by members of:
        use_facet > (str.getloc()).

    *   any character other than the decimal point is converted.

    *   decimal point characters are replaced with punct.decimal_point().

    *   thousands separator character are inserted into the sequence
        determined by the value returned by punct.do_grouping().

Stage 3: Determine the location of any padding:

    *   if width() != 0 and the number of charT's in the sequence is
            less than width() then the fill characters are added at the
            position indicated for padding to bring the sequence equal to
            width().

Stage 4: The sequence is sent to output:

    *   the sequence is sent to output via: *out++ = c

    *   out is returned

The possible results of processing the characters are:

    *   out.failed() becomes true during stage 3, output is
            terminated.

Method             put()

Access             Public

Classification     Accessor

Syntax             iter_type put(iter_type out, ios_base& str,
                                 char_type fill, bool v) const;

                   iter_type put(iter_type out, ios_base& str,
                                 char_type fill, long v) const;

                   iter_type put(iter_type out, ios_base& str,
                                 char_type fill, unsigned long v) const;

                   iter_type put(iter_type out, ios_base& str,
                                 char_type fill, double v) const;

                   iter_type put(iter_type out, ios_base& str,
                                 char_type fill,long double v) const;

                   iter_type put(iter_type out, ios_base& str,
                                 char_type fill,void* m v) const;

Parameters         out is an iterator that points to the destination
                   sequence.

                   str supplies the formatting specifications.

                   fill is a character used for padding.

                   v is the value to be formatted.

Returns            This method returns out.

Description

Each version of the put() method returns do_put(out, str, fill, v).

Method             num_put()

Access             Public

Classification     Constructor

Syntax             explicit num_put(size_t refs = 0);

Parameters         refs, if the refs argument = 0 then the destruction
                   of the object is delegated to the locale or locales
                   which contain it. If refs = 1 then the object must
                   be explicitly deleted. The locale will not delete
                   it. The object can then be maintained across the
                   lifetime of multiple locales.

Returns            None

Description

This constructor constructs a num_put facet object.

Method             num_put()

Access             Protected

Classification     Destructor

Syntax             ~num_put();

Parameters         None

Returns            None

Description

This destructor destroys a num_put facet object.

The Class Relationship Diagram for num_put


The basic_ofstream(ofstream) Class

Class Name            basic_ofstream

Header File           <fstream>

Classification      Input/Output (Format Class)
Class Relationship Diagram

Class Description

Member Classes

basic_filebuf

Methods

basic_ofstream()

explicit basic_ofstream(const char* s,ios_base::openmode mode = ios_base::in)

basic_filebuf<charT,traits>* rdbuf() const

bool is_open()

void open(const char* Str, openmode OMode = in)

void close()

Example

Class Description

The ofstream class is derived from the basic_istream class. The ofstream class models the output file stream. Whereas the basic_istream class focuses on a input stream normally attached to the console, the ifstream focuses on a stream normally attached to a file. The ofstream is a specialized basic_ostream class. Through the filebuf component the ifstream class has access to the file. It is important to note that the ANSI/ISO standard for the iostreams does not support the concept of a file descriptor. Older implementations of the iostreams often included file descriptor access through the filebuf class and some type of fd( ) method. This type of access is no longer supported. The standard typedef for basic_ofstream is ofstream.

Method            basic_ofstream()

Access            Public

Classification    Constructor

Syntax            basic_ofstream()

Parameters        None

Return            None

Description

This basic_ofstream() method constructs a basic_ifstream object. It constructs a stream that is not connected to any file or device. The open() method will have to be called to connect the stream with a file or device.

Method            basic_ofstream()

Access            Public

Classification    Constructor

Syntax            explicit basic_ofstream(const char* Str,ios_base::openmode OMode = ios_base::in)

Parameters        Str points to the name of the file or device that will be opened and
                  connected to the ofstream object. OMode is the mode the stream will
                  be opened in.

Return            None

Description

This basic_ofstream() method constructs a basic_ofstream object. This constructor constructs a stream that will be connected to the device named by Str. The device or file will be opened in the mode specified by OMode. This constructor opens the file specified by Str. if the file cannot be opened the buffer state will contain the error condition.

Method            rdbuf()

Access            Public

Classification    Accessor

Syntax            basic_filebuf<charT,traits>* rdbuf() const

Parameters        None

Return            Returns a pointer to the associated streambuf object.

Description

The rdbuf() method returns a pointer to the associated streambuf object.

The Class Relationship Diagram of basic_ofstream

// This program uses the ofstream class to
// generate a simple HTML skeleton
// that can be opened with a web browser.

#include <iostream>
#include <fstream>

using namespace std;

void main(void)
{

   ofstream Internet("WebPage.html");
   Internet << "<html>" << endl << "<head>" << endl;
   Internet << "<title>C++ Standard Class Library</title>" << endl;
   Internet << "</head>" << endl << "<body>" << endl;
   Internet << "<h3>Object Oriented I/O</h3>" << endl;
   Internet << "The iostreams can be used to generate HTML files!" << endl;
   Internet << "and Web pages" <<endl;
   Internet << "</body>" << endl << "</html>" << endl;
   Internet.close();
}


The Common Container Operators

 Operator	            Description
 ________                   ____________

 a == b                    Equality operation on containers of the same type. Returns true
                           when the sequences of elements in a and b are elementwise equal
                           (using x : : value_type : : operator==) Takes linear time. a != b
                           The opposite of the equality operation. Takes linear time.

 a <b                      Compares two containers lexicographically. Takes linear time.

 a >b                      Returns true if b < a, as defined above. Takes linear time.

 a <= b                    Returns true if ! (a > b). Takes linear time.

 a >= b                    Returns true if ! (a < b) Takes linear time.

 r = a                     The assignment operator for containers. Takes linear time.


The basic_ostringstream Class

Class Name            basic_ostringstream

Header File           <sstream>

Classification      Input/Output (Memory Class)
Class Relationship Diagram

Class Description

Member Classes

basic_stringbuf

Methods

explicit basic_ostringstream(ios_base::openmode OMode = ios_base::in)

explicit basic_ostringstream(const basic_string& Str,ios_base::openmode OMode = ios_base::in)

basic_stringbuf* rdbuf() const

basic_string str() const

void str(const basic_string& Str)

Example

Class Description

The basic_ostringstream class implements the functionality of an object oriented input memory device. Whereas the cout type basic_ostream object is normally tied to the console, and the ofstream class is connected to a file, or a device that is recognized as a file. The basic_ostringstream class is connected to a block of memory, or a character array. The basic_ostringstream class is a model of a character, or byte array. The ostringstream class is derived from the basic_ostream class. The standard typedef for basic_ostringstream is ostringstream.

Whereas the basic_ostream class has a basic_streambuf component, and the ofstream has a filebuf component, the ostringstream class has a stringbuf component. The stringbuf component is a specialized basic_streambuf. It is derived from basic_streambuf. The stringbuf component is connected to a character array, as opposed to a file. The source of a stringbuf is intended to be a memory device. The programmer can have direct access to the ostringstream memory device through the stringbuf component. The stringbuf component can be reached by the rdbuf() member function.

Method            basic_ostringstream()

Access            Public

Classification    Constructor

Syntax            explicit basic_ostringstream(ios_base::openmode OMode = ios_base::out)

Parameters        OMode is the open mode the buffer will be constructed with.
                  Basic open modes are:

                                Open Mode       Function
                                ________________________________________
                                app             append
                                ate             open at end
                                out             open for writing
                                trunc           erase buffer start at 0
                                ________________________________________

Return            None

Method            basic_ostringstream()

Access            Public

Classification    Constructor

Syntax            explicit basic_ostringstream(const basic_string& Str,ios_base::openmode OMode = ios_base::out)

Parameters        OMode is the open mode the buffer will be constructed with.
                  Basic open modes are:

                                Open Mode       Function
                                ________________________________________
                                app             append
                                ate             open at end
                                out             open for writing
                                trunc           erase buffer start at 0
                                ________________________________________

                 Str is a reference  to a character buffer that will be used as the put area for the
                 ostringstream object.

Return            None

Description

This basic_ostringstream() method constructs a basic_ostringstream object. It constructs a stream that is uses Str as its buffer or put area.

Method            rdbuf()

Access            Public

Classification    Accessor

Syntax            basic_filebuf<charT,traits>* rdbuf() const

Parameters        None

Return            Returns a pointer to the associated streambuf object.

Description

The rdbuf() method returns a pointer to the associated streambuf object.

The Class Relationship Diagram of basic_ostringstream

    1   #include <iostream>
    2   #include <sstream>
    3   #include <string>
    4
    5   using namespace std;
    6
    7   void main(void)
    8   {
    9         string Source("These are the voyages....");
   10         char Dest[81] = "";
   11         istringstream InputStream(Source);
   12         ostringstream Buffer;
   13         if(!InputStream){
   14              cerr << "Error Setting up stream";
   15         }
   16         InputStream.get(Dest,81,'e');
   17         Buffer << Dest << endl;
   18         InputStream.seekg(0,ios_base::beg);
   19         InputStream.get(Dest,InputStream.rdbuf()->in_avail(),'\n');
   20         Buffer << Dest << endl;
   21         InputStream.seekg(0,ios_base::beg);
   22         InputStream.get(Dest,5,'\n');
   23         Buffer << Dest << endl;
   24         cout << Buffer.str() << endl;
   25   }


The basic_ostream(ostream) Class

Class Name            basic_ostream

Header File           <ostream>

Classification      Input/Output (Format Class)
Class Relationship Diagram

Class Description

Member Classes

basic_ios
sentry

Methods

explicit basic_ostream(basic_streambuf* Sb)

virtual ~basic_ostream()

basic_ostream& put(char_type CharValue)

basic_ostream& write(const char_type* Str, streamsize Num)

basic_ostream& flush()

pos_type tellp()

basic_ostream& seekp(pos_type Pos)

basic_ostream& seekp(off_type Pos, ios_base::seekdir Dir)

Class Description

The basic_ostream class implements the notion of the object oriented output stream. This object oriented output stream can be a binary stream or a text stream. The object oriented stream can be buffered, or unbuffered. The basic_ostream class has facilities to process single characters, or blocks of characters. When characters or blocks of characters are sent to an basic_ostream object the operation is referred to as insertion. The cout and wcout objects are examples of basic_ostream objects that have been pre-defined.

Method            basic_ostream()

Access            Public

Classification    Constructor

Syntax            explicit basic_ostream(basic_streambuf* Sb)

Parameters        Sb is the buffer object that will be used for the ostream
                  object.

Return            None

Description

This basic_ostream() method is used to construct an object of type basic_ostream.

Method            basic_ostream()

Access            Public

Classification    Constructor

Syntax            virtual ~basic_ostream()

Parameters        None

Return            None

Description

This basic_ostream() method is used to destruct an object of type basic_ostream.

Method            put()

Access            Public

Classification    Modifier

Syntax            basic_ostream<charT,traits>& put(char_type CharValue)

Parameters        CharValue is the character that is inserted into the
                  output stream

Return            This method returns a reference to the current ostream object.

Description

The put() method is used to insert a character into the output stream.

Method            write()

Access            Public

Classification    Modifier

Syntax            basic_ostream<charT,traits>& write(const char_type* Str, streamsize Num)

Parameters        Num characters are inserted into the output stream starting at the location
                  pointed to by Str.

Return            This method returns a reference to the current ostream object.

Description

The write() method is used to insert a character into the output stream. The insertion operation will continue until Num characters are inserted into the output stream or until an error condition occurs. If the output operation fails an exception may be thrown e.g.

                       ios_base::failure

Method            flush()

Access            Public

Classification    Modifier

Syntax            basic_ostream<charT,traits>& flush()

Parameters        None

Return            This method returns a reference to the current ostream object.

Description

The flush() method has the effect of calling sync.

Method            tellp()

Access            Public

Classification    Accessor

Syntax            pos_type tellp()

Parameters        None

Return            This method returns the current put position.

Description

The tellp() method returns the current position of put pointer in the output stream.

Method            seekp()

Access            Public

Classification    Modifier

Syntax            basic_ostream<charT,traits>& seekp(pos_type Pos)

Parameters        Pos is the position in the output stream that the point pointer
                  will be moved to.

Return            This method returns a reference to the current ostream object.

Description

The seekp() method performs an absolute seek Pos from the beginning of the output stream.

Method            seekp()

Access            Public

Classification    Modifier

Syntax            basic_ostream<charT,traits>& seekp(off_type Pos, ios_base::seekdir Dir)

Parameters        Pos is the position in the output stream that the point pointer
                  will be moved to relative Dir.  Dir can have the following
                  values

                                      ios_base::beg
                                      ios_base::cur
                                      ios_base::end

Return            This method returns a reference to the current ostream object.

Description

The seekp() method performs an relative seek to Pos from the direction specified by Dir.

The Class Relationship Diagram of basic_ostream


The overflow_error Class

Class Name            overflow_error

Header File           <stdexcept>

Classification      Exception
Class Relationship Diagram

Class Description

Member Classes

None

Methods

overflow_error(const string &What_Arg)

Example

Class Description

The overflow_error class is derived from the runtime_error class. The overflow_error class represents exceptions that occur because arithmetic overflow error.

Method            overflow_error()

Access            Public

Classification    Constructor

Syntax            overflow_error(const string &What_Arg)

Parameters        The What_Arg parameter should contain a description of the kind of exception
                  that has occurred.

Return            None

Description

The overflow_error() method constructs an object of type overflow_error. The What_Arg parameter can be used to set a description of the kind of error that this exception represents. A set possible solutions is sometimes supplied with the exception description in addition to the type of error.

overflow_error Class Relationship Diagram

    1
    2   #include <stdexcept>
    3
    4
    5   void main(void)
    6   {
    7
    8
    9      try{
   10
   11            exception X;
   12            throw(X);
   13      }
   14      catch(const exception &X)
   15      {
   16          cout << X.what() << endl;
   17
   18      }
   19
   20      try
   21      {
   22          overflow_error OverFlow("Arithmetic Operation Overflow");
   23          throw(OverFlow);
   24      }
   25      catch(const exception &X)
   26      {
   27          cout << X.what() << endl;
   28      }
   29
   30
   31
   32   }
   33


The priority_queue Class

Class Name            priority_queue

Header File           <queue>

Classification      Container
Class Description

Member Classes

None

Methods

bool empty() const

size_type size() const

void push(const value_type& x)

void pop()

explicit priority_queue(const Compare& X = Compare(),const Container&Cont = Container())

template <class InputIterator> priority_queue(InputIterator first, InputIterator last, const Compare& x = Compare(), const Container& = Container())

const value_type& top()

Operators

Class Description

A priority queue is an ordered queue. This means that the objects that are placed into a priority queue are sorted into some kind of order. However, this does not change the restriction of only being able to dequeue from the front of the queue and enqueue into the rear of the queue. There are two types of priority queues, descending priority queues and ascending priority queues. In a descending priority queue the objects are sorted from largest to smallest. The largest object is dequeued from the queue, and then the next largest object is dequeued, and so on. In this way the queue is said to be descending, because as the values are dequeued they get smaller. The ascending priority queue is just the opposite. In a ascending queue the object are stored in sequence from smallest to largest. The container class library priority_queue is a adaptor or interface class.

Method             priority_queue()

Access            Public

Classification    Constructor

Syntax            explicit priority_queue(const Compare& X = Compare(),const Container&Cont = Container())

Parameters        X is the function object that will be used to order the priority_queue.
                  The objects in Cont will be used to construct a new priority_queue.

Return            None

Description

This priority_queue() method constructs a queue that contains copies of elements in Cont.

Method             priority_queue()

Access            Public

Classification    Constructor

Syntax            template <class InputIterator> priority_queue(InputIterator first, InputIterator last, const Compare& X = Compare(), const Container&Cont = Container())

Parameters        X is the function object that will be used to order the priority queue.
                  The objects in Cont will be used to construct a new priority_queue.
                  The objects will be from the range[first,last).

Return            None

Description

This priority_queue() method constructs a queue that contains copies of elements in Cont in the range [first,last).


The queue Class

Class Name            queue

Header File           <queue>

Classification      Container
Class Description

Member Classes

None

Methods

reference back()

const_reference back() const

reference front()

const_reference front() const

size_type size() const

void push(const value_type& x)

void pop()

explicit queue(const Container& = Container())

Operators

Class Description

A queue is a front to back ordering whose logical structure looks like a line. In a queue the items are deleted from the front and inserted into the rear of the queue. The queue is known as a FIFO (First In First Out) structure. This means that the first item hat has been inserted will be the first item that will be removed.

Method             queue()

Access            Public

Classification    Constructor

Syntax            explicit queue(const Container &X = Container())

Parameters        X is the container that will be used to construct the queue.

Return            None

Description

This queue() method constructs a queue that contains copies of elements in X.


The out_of_range Class

Class Name            out_of_range

Header File           <stdexcept>

Classification      Exception
Class Relationship Diagram

Class Description

Member Classes

None

Methods

out_of_range(const string &What_Arg)

Example

Class Description

The out_of_range class is derived from the logic_error class. The out_of_range represents exceptions that are occur because some piece of the software component that causes the exception is attempting to use an object as a parameter or a return value that is out of the range of what is expected. The out_of_range exception is another logical content exception similar to the domain_error exception class. In the case of an out_of_range exception some object is attempting to take on an illegal value. What types of values are out of range are class dependent and is determined by context. This class represents a node class and can therefore be used as a base class for user defined classes. Objects of type out_of_range are thrown by methods in the standard C++ class library.

Method            out_of_range()

Access            Public

Classification    Constructor

Syntax            out_of_range(const string &What_Arg)

Parameters        The What_Arg parameter should contain a description of the kind of exception
                  that has occurred.

Return            None

Description

The out_of_range() method constructs an object of type out_of_range. The What_Arg parameter can be used to set a description of the kind of error that this exception represents. A set possible solutions is sometimes supplied with the exception description in addition to the type of error.

The Class Relationship Diagram of out_of_range

    1
    2   #include <stdexcept>
    3
    4
    5   void main(void)
    6   {
    7
    8
    9      try{
   10
   11            exception X;
   12            throw(X);
   13      }
   14      catch(const exception &X)
   15      {
   16          cout << X.what() << endl;
   17
   18      }
   19
   20      try
   21      {
   22          out_of_range RangeError("Length or Range Exception");
   23          throw(RangeError);
   24      }
   25      catch(const exception &X)
   26      {
   27          cout << X.what() << endl;
   28      }
   29
   30
   31
   32   }
   33


reverse_iterator

Class Name            reverse_iterator

Header File          <iterator>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

Iterator current

Methods

Iterator base() const;

reverse_iterator();

explicit reverse_iterator(Iterator x);

Operators

Reference operator*() const;

reverse_operator& operator++();

reverse_operator& operator++(int);

reverse_operator& operator--();

reverse_operator operator--(int);

Pointer operator>() const;

reverse_operator operator+(Distance n) const;

reverse_operator& operator+=(Distance n);

reverse_operator operator-(Distance n) const;

reverse_operator& operator-=(Distance n);

reverse_operator& operator[](Distance n) const;

Class Description

The reverse_iterator is a reverse iterator. The reverse_iterator is an adaptation of a random access iterator. It can traverse through a container in the same manner as a random access iterator but in the reverse direction. Because the reverse iterator traverses in the reverse order, iterator that points to the start of the container (rbegin()) actually points to one element after the last element in the container. In order to avoid this type of violation, the dereference operator decrements that iterator by 1 or current -1. Thus the mapping of this type of iteration with the original sequence with random access iterator i is: &*(reverse_iterator(i)) == &*(i - 1). The incrementation, ++, and decrementation, --, operators perform opposite operations. The incrementation operator decrements the current iterator and the decrementation operator increments the current iterator.

The reverse_iterator meets all of the requirements for the random access iterator therefore, operator+, operator-, operator+=, operator-=, operator[] members are all defined along with the global operators: operator>, operator<, operator>=, operator<=, operator+, and operator-. The -, -= , + , and += operators allows pointer arithmetic to be performed on these iterators.

Iterator current

The random access iterator which points into the container. This iterator is used to determine the current iterator in reverse order.

Method             reverse_iterator()

Access             Public

Classification     Constructor

Syntax             reverse_iterator();

Parameters         None

Returns            None

Description

This constructor constructs a reverse_iterator object.

Method             reverse_iterator()

Access             Public

Classification     Constructor

Syntax             explicit reverse_iterator(Iterator x);

Paramters          x is the random access iterator which points into
                   the container.

Returns            None

Description

This constructor constructs a reverse_iterator object and initializes Iterator current with x.

Method             operator*()

Access             Public

Classification     Accessor

Syntax             reference operator*() const;

Parameters         None

Returns            This operator returns a reference to the iterator.

Description

The dereference operator of a const object makes a copy of Iterator current, decrements the copy and returns a reference to the copy.

Method             operator[]()

Access             Public

Classification     Accessor

Syntax             Reference operator[](Distance n) const;

Parameters         n is a Distance type. It represents the distance between the
                   iterators in the container. It is used as an offset
                   value.

Returns            The operator will return the element that is n distance + 1
                   from the end of the container.

Description

The subscript operator will return the element that is n distance + 1 from the end of the container.

Method             operator++()

Access             Public

Classification     Accessor

Syntax             reverse_iterator& operator++();

Parameters         None

Returns            This operator returns a pointer to the current object.

Description

The pre-incrementation operator decrements Iterator current (--current) and then returns *this.

Method             operator++()

Access             Public

Classification     Accessor

Syntax             reverse_iterator& operator++(int x);

Parameter          x is a dummy argument to distinguish between the
                   postfix and prefix incrementation that is never
                   used.

Returns            This operator returns a pointer to the current object.

Description

The postfix incrementation operator makes a copy of *this, decrements Iterator current (--current) and then returns the copy of *this.

Method             operator--()

Access             Public

Classification     Accessor

Syntax             reverse_iterator& operator--();

Parameters         None

Returns            This operator returns a pointer to the current object.

Description

The pre-decrementation operator increments Iterator current (++current) and then returns *this.

Method             operator--()

Access             Public

Classification     Accessor

Syntax             reverse_iterator& operator--(int x);

Parameters         x is a dummy argument to distinguish between the
                   postfix and prefix incrementation that is never used.

Returns            This operator returns a pointer to the current object.

Description

The postfix decrementation operator makes a copy of *this, increments Iterator current (++current) and then returns the copy of *this.

Method             base()const

Access             Public

Classification     Accessor

Syntax             Iterator base()const;

Parameters         None

Returns            This method returns Iterator current.

Description

The base() method returns Iterator current.

Method             operator+()

Access             Public

Classification     Accessor

Syntax             reverse_iterator operator+(Distance n) const;

Parameters         n is the offset.

Returns            This operator returns &(current - n).

Description

The operator+() decrements n from Iterator current and returns a pointer to this element.

Method             operator+=()

Access             Public

Classification     Modifier

Syntax             reverse_iterator operator+=(Distance n);

Parameters         n is the offset.

Returns            This operator returns &(current -= n).

Description

The operator+() changes the Iterator current by decrementing current by n and returns a pointer to this element.

Method             operator-()

Access             Public

Classification     Accessor

Syntax             reverse_iterator operator(Distance n) const;

Parameters         n is the offset.

Returns            This operator returns &(current + n).

Description

The operator+() increments Iterator current by n and returns a pointer to this element.

Method             operator-=()

Access             Public

Classification     Modifier

Syntax             reverse_iterator operator-=(Distance n);

Parameters         n is the offset.

Returns            This operator returns &(current += n).

Description

The operator+() changes the Iterator current by incrementing current by n and returns a pointer to this element.

Method             operator->()

Access             Public

Classification     Accessor

Syntax             pointer operator->() const;

Parameters         None

Returns type       This operator returns &(operator*()).

Description

This pointer operator of a const object makes a copy Iterator current, decrements the copy and returns a pointer to the copy.

The Class Relationship Diagram for reverse_iterator


The range_error Class

Class Name            range_error

Header File           <stdexcept>

Classification      Exception
Class Relationship Diagram

Class Description

Member Classes

None

Methods

range_error(const string &What_Arg)

Example

Class Description

The range_error class is derived from the runtime_error class. The range_error class represents exceptions that are occur because some piece of the software component that causes the exception is attempting to work with a value that is either to large or to small to represent in the current environment. The value is a legitimate value but beyond the representation capabilities of the current machine. This is in contrast to the out_of_range exception which represents values that are not legitimate for operation they are involved in. This class represents a node class and can therefore be used as a base class for user defined classes.

Method            range_error()

Access            Public

Classification    Constructor

Syntax            range_error(const string &What_Arg)

Parameters        The What_Arg parameter should contain a description of the kind of exception
                  that has occurred.

Return            None

Description

The range_error() method constructs an object of type range_error. The What_Arg parameter can be used to set a description of the kind of error that this exception represents. A set possible solutions is sometimes supplied with the exception description in addition to the type of error.

The Class Relationship Diagram of range_error

    1
    2   #include <stdexcept>
    3
    4
    5   void main(void)
    6   {
    7
    8
    9      try{
   10
   11            exception X;
   12            throw(X);
   13      }
   14      catch(const exception &X)
   15      {
   16          cout << X.what() << endl;
   17
   18      }
   19
   20      try
   21      {
   22          range_error RangeError("Value To Large For Display");
   23          throw(RangeError);
   24      }
   25      catch(const exception &X)
   26      {
   27          cout << X.what() << endl;
   28      }
   29
   30
   31
   32   }
   33


The runtime_error Class

Class Name            runtime_error

Header File          <stdexcept>

Classification      Error Handling (Node Class)
Family of runtime_error Classes

Class Description

Member Classes

None

Methods

runtime_error(const string &What_Arg)

Example

Class Description

The runtime_error family of classes are derived from the exception class. There are three classes derived from runtime_error; range_error, overflow_error, and underflow_error. The runtime_error classes report internal computation or arithmetic errors. The functionality of the runtime_error classes is similar to the logic_error classes. The runtime_error classes get their primary functionality from their exception class ancestor. The what(), assignment operator=(), and the constructors for the exception class provide the capability of the runtime_error classes. Like the logic_error classes, the runtime_error classes provide an exception framework and architectural blueprint to build upon. They provide very little functionality unless the programmer specializes them through inheritance or by including them in an interface class.

Method            runtime_error()

Access            Public

Classification    Constructor

Syntax            runtime_error(const string &What_Arg)

Parameters        The What_Arg parameter should contain a description of the kind of exception
                  that has occurred.

Return            None

Description

The runtime_error() method constructs an object of type runtime_error. The What_Arg parameter can be used to set a description of the kind of error that this exception represents. A set possible solutions is sometimes supplied with the exception description in addition to the type of error.

Family of runtime_error Classes

    1
    2   #include <stdexcept>
    3
    4
    5   void main(void)
    6   {
    7
    8
    9      try{
   10
   11            exception X;
   12            throw(X);
   13      }
   14      catch(const exception &X)
   15      {
   16          cout << X.what() << endl;
   17
   18      }
   19
   20      try
   21      {
   22          runtime_error RuntimeError("Something Occurred During Execution!");
   23          throw(RuntimeError);
   24      }
   25      catch(const exception &X)
   26      {
   27          cout << X.what() << endl;
   28      }
   29
   30
   31
   32   }
   33


The sentry Class

Class Name            sentry

Header File           <sentry>

Classification      sentry
Class Description

Methods

explicit sentry(basic_ostream<charT,traits>& Os)

~sentry()

operator bool()

Description

The sentry class is a class used monitor pre-conditions and post-conditions of an input/output class. The constructor for the sentry class performs exception safe prefix operations. The destructor for the sentry class performs exception safe suffix operations.

Method            sentry

Access            Public

Classification    Constructor

Syntax            explicit sentry(basic_ostream& Os)

Parameters        Os is a reference to the ostream object that requires
                  exception safe prefix or suffix operations.

Return            None

Description

This sentry() method is used to construct an object of type sentry. The sentry() constructor has the effect of calling the opfx() method.

Method            sentry()

Access            Public

Classification    Destructor

Syntax            ~sentry()

Parameters        None

Return            None

Description

This sentry() method is destructs an object of type sentry. The ~sentry() destructor has the effect of calling the osfx() method.

Method            bool()

Access            Public

Classification    Accessor

Syntax            operator bool()

Parameters        None

Return            This method returns the value of ok_.

Description

This bool() method returns the value of the ok_ attribute.


The Common Sequence Container Methods

Class Name        basic_istringstream

Classification    Sequence Containers

Methods

iterator insert(iterator Pos, const T& X = T())

void insert(iterator Pos, size_type Num, const T& x)

template  void insert (iterator Pos, InputIterator First, InputIterator Last)

iterator erase(iterator Pos)

iterator erase(iterator First, iterator Last)

Method            insert()

Access            Public

Classification    Modifier

Syntax            iterator insert(iterator Pos, const T& X = T())

Parameters        X is the object to be inserted before Position Pos.

Return            This method returns an iterator pointing to the inserted
                  object.

Description

This insert() method inserts object X before Position Pos in the container.

Method            insert()

Access            Public

Classification    Modifier

Syntax            void insert(iterator Pos, size_type Num, const T& x)

Parameters        X is the object to be inserted before Position. Num is the
                  number of objects to insert before Position Pos.

Return             None

Description

This insert() method inserts Num  X objects before Position
Pos in the container.

Method            insert()

Access            Public

Classification    Modifier

Syntax            template  void insert (iterator Pos, InputIterator First, InputIterator Last)

Parameters        [First,Last) is the range of objects that will be inserted before
                  Position Pos.

Return             None

Description

This insert() method inserts the objects in the range [First,Last] before position
Pos in the container.

Method            erase()

Access            Public

Classification    Modifier

Syntax            iterator erase(iterator Pos)

Parameters        Pos points to the object to be deleted.

Return            None

Description

This erase() method deletes the object pointed to by Pos.

Method            erase()

Access            Public

Classification    Modifier

Syntax            iterator erase(iterator First, iterator Last)

Parameters        [First,Last) contains the range of objects to
                  be deleted

Return            None

Description

This erase() method deletes the objects in the range [First,Last).


The set Class

Class Name            set

Header File           <set>

Classification      Container
Class Description

Member Classes

None

Methods

iterator begin()

const_iterator begin() const

void clear()

size_type count(const key_type& x) const

bool empty() const

iterator end()

const_iterator end() const

void erase(iterator position)

size_type erase(const key_type& x)

void erase(iterator first, iterator last)

pair<iterator,iterator> equal_range(const key_type& x) const

iterator find(const key_type& x) const

allocator_type get_allocator() const

pair<iterator,bool> insert(const value_type& x)

iterator insert(iterator position, const value_type& x)

template <class InputIterator>void insert(InputIterator first, InputIterator last)

iterator lower_bound(const key_type& x) const

size_type max_size() const

reverse_iterator rbegin()

const_reverse_iterator rbegin() const

reverse_iterator rend()

void resize(size_type Sz, T C = T())

const_reverse_iterator rend() const

explicit set(const Compare& comp = Compare(), const Allocator& = Allocator())

template <class InputIterator> set(InputIterator first, InputIterator last,const Compare& Comp = Compare(), const Allocator&X = Allocator())

set(const set<Key,Compare,Allocator>& X)

~set()

size_type size() const

void swap(set& X)

iterator upper_bound(const key_type& x) const

Operators

set& operator=(const set& x);

Example

Class Description

A set container can be used to represent a collection of people, places, things, or ideas. An important characteristic of sets is that they only allow an object to be included once in the set. That is each element must have a unique key.

Method            swap()

Access            Public

Classification    Modifier

Syntax            void swap(set<Key,Compare,Allocator>& X)

Parameters        X is the set to be swapped with the contents of the current set.

Return            X is the set to be swapped.

Description

The swap() method swaps the contents of the current set with set X.

Method            set()

Access            Public

Classification    Constructor

Syntax            explicit set(const Compare& Comp = Compare(), const Allocator &X = Allocator())

Parameters        Comp is the function object that will be used to order the set.
                   X is a allocator object.

Return            None.

Description

The set() method constructs an empty set container.

Method            set()

Access            Public

Classification    Constructor

Syntax            template <class InputIterator> set(InputIterator first, InputIterator last,const Compare& Comp = Compare(), const Allocator&X = Allocator())

Parameters        elements from the range [first,last) will be used to construct the set. X is a allocator object.
                  Comp is the function object that will be used to order the set.

Return            None.

Description

The set() method constructs a set that contains copies of the objects that are pointed to by the iterators in the range [first,last].

Method            set()

Access            Public

Classification    Constructor

Syntax            set(const set<Key,Compare,Allocator>& X)

Parameters        X is the set that will be used to construct the new set.

Return            None.

Description

The set() method constructs a new set from set X.

Method            set()

Access            Public

Classification    Destructor

Syntax            ~set()

Parameters        None.

Return            None.

Description

The ~set() method destructs a set object.

#include <set>
#include <iostream>
using namespace std;

void main(void)
{
   set<int, less<int> > M;
   M.insert(1960);
   M.insert(1952);
   M.insert(1771);
   M.insert(1812);
   M.insert(1960);
   M.insert(2000);
   set<int, less<int> >::iterator N= M.begin();
   cout << "Number Of Elements " << M.size() << endl;
   while(N != M.end())
   {
             cout << *N << endl;
             N++;
   }
}


The stack Class

Class Name            stack

Header File           <stack>

Classification      Container
Class Description

Member Classes

None

Methods

bool empty() const

size_type size() const

void push(const value_type& x)

void pop()

explicit stack(const Container& = Container())

value_type& top()

const value_type& top() const

Operators

Class Description

Stacks are containers that can hold a arbitrary number of objects. Stacks are dynamic containers. When objects are inserted into a stack the stack's size grows. When objects are removed from a stack the stack size shrinks. The stack is a restricted access container. Objects may only be removed from a stack one at a time. The stack is known as a LIFO (Last In First Out) structure. The first item inserted into a stack is the last item removed, and the last item inserted is the first item removed.

Method             stack

Access            Public

Classification    Constructor

Syntax            explicit stack(const Container &X = Container())

Parameters        X is a container that will be used to construct a new
                  stack object.
Return            None

Description

This stack() method constructs a stack that contains copies of elements in X.


The basic_stringbuf Class

Class Name            basic_stringbuf

Header File           <sstream>

Classification      Input/Output (Format Class)
Class Relationship Diagram

Class Description

Member Classes

none

Methods

explicit basic_stringbuf(ios_base::openmode OMode = ios_base::in | ios_base::out)
explicit basic_stringbuf( const basic_string<charT,traits,Allocator>& Str, ios_base::openmode OMode = ios_base::in | ios_base::out)
virtual int_type pbackfail(int_type c = traits::eof())
virtual int_type overflow (int_type c = traits::eof())
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 sp, ios_base::openmode which = ios_base::in | ios_base::out)
virtual basic_streambuf<charT,traits>* setbuf(charT* Str, streamsize Num)
basic_string<charT,traits,Allocator> str() const
Public void str(const basic_string<charT,traits,Allocator>& s)
Public virtual int_type underflow()

Class Description

The stringbuf component is a specialized basic_streambuf. It is derived from basic_streambuf. The stringbuf component is connected to a character array, as opposed to a file. The source of a stringbuf is intended to be a memory device. The programmer can have direct access to the istringstream/ostringstream memory device through the stringbuf component. The stringbuf component can be reached by the rdbuf() member function. The standard typedef for basic_stringbuf is stringbuf.

Method            basic_stringbuf()

Access            Public

Classification    Constructor

Syntax            explicit basic_stringbuf(ios_base::openmode OMode = ios_base::in | ios_base::out)

Parameters        OMode is the mode that the buffer is opened in.

Return            None

Description

This basic_stringbuf() method constructs an object of basic_stringbuf in mode OMode. A basic_stringbuf object constructed with this method will be initialized with a basic_streambuf object.

Method            basic_stringbuf()

Access            Public

Classification    Constructor

Syntax            explicit basic_stringbuf( const basic_string<charT,traits,Allocator>& Str, ios_base::openmode OMode = ios_base::in | ios_base::out)

Parameters        OMode is the mode that the buffer is opened in. Str is a character buffer that will
                  be used to initialize the stringbuf object.

Return            None

Description

This basic_stringbuf() method constructs an object of basic_stringbuf in mode OMode. A basic_stringbuf object constructed with this method will be initialized with the character buffer referred to by Str.

Method            setbuf()

Access            Protected

Classification    Accessor

Syntax            virtual basic_streambuf<charT,traits>* setbuf(charT* Str, streamsize Num)

Parameters        Str points to a Str that a new buffer for the stringbuf object.  Num is the
                  size in characters the buffer can hold

Return            This method returns the *this pointer for the stringbuf object.

Description

The setbuf() method updates the buffer for the stringbuf object. setbuf(0,0) has no effect for a stringbuf object.

The Class Relationship Diagram of basic_stringbuf


The basic_streambuf Class

Class Name            basic_streambuf

Header File           <streambuf>

Classification      Input/Output (Format Class)
Class Relationship Diagram

Class Description

Member Classes

locale

Methods

basic_streambuf()

virtual ~basic_streambuf()

char_type* eback() const

char_type* egptr() const

char_type* epptr() const

void gbump(int Num)

locale getloc() const

char_type* gptr() const

virtual void imbue(const locale & Loc)

virtual int_type overflow (int_type c = traits::eof())

virtual int_type pbackfail(int_type CharValue = traits::eof())

char_type* pbase() const

void pbump(int Num)

char_type* pptr() const

locale pubimbue(const locale & Loc)

basic_streambuf<char_type,traits>* pubsetbuf(char_type* Str, streamsize Num)

int pubsync()

int_type sbumpc()

virtual pos_type seekoff(off_type off, ios_base::seekdir way, protected 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 basic_streambuf<char_type,traits>* setbuf(char_type* s, streamsize n)

void setg(char_type* Gb, char_type* Gnext, char_type* Gend)

void setp(char_type* Pb, char_type* Pend)

int_type sgetc()

streamsize sgetn(char_type* Str, streamsize Num)

virtual int showmanyc()

int_type snextc()

int_type sputbackc(char_type CharValue)

int_type sputc(char_type CharValue)

streamsize sputn(const char_type* Str, streamsize Num)

int_type sungetc()

virtual int sync()

virtual int_type uflow()

virtual int_type underflow()

virtual streamsize xsgetn(char_type* Str, streamsize Num)

virtual streamsize xsputn(const char_type* s, streamsize n)

Class Description

The basic_streambuf class is the base class for basic_filebuf and basic_stringbuf. The basic_streambuf class has methods that get bytes, put bytes, skip bytes, put bytes back etc,. The basic_streambuf class has the functionality that controls what happens with stream overflow, or stream underflow conditions. The basic_streambuf class is contained as a data member of one of the other iostream classes. For instance, the basic_ios class usually contains a basic_streambuf data member. Positioning is another responsibility of the basic_streambuf class. The basic_streambuf family of classes control the movement of a get pointer and put pointer. The get pointer points to the next byte to read, assigned or viewed. The put pointer points to the next byte to be written, assigned, assigned or viewed.

The class basic_streambuf can be physically described as a set of memory areas with a number of protected methods that define the behavior of the memory areas. The areas that make up the buffer are the reserve, put, and get areas. The reserve area is normally a fixed block of memory used as a memory resource by the other areas. The other two areas overlap (partially or fully) the reserve area but never meet each other. The get area could be divided into two areas: the get and put back areas. At least two flags indicate whether the reserve area exists and if it is owned by basic_streambuf. The get and put areas are managed by a set of pointers. Each area is assigned three pointers. The basic_streambuf object has a typdef that allows the user to specify a basic_streambuf class through the use of the name streambuf.

Method            basic_streambuf()

Access            Protected

Classification    Constructor

Syntax            basic_streambuf()

Parameters        None

Return Type       None

Description

This basic_streambuf() method constructs a basic_streambuf object by setting all its pointers to NULL and setting locale object to the global locale.

Method            basic_streambuf()

Access            Public

Classification    Destructor

Syntax            virtual ~basic_streambuf()

Parameters        None

Return Type       None

Description

This basic_streambuf() method destructs an object of type basic_streambuf.

Method            eback()

Access            Protected

Classification    Accessor

Syntax            char_type* eback() const

Parameters        None

Return            This method returns a pointer to the beginning of the
                  input area.

Description

The eback() method returns a pointer to the beginning of the input buffer/area.

Method            egptr()

Access            Protected

Classification    Accessor

Syntax            char_type* egptr() const

Parameters        None

Return            This method returns a pointer to the end of the
                  input area.

Description

The eback() method returns a pointer to the end of the input area.

Method            epptr()

Access            Protected

Classification    Accessor

Syntax            char_type* epptr() const

Parameters        None

Return            This method returns a pointer to the end of the
                  output area.

Description

The epptr() method returns a pointer to the end of the output buffer/area.

Method            gbump()

Access            Public

Classification    Modifier

Syntax            void gbump(int Num);

Parameters        Num is the position to advance the next pointer

Return            None

Description

The gbump() method is used to advance the pointer to the next character in the input buffer/area by the value of Num.

Method            gptr()

Access            Protected

Classification    Accessor

Syntax            char_type* gptr() const

Parameters        None

Return            This method returns the next pointer for the input area.

Description

The gptr() method returns the next pointer for the input area/buffer.

Method            imbue()

Access            Protected

Classification    Modifier

Syntax            virtual void imbue(const locale & Loc);

Parameters        Loc is a locale object

Return            None

Description

This imbue() method is virtual and is meant to be overridden in a derived class. This imbue() method is only a place holder.

Method            overflow()

Access            Protected

Classification    Modifier

Syntax            virtual int_type overflow (int_type CharValue = traits::eof())

Parameters        CharValue is the character that will be sent to some destination after
                  making room for it.

Return            This method returns a value not equal to traits::eof() if it
                  was successful otherwise it returns traits::eof(). It may
                  throw an exception if unsuccessful.

Description

The overflow() method can flush a buffer, expand a block of memory, and send characters to some output device in attempt to output or make room for its argument. When there is no more room in the put area for a character or sequence the overflow() method is called. The overflow() method is designed to be overridden in a derived class.

Method            pbackfail()

Access            Protected

Classification    Modifier

Syntax            virtual int_type pbackfail(int_type CharValue = traits::eof())

Parameters        CharValue is the character that will be placed back into the
                  input buffer.

Return            This method returns a value not equal to traits::eof() if it
                  was successful otherwise it returns traits::eof().

Description

If the pbackfail() method is successful the Character CharValue will have been placed back into the input area. The effect of this method is to backup the input sequence one character.

Method            pbase()

Access            Protected

Classification    Accessor

Syntax            char_type* pbase() const

Parameters        None

Return            This method returns a pointer to the beginning of the
                  output buffer.

Description

The pbase() method returns a pointer to the beginning of the output area/buff.

Method            pbump()

Access            Protected

Classification    Accessor

Syntax            void pbump(int Num)

Parameters        Num is the number that the next point is advanced

Return            None

Description

The pbump() method moves the next pointer of the output area by the value of Num. The next pointer determines where the next output location will be. basic_streambuf<char_type,traits>* pubsetbuf(char_type* s, streamsize n); The pptr() method returns the next pointer for the output buffer/area.

Method            pubimbue()

Access            Public

Classification    Modifier

Syntax            locale pubimbue(const locale & Loc)

Parameters        Loc is a locale object that will be assigned to the
                  basic_streambuf object.

Return            This method returns the locale object that was in effect
                  prior to the assignment of Loc. If this is the first time
                  pubimbue() has been called for the this basic_streambuf
                  object then pubimbue() will return the global locale object
                  that is in effect.

Description

The pubimbue() method updates the locale object of the streambuf object.

Method            pubsetbuf()

Access            Public

Classification    Modifier

Syntax            basic_streambuf<char_type,traits>* pubsetbuf(char_type* Str, streamsize Num);

Parameters        Str is a streambuf character. Num is a value used to effect the update of
                  the associated buffer object.

Return            This method returns a pointer to this basic_streambuf object.

Description

This virtual pubsetbuf() is designed to be overridden in a derived class such as basic_filebuf, or stringbuf. It serves only as a place holder in the basic_streambuf class.

Method            pubsync()

Access            Public

Classification    Accessor

Syntax            int pubsync();

Parameters        None

Return            This method will return 0 if successful and -1 on failure.

Description

The pubsync() method simply returns the sync() method. The sync() method synchronizes the controlled sequences with the internal arrays or streams. In many cases the behavior is to flush the buffer area to the connected output device.

Method            sbumpc()

Access            Public

Classification    Modifier

Syntax            int_type sbumpc();

Parameters        None

Return            This method returns a value not equal to traits::eof() if it
                  was successful otherwise it returns traits::eof().

Description

It returns the current character in the input stream or traits::eof(). If the call to this method is successful it moves the get pointer forward by one value.

Method            seekoff()

Access            Protected

Classification    Modifier

Syntax            virtual pos_type seekoff(off_type Off, ios_base::seekdir Way, protected ios_base::openmode which = ios_base::in | ios_base::out)

Parameters        Way is can be

                                      ios_base::beg
                                      ios_base::cur
                                      ios_base::end

                  Off is the number of positions to move relative to Way

                  Which is the open mode of the streambuf object.

Return            This method returns an invalid stream position for the streambuf object.

Description

The seekoff() method moves to a new position in the stream relative to Way by a value of Off. This virtual method is designed to be overridden in a derived class. The seekoff() method usually returns an invalid stream position for the streambuf object.

Method            seekpos()

Access            Protected

Classification    Modifier

Syntax            virtual pos_type seekpos(pos_type Pos, ios_base::openmode Which = ios_base::in | ios_base::out)

Parameters        Pos is the new position in the stream.  Which is the open mode of the
                  stream.

Return            This method returns an invalid stream position for the streambuf object.

Description

The seekpos() method moves to a new position in the stream. This virtual method is designed to be overridden in a derived class. The seekpos() method usually returns an invalid stream position for the streambuf object.

Method            setbuf()

Access            Public

Classification    Modifier

Syntax            virtual basic_streambuf<char_type,traits>* setbuf(char_type* S, streamsize N)

Parameters        S is a streambuf character. N is a value used to effect the update of
                  the associated buffer object.

Return            This method returns a pointer to this basic_streambuf object.

Description

This virtual setbuf() is designed to be overridden in a derived class such as basic_filebuf, or stringbuf. It serves only as a place holder in the basic_streambuf class.

Method            setg()

Access            Protected

Classification    Modifier

Syntax            void setg(char_type* Gb, char_type* Gnext, char_type* Gend)

Parameters        Gb will be used to update the beginning input area pointer. Gnext
                  will be used to update the next pointer for the input area. Gend
                  will be used to update the pointer that is pointing to the end
                  of the input area.

Return            None

Description

The setg() method updates the pointers to the input buffer. The beginning pointer is set to Gb. The next pointer is set to Gnext and the end pointer is set to Gend.

Method            setp()

Access            Protected

Classification    Modifier

Syntax            void setp(char_type* Pb, char_type* Pend);

Parameters        Pb will be used to update the beginning output area pointer. Pend
                  will be used to update the pointer that is pointing to the end
                  of the output area.

Return            None

Description

The setp() method updates the pointers to the output buffer. The beginning pointer is set to Pb. The end pointer is set to Pend.

Method            sgetc()

Access            Public

Classification    Accessor

Syntax            int_type sgetc();

Parameters        None

Return            This method returns a value not equal to traits::eof() if it
                  was successful otherwise it returns traits::eof().

Description

The sgetc() method returns the next character in the input stream(if there is one) otherwise it returns traits::eof().

Method            sgetn()

Access            Public

Classification    Modifier

Syntax            streamsize sgetn(char_type* Str, streamsize Num)

Parameters        Str is the starting location for a sequence of characters that will
                  be assigned to the streambuf object.  Num is the number of characters
                  that will be assigned to the streambuf object.

Return            This method returns the number of characters inserted into the
                  buffer.

Description

The sgetn() method does its work by calling xsgetn(). The xsgetn() method inserts Num characters into the buffer area beginning at the location pointed to by Str. It will continue to insert characters until Num characters have been exhausted or until traits::eof() has been reached.

Method            showmanyc()

Access            Protected

Classification    Accessor

Syntax            virtual int showmanyc();

Parameters        None

Return            This method will return -1 if there are no characters to extract or
                  an estimation of the least number of characters that can be extracted.

Description

The showmanyc() method returns an estimate of the number of characters in the input area that can be extracted. However, this method is a virtual method as is designed to be overridden in a derived class. The default behavior for this class is for showmanyc() to return 0.

Method            snextc()

Access            Public

Classification    Modifier

Syntax            int_type snextc();

Parameters        None

Return            This method returns a value not equal to traits::eof() if it
                  was successful otherwise it returns traits::eof().

Description

It returns the current character in the input stream or traits::eof(). If the call to this method is successful it moves the get pointer forward by one value.

Method            sputbackc()

Access            Public

Classification    Modifier

Syntax            int_type sputbackc(char_type CharValue);

Parameters        CharValue is the character to put back into the input
                  stream.

Return            This method returns pbackfail()

Description

The sputbackc() method() attempts to place CharValue back into the input stream. Upon success this method will return gptr() upon failure it returns pbackfail().

Method            sputc()

Access            Public

Classification    Modifier

Syntax            int_type sputc(char_type CharValue);

Parameters        CharValue is the character to put into the output
                  stream.

Return            This method returns xsputn()

Description

The sputc() method inserts CharValue into the output stream.

Method            sputn()

Access            Public

Classification    Modifier

Syntax            streamsize sputn(const char_type* Str, streamsize Num)

Parameters        Str is the beginning of the sequence of elements to be inserted into
                  the output stream.  Num is the number of elements to be inserted into
                  the output stream.

Return            This method returns xsputn()

Description

The sputn() method inserts up to Num elements into the output stream.

Method            sungetc()

Access            Public

Classification    Modifier

Syntax            int_type sungetc();

Parameters        None

Return            This method returns either a pointer to the current element or
                  pbackfail()

Description

The sungetc() method decrements the next pointer for the input buffer if possible.

Method            sync()

Access            Protected

Classification    Accessor

Syntax            virtual int sync()

Parameters        None

Return            This method will return 0 if successful and -1 on failure.

Description

The sync() method synchronizes the controlled sequences with the internal arrays or streams. In many cases the behavior is to flush the buffer area to the connected output device.

Method            uflow()

Access            Protected

Classification    Modifier

Syntax            virtual int_type uflow()

Parameters        None

Return

Description

calls underflow()

Method            underflow()

Access            Protected

Classification    Modifier

Syntax            virtual int_type underflow()

Parameters        None

Return            This method returns the current element of the input stream on success
                  otherwise traits::eof()

Description

The underflow() method attempts to get more characters from the source or input stream. This method is virtual and is designed to be overridden in a derived class. It will be have differently based on the type of input stream it is connected to. The default behavior of this method is to return traits::eof().

Method            xsgetn()

Access            Protected

Classification    Modifier

Syntax            virtual streamsize xsgetn(char_type* Str, streamsize Num)

Parameters        Str is the starting location for a sequence of characters that will
                  be assigned to the streambuf object.  Num is the number of characters
                  that will be assigned to the streambuf object.

Return            This method returns the number of characters inserted into the
                  buffer.

Description

The xsgetn() method inserts Num characters into the buffer area beginning at the location pointed to by Str. It will continue to insert characters until Num characters have been exhausted or until traits::eof() has been reached.

Method            xsputn()

Access            Protected

Classification    Modifier

Syntax            virtual streamsize xsgetn(char_type* Str, streamsize Num)

Parameters        Str is the beginning of the sequence of elements to be inserted into
                  the output stream.  Num is the number of elements to be inserted into
                  the output stream.

Return            This method returns the number of characters inserted into the
                  output stream.

Description

The Xsputn() method inserts up to Num elements into the output stream.

The Class Relationship Diagram of streambuf


basic_string

Class Name            basic_string

Header File          <string>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

None

Methods

basic_string& append(const basic_string& str);

basic_string& append(const basic_string& str, size_type pos,
size_type n);

basic_string& append(const charT* s, size_type n);

basic_string& append(const charT* s);

basic_string& append(size_type n, charT c);

template
basic_string& append(InputIterator first, InputIterator last);

basic_string& assign(const basic_string&);

basic_string& assign(const basic_string& str, size_type pos,
size_type n);

basic_string& assign(const charT* s, size_type n);

basic_string& assign(const charT* s);

basic_string& assign(size_type n, charT c);

template
basic_string& assign(InputIterator first, InputIterator last);

reference at(size_type pos);

const_reference at(size_type pos) const;

explicit basic_string(const Allocator& a = Allocator());

basic_string(const basic_string& str, size_type pos = 0,
size_type n = npos, const Allocator& a = Allocator());

basic_string(const charT* s, size_type n,
const Allocator& a =Allocator());

basic_string(const charT* s, const Allocator& a = Allocator());

basic_string(size_type n, charT c, const Allocator& a = Allocator());

templatebasic_string(InputIterator begin, InputIterator end, const Allocator& a = Allocator());

~basic_string();

iterator begin();

const_iterator begin() const;

const charT* c_str() const;

size_type capacity() const;

void clear();

int compare(const basic_string& str) const;

int compare(size_type pos1, size_type n1,
const basic_string& str) const;

int compare(size_type pos1, size_type n1, const basic_string& str,
size_type pos2, size_type n2) const;

int compare(const charT* s) const;

int compare(size_type pos1, size_type n1,
const charT* s, size_type n2 = npos) const;

size_type copy(charT* s, size_type n, size_type pos = 0) const;

const charT* data() const;

bool empty() const;

iterator end();

const_iterator end() const;

basic_string& erase(size_type pos = 0, size_type n = npos);

iterator erase(iterator position);

iterator erase(iterator first, iterator last);

size_type find(const basic_string& str, size_type pos = 0) const;

size_type find(const charT* s, size_type pos, size_type n) const;

size_type find(const charT* s, size_type pos = 0) const;

size_type find(charT c, size_type pos = 0) const;

size_type find_first_not_of(const basic_string& str,
size_type pos = 0) const;

size_type find_first_not_of(const charT* s, size_type pos,
size_type n) const;

size_type find_first_not_of(const charT* s, size_type pos = 0) const;

size_type find_first_not_of(charT c, size_type pos = 0) const;

size_type find_first_of(const basic_string& str,
size_type pos = 0) const;

size_type find_first_of(const charT* s, size_type pos,
size_type n) const;

size_type find_first_of(const charT* s, size_type pos = 0) const;

size_type find_first_of(charT c, size_type pos = 0) const;

size_type find_last_not_of (const basic_string& str,
size_type pos = npos) const;

size_type find_last_not_of (const charT* s, size_type pos,
size_type n) const;

size_type find_last_not_of (const charT* s,
size_type pos = npos) const;

size_type find_last_not_of (charT c, size_type pos = npos) const;

size_type find_last_of (const basic_string& str,
size_type pos = npos) const;

size_type find_last_of (const charT* s, size_type pos,
size_type n) const;

size_type find_last_of (const charT* s, size_type pos = npos) const;

size_type find_last_of (charT c, size_type pos = npos) const;

allocator_type get_allocator() const;

basic_string& insert(size_type pos1, const basic_string& str);

basic_string& insert(size_type pos1, const basic_string& str,
size_type pos2, size_type n);

basic_string& insert(size_type pos, const charT* s, size_type n);

basic_string& insert(size_type pos, const charT* s);

basic_string& insert(size_type pos, size_type n, charT c);

iterator insert(iterator p, charT c = charT());

void insert(iterator p, size_type n, charT c);

template
void insert(iterator p, InputIterator first, InputIterator last);

size_type length() const;

size_type max_size() const;

reverse_iterator rbegin();

const_reverse_iterator rbegin() const;

reverse_iterator rend();

const_reverse_iterator rend() const;

basic_string& replace(size_type pos1, size_type n1,
const basic_string& str);

basic_string& replace(size_type pos1, size_type n1,
const basic_string& str, size_type pos2, size_type n2);

basic_string& replace(size_type pos1, size_type n1, const charT* s,
size_type n2);

basic_string& replace(size_type pos1, size_type n1, const charT* s);

basic_string& replace(size_type pos, size_type n1, size_type n2,
charT c);

basic_string& replace(iterator i1, iterator i2,
const basic_string& str);

basic_string& replace(iterator i1, iterator i2, const charT* s,
size_type n);

basic_string& replace(iterator i1, iterator i2, const charT* s);

basic_string& replace(iterator i1, iterator i2, size_type n, charT c);

template
basic_string& replace(iterator i1, iterator i2,
InputIterator j1, InputIterator j2);

void reserve(size_type res_arg = 0);

void resize(size_type n, charT c);

void resize(size_type n);

size_type rfind(const basic_string& str, size_type pos = npos) const;

size_type rfind(const charT* s, size_type pos, size_type n) const;

size_type rfind(const charT* s, size_type pos = npos) const;

size_type rfind(charT c, size_type pos = npos) const;

size_type size() const;

basic_string substr(size_type pos = 0, size_type n = npos) const;

void swap(basic_string&);

Operators

basic_string& operator+=(const basic_string& str);

basic_string& operator+=(const charT* s);

basic_string& operator+=(charT c);

basic_string& operator=(const basic_string& str);

basic_string& operator=(const charT* s);

basic_string& operator=(charT c);

const_reference operator[](size_type pos) const;

reference operator[](size_type pos);

Example

Class Description

A template class that describes an object that stores a sequence of varying length characters. The characters can be of an arbitrary char-like objects. The first object in the sequence is at position zero. The storage for basic_string will be allocated and freed by the member functions. The basic_string class supports random access iterators.

Method             operator+=()

Access             Public

Classification     Operator

Syntax             basic_string& operator+=(const basic_string& str);

Parameters         str contains the character sequence that is
                   to be appended to the character sequence of the
                   calling object.

Returns            This operator returns a pointer to the calling object.

Description

The operator+=() appends basic_string str's character sequence to the character sequence of the current object. The operator returns *this.

Method             operator+=()

Access             Public

Classification     Operator

Syntax             basic_string& operator+=(const charT* s);

Parameters         s points to a character array that is to be
                   appended to the character sequence of the calling object.

Returns            This operator returns a pointer to the calling object.

Description

The operator+=() appends the character array pointed to by s to the character sequence of the current object. The operator returns *this.

Method             operator+=()

Access             Public

Classification     Operator

Syntax             basic_string& operator+=(charT c);

Parameters         c is the character to be appended to the
                   character sequence of the calling object.

Returns            This operator returns a pointer to the calling object.

Description

The operator+=() appends the character c to the character sequence of the current object. The operator returns *this.

Method             operator=()

Access             Public

Classification     Assignment Operator

Syntax             basic_string& operator=(const basic_string& str);

Parameters         str is the basic_string to be assigned to the
                   current object.

Returns            This operator returns a pointer to the calling object.

Description

The operator=() assigns basic_string str to the current object. The operator returns *this.

Method             operator=()

Access             Public

Classification     Assignment Operator

Syntax             basic_string& operator=(const charT* s);

Parameters         s points to a character array that is assigned to
                   the character sequence of the calling object.

Returns            This operator returns a pointer to the calling object.

Description

The operator=() assigns the character array pointed to by s to the character sequence of the current object. This method returns *this.

Method             operator=()

Access             Public

Classification     Assignment Operator

Syntax             basic_string& operator=(charT c);

Parameters         c is the character to be assigned to the
                   character sequence of the current object.

Returns            This method returns a pointer to the calling object.

Description

The operator=() assigns the character c to the character sequence of the current object. The operator returns *this.

Method             operator[]

Access             Public

Classification     Subscript Operator

Syntax             const_reference operator[](size_type pos) const;

Parameters         pos is an index of the character sequence of the
                   current object.

Returns            This operator returns a const reference to a
                   character in the sequence.

Description

The operator[] returns the const reference to the character at position pos. If pos == size() then traits::eos() is returned. The reference will be invalid after any subsequent calls to c_str(), data() or any non-const member functions for the object.

Method             operator[]

Access             Public

Classification     Subscript Operator

Syntax             reference operator[](size_type pos);

Parameters         pos is an index of the character sequence of the
                   current object.

Returns            This operator returns a reference to a character
                   in the sequence.

Description

The operator[] returns the reference to the character at position pos. If pos == size() then traits::eos() is returned. The reference will be invalid after any subsequent calls to c_str(), data() or any non-const member functions for the object.

Method             append()

Access             Public

Classification     Modifier

Syntax             basic_string& append(const basic_string& str);

Parameters         str contains the character sequence that is to be
                   appended to the character sequence of the current
                   object.

Returns            This method returns a reference to a basic_string
                   object initialized with the new character sequence.

Description

This append() method appends the basic_string str's character sequence to the current object's character sequence. A basic_string object initialized with the new string is returned. An exception out_of_range is thrown if pos > str.size(). An exception length_error is thrown if length of new string is greater than npos.

Method             append()

Access             Public

Classification     Modifier

Syntax             basic_string& append(const basic_string& str,
                                        size_type pos,
                                        size_type n);

Parameters         str contains the character sequence to be appended
                   to the character sequence of the current object.

                   pos is the starting position to the sequence of the
                   basic_string str that is to be appended to the
                   current object's character sequence.

                   n is the length of the appending sequence.

Returns            This method returns a reference to a basic_string
                   object initialized with the new character sequence.

Description

This append() method appends the basic_string str's character sequence starting at position pos with a length of n to the current object's character sequence. A basic_string object initialized with the new string is returned. An exception out_of_range is thrown if pos > str.size(). An exception length_error is thrown if length of new string is greater than npos.

Method             append()

Access             Public

Classification     Modifier

Syntax             basic_string& append(const charT* s, size_type n);

Parameters         s points to a character array that is appended to
                   the character sequence of the calling object.

                   n is the length of the appending sequence.

Returns            This method returns a reference to a basic_string
                   object initialized with the new character sequence.

Description

This append() method appends the character array pointed to by s with a length of n to the current object's character sequence. A basic_string object initialized with the new string is returned. An exception out_of_range is thrown if pos > str.size(). An exception length_error is thrown if length of new string is greater than npos.

Method             append()

Access             Public

Classification     Modifier

Syntax             basic_string& append(const charT* s);

Parameters         s points to a character array that is appended to
                   the character sequence of the calling object.s

Returns            This method returns a reference to a basic_string
                   object initialized with the new character sequence.

Description

This append() method appends the character array pointed to by s to the current object's character sequence. A basic_string object initialized with the new string is returned. An exception out_of_range is thrown if pos > str.size(). An exception length_error is thrown if length of new string is greater than npos.

Method             append()

Access             Public

Classification     Modifier

Syntax             basic_string& append(size_type n, charT c);

Parameters         n is the number of characters to be appended.

                   c is the character to be appended to the
                   character sequence of the current object.

Returns            This method returns a reference to a basic_string
                   object initialized with the new character sequence.

Description

This append() method appends n number of the character c to the current object's character sequence. A basic_string object initialized with the new string is returned. An exception out_of_range is thrown if pos > str.size(). An exception length_error is thrown if length of new string is greater than npos.

Method             append()

Access             Public

Classification     Modifier

Syntax             template
                   basic_string& append(InputIterator first,
                                        InputIterator last);

Parameters         first points to the beginning of a character
                   range.

                   last points to the end of a character range.

Returns            This method returns a reference to a basic_string
                   object initialized with the new character sequence.

Description

This append() method is a template function that appends a range specified by the input iterators first and last to the current object's character sequence. A basic_string object initialized with the new string is returned. An exception out_of_range is thrown if pos > str.size(). An exception length_error is thrown if length of new string is greater than npos.

Method             assign()

Access             Public

Classification     Modifier

Syntax             basic_string& assign(const basic_string& str);

Parameters         str is the basic_string object to be assigned
                   to the current object.

Returns            This method returns a pointer to the calling object.

Description

This assign() method assigns the character sequence of the basic_string str to the character sequence of the current object. The method returns *this.

Method             assign()

Access             Public

Classification     Modifier

Syntax             basic_string& assign(const basic_string& str,
                                        size_type pos,
                                        size_type n);

Parameters         str is the basic_string object to be assigned
                   to the current object.

                   pos is the starting position to the sequence of the
                   basic_string str that is to be assigned to the
                   current object's character sequence.

                   n is the length of the sequence to be assigned.

Returns            This method returns a pointer to the calling object.

Description

This assign() method assigns the basic_string str's character sequence starting at position pos with a length of n to the current object's character sequence. The method returns *this. An exception out_of_range is thrown if pos > str.size().

Method             assign()

Access             Public

Classification     Modifier

Syntax             basic_string& assign(const charT* s,
                                        size_type n);

Parameters         s points to a character array that is assigned to
                   the character sequence of the calling object.

                   n is the length of the sequence to be assigned.

Returns            This method returns a pointer to the calling object.

Description

This assign() method assigns the character array pointed to by s with a length of n to the current object's character sequence. This method returns *this.

Method             assign()

Access             Public

Classification     Modifier

Syntax             basic_string& assign(const charT* s);

Parameters         s points to a character array that is assigned to
                   the character sequence of the calling object.

Returns            This method returns a pointer to the calling object.

Description

This assign() method assigns the character array pointed to by s to character sequence of the current object. The method returns *this.

Method             assign()

Access             Public

Classification     Modifier

Syntax             basic_string& assign(size_type n, charT c);

Parameters         n is the number of characters to be assigned.

                   c is the character to be assigned to the
                   character sequence of the current object.

Returns            This method returns a pointer to the calling object.

Description

This assign() method assigns n number of the character c to the current object's character sequence. The method returns *this.

Method             assign()

Access             Public

Classification      Modifier

Syntax             template<class InputIterator>
                    basic_string& assign(InputIterator first,
                                           InputIterator last);

Parameters         first points to the beginning of a character
                   range.

                   last points to the end of a character range.

Returns            This method returns a pointer to the calling object.

Description

This assign() method is a template function that assigns a range specified by the input iterators first and last to the current object's character sequence. The method return *this. An exception out_of_range is thrown if pos > str.size().

Method             at()

Access             Public

Classification     Accessor

Syntax             const_reference at(size_type pos) const;

Parameters         pos is a position in the sequence of the current
                   object.

Returns            This method returns a const reference to the
                   character at position pos.

Description

This at() method returns the const reference to the character at position pos. This is equivalent to operator[](pos). It requires pos < size(). An exception out_of_range is returned if pos >= size().

Method             at()

Access             Public

Classification     Accessor

Syntax             reference at(size_type pos);

Parameters         pos is a position in the character sequence of
                   the current object.

Returns            This method returns a reference to the character at
                   position pos.

Description

This at() method returns the reference to the character at position pos. This is equivalent to operator[](pos). It requires pos < size(). An exception out_of_range is returned if pos >= size().

Method             basic_string()

Access             Public

Classification     Constructor

Syntax             explicit basic_string(const Allocator& a = Allocator())

Parameter          a has a default value Allocator().

Returns            None

Description

This is the default constructor. This explicit constructor constructs a basic_string object with a single argument. This means the constructor is only invoked when the argument type matches the parameter type exactly. The compiler will not perform any type conversion. The Allocator object has a default value.

After construction:

     data() returns a non-null pointer; 0 can be added to it.

     size() returns 0.

     capacity() returns an unspecified value.

Method             basic_string()

Access             Public

Classification     Constructor

Syntax             basic_string(const basic_string& str,
                                size_type pos = 0,
                                size_type n = npos,
                                const Allocator& a = Allocator())

Parameters         str is a basic_string object in which the current
                   object is initialized.

                   pos is a position in the character sequence of str.

                   n is the length of the character sequence of str
                   to be assigned to the new object.

                   a has a default value Allocator().

Returns            None

Description

This constructor constructs a basic_string object and initializes the basic_string object with another basic_string object str. pos has a default value of 0. pos has to be less than or equal to str.size(). n has a default value of npos. npos is initialized to the largest possible value. pos and n determines the character sequence to be copied into the new string object. The length of the sequence is the smaller of n and str.size() - pos. The allocator object has a default value Allocator(). This constructor throws an exception out-of-range is pos > str.size().

After construction:

                   data() returns a pointer that points to the first
                   element of an allocated copy of strlength
                   consecutive elements of the string controlled by
                   str beginning at position pos.

                   size() returns strlength which is the smaller of
                   n and str.size() - pos.

                   capacity() returns a value at least as large as
                   size().

                   get_allocator() returns str.get_allocator().

Method             basic_string()

Access             Public

Classification     Constructor

Syntax             basic_string(const charT* s,
                                size_type n,
                                const Allocator& a = Allocator());

Parameters         s points to the character array to be copied
                   to the new object.

                   n is the length of the character sequence.

                   a has a default value Allocator().

Returns            None

Description

This constructor constructs a basic_string object and initializes the basic_string object with the array of charT pointed to by s, the first element in the array. s is not be a null pointer. The length of the string is determined by n. n is less than npos. The allocator object has a default value Allocator(). This constructor throws an exception out_of_range if n == npos.

After construction:

                   data() returns a pointer that points to the first
                   element of an allocated copy of the array whose
                   first element is pointed to by s.

                   size() returns n.

                   capacity() returns a value at least as large as
                   size().

Method             basic_string()

Access             Public

Classification     Constructor

Syntax             basic_string(const charT* s,
                                const Allocator& a = Allocator());

Parameters         s points to the character array to be copied
                   to the new object.

                   a has a default value Allocator().

Returns            None

Description

This constructor constructs a basic_string object and initializes the basic_string object with the array of charT pointed to by s, the first element in the array. s is not be a null pointer. The length of the string is determined by traits::length(s). The allocator object has a default value Allocator().

After construction:

                   data() returns a pointer that points to the first
                   element of an allocated whose first element is pointed
                   to by s.

                   size() returns traits::length(s).

                   capacity() returns a value at least as large as size().

Method             basic_string()

Access             Public

Classification     Constructor

Syntax             basic_string(size_type n,
                                charT c,
                                const Allocator& a = Allocator());

Parameters         n is the number of characters to be copied to the
                   new object.

                   c is the character to be copied.

                   a has a default value Allocator().

Returns            None

Description

This constructor constructs a basic_string object and initializes the basic_string object with the charT c repeated n times. n is less than npos. The allocator object has a default value Allocator(). This constructor throws an exception length_error if n == npos.

After construction:

                   data() returns a pointer that points to the first
                   element of an allocated copy of the array whose
                   first element is pointed to by str.data().

                   size() returns str.size().

                   capacity() returns a value at least as large as
                   size().

Method             basic_string()

Access             Public

Classification     Constructor

Syntax             template <class InputIterator>
                     basic_string(InputIterator begin, InputIterator end,
                                  const Allocator& a = Allocator());

Parameters         begin points to the beginning of a character
                   range.

                   end points to the end of a character range.

                   a has a default value Allocator().

Returns            None

Description

A template constructor that constructs a basic_string object and initializes the basic_string object with the values determined by the range [begin, end). The length of the string is determined by the distance between begin and end. The allocator object has a default value Allocator().

After construction:

                   data() returns a pointer that points to the first
                   element of an allocated copy of the elements in
                   the range [begin, end).

                   size() returns the distance between begin and end.

                   capacity() returns a value at least as large as
                   size().

Method             basic_string()

Access             Public

Classification     Destructor

Syntax             ~basic_string();

Parameters         None

Returns            None

Description

The ~basic_string() destroys the basic_string object.

Method             begin()

Access             Public

Classification     Accessor

Syntax             iterator begin();

Parameters         None

Returns            This method returns an iterator that points to the
                   first element of the current object's character
                   sequence.

Description

This begin() method returns an iterator that points to the first element of the basic_string object's character sequence.

Method             begin()

Access             Public

Classification     Accessor

Syntax             const_iterator begin() const;

Parameters         None

Returns            This method returns a const iterator that points
                   to the first element of the current object's
                   character sequence.

Description

This begin() method returns a const iterator that points to the first element of the basic_string object's character sequence.

Method             c_str()

Access             Public

Classification     Accessor

Syntax             const charT* c_str() const;

Parameters         None

Returns            This method returns a pointer to a the first
                   element of an array which represents the
                   character sequence of the current object.

The c_str() method returns a pointer of type const charT that points to the first element of an array whose length is size() + 1. The first size() elements are equal in correspondence to the elements of the string controlled by *this and the last element is a null character specified by traits::eos().The pointer may not be valid after the string object has been modified.

Method             capacity()

Access             Public

Classification     Accessor

Syntax             size_type capacity() const;

Parameters         None

Returns            This method returns the number of characters
                   allocated for the sequence.

Description

The capacity() method returns the number of characters allocated for in the character sequence.

Method             compare()

Access             Public

Classification     Accessor

Syntax             int compare(const basic_string& str) const;

Parameters         str is the basic_string object compared to the
                   current object.

Returns            The method returns 0 if the character sequences of
                   the basic_string objects are equal.

Description

The compare() method compares the basic_string str with the character sequence of the current object. The comparison is performed by char_traits<Ch>'s compare(). 0 is returned if the character sequences have the same value; a negative integer is returned if the current object's character sequence is lexicographically before str's character sequence; a positive integer is returned otherwise.

Method             compare()

Access             Public

Classification     Accessor

Syntax             int compare(size_type pos1,
                               size_type n1,
                               const basic_string& str) const;

Parameters         pos1 is the starting position in the character
                   sequence of the current object used in the
                   comparison.

                   n1 is the length of the character sequence used in
                   the comparison.

                   str is the basic_string object compared to the
                   current object.

Returns            The method returns 0 if the character sequences of
                   the basic_string objects are equal.

Description

The compare() method compares the basic_string str with the character sequence of the current object. It compares current object's character sequence of length n1 starting at position pos1 with the character sequence of str. The comparison is performed by char_traits<Ch>'s compare(). 0 is returned if the character sequences have the same value; a negative integer is returned if the current object's character sequence is lexicographically before str's character sequence; a positive integer is returned otherwise.

Method             compare()

Access             Public

Classification     Accessor

Syntax             int compare(size_type pos1,
                               size_type n1,
                               const basic_string& str,
                               size_type pos2,
                               size_type n2) const;

Parameters         pos1 is the starting position in the character
                   sequence of the current object used in the
                   comparison.

                   n1 is the length of the character sequence used in
                   the comparison.

                   str is the basic_string object compared to the
                   current object.

                   pos2 is the starting position in the character
                   sequence of basic_string object str used in the
                   comparison.

                   n2 is the length of the character sequence
                   of the basic_string object str used in the
                   comparison.

Returns            The method returns 0 if the character sequences of
                   the basic_string objects are equal.

Description

The compare() method compares the basic_string str with the character sequence of the current object. It compares current object's character sequence of length n1 starting at position pos1 with the character sequence of str starting at position pos2 of length n2. The comparison is performed by char_traits<Ch>'s compare(). 0 is returned if the character sequences have the same value; a negative integer is returned if the current object's character sequence is lexicographically before str's character sequence; a positive integer is returned otherwise.

Method             compare()

Access             Public

Classification     Accessor

Syntax             int compare(const charT* s) const;

Parameters         s points to the character array used in the
                   comparison.

Returns            The method returns 0 if the character sequences of
                   the basic_string objects are equal.

Description

The compare() method compares the character sequence pointed to by s with the character sequence of the current object. The comparison is performed by char_traits<Ch>'s compare(). 0 is returned if the character sequences have the same value; a negative integer is returned if the current object's character sequence is lexicographically before s's character array; a positive integer is returned otherwise.

Method             compare()

Access             Public

Classification     Accessor

Syntax             int compare(size_type pos1,
                               size_type n1,
                               const charT* s,
                               size_type n2 = npos) const;

Parameters         pos1 is the starting position in the character
                   sequence of the current object used in the
                   comparison.

                   n1 is the length of the character sequence used in
                   the comparison.

                   s points to the character array used in the
                   comparison.

                   n2 is the length of the character array s used in
                   the comparison.

Returns            The method returns 0 if the character sequences of
                   the basic_string objects are equal.

Description

The compare() method compares the character sequence pointed to by s with the character sequence of the current object. It compares current object's character sequence of length n1 starting at position pos1 with the character array pointed to by s of length n2.The comparison is performed by char_traits<Ch>'s compare(). 0 is returned if the character sequences have the same value; a negative integer is returned if the current object's character sequence is lexicographically before s's character array; a positive integer is returned otherwise.

Method             copy()

Access             Public

Classification     Modifier

Syntax             size_type copy(charT* s, size_type n,
                                  size_type pos = 0) const;

Parameters         s points to the character array which
                   receives the copy of the character sequence of the
                   current object.

                   n is the length of the current object's
                   character sequence to be copied.

                   pos1 is the starting position in the character
                   sequence of the current object to be copied.

Returns            This method returns the number of characters
                   copied.

Description

The copy() method copies the current object's character sequence starting at position pos with a length of n or to the end of the sequence, whichever comes first, to the character array pointed by s. A null object is not appended to the character array. The method returns the number of characters copied.

Method             data()

Access             Public

Classification     Accessor

Syntax             const charT* data() const;

Parameters         None

Returns            This method returns a pointer that points to the
                   first element of an array whose elements corresponds
                   to the character sequence of the current object.

Description

The data() method returns a pointer of type const charT that points to the first element of an array whose first size() elements are equal in correspondence to the elements of the string controlled by *this if size() is nonzero. If size() == 0, then a non-null pointer that is copyable and can have 0 added to it is returned. The pointer may not be valid after the string object has been modified.

Method             empty()

Access             Public

Classification     Accessor

Syntax             bool empty() const;

Parameters         None

Returns            This method returns true if the string object has
                   no character sequence.

Description

The empty() method returns true if the string object has no character sequence.

Method             end()

Access             Public

Classification     Accessor

Syntax             iterator end();

Parameters         None

Returns            This method returns an iterator that points to the
                   past-the-end value of the character sequence of the
                   current object.

Description

The end() method returns an iterator that points to the past_the_end value of the basic_string object's character sequence.

Method             end()

Access             Public

Classification     Accessor

Syntax             const_iterator end() const;

Parameters         None

Returns            This method returns a const iterator that points to
                   the past-the-end value of the character sequence of
                   the current object.

Description

The end() method returns a const iterator that points to the past_the_end value of the basic_string object's character sequence.

Method             erase()

Access             Public

Classification     Modifier

Syntax             basic_string& erase(size_type pos = 0,
                                       size_type n = npos);

Parameters         pos is the starting position in the character
                   sequence of the current object to be erased.

                   n is the number of characters to be erased.

Returns            This method returns a pointer to the calling object.

Description

This erase() method removes characters starting at position pos to the end of the sequence or n characters, whichever comes first. The method returns *this. An exception out_of_range is thrown if pos > size().

Method             erase()

Access             Public

Classification     Modifier

Syntax             iterator erase(iterator position);

Parameters         position is the position of the character in the
                   sequence of the current object to be erased.

Returns            This method returns an iterator that points to the
                   character following the character position to be
                   erased.
Return Type: iterator

Description

This erase() method removes the character pointed to by the iterator position. Returns the iterator that points to the character following the character position of the element that was erased. If that character does not exist then end() is returned. The iterator position must be a valid iterator of the current object. An exception out_of_range is thrown if pos > size().

Method             erase()

Access             Public

Classification     Modifier

Syntax             iterator erase(iterator first, iterator last);

Parameters         first points to the beginning of a character
                   range.

                   last points to the end of a character range.

Returns            This method returns the iterator that points to the
                   character following the character position of the
                   element that was erased.

Description

This erase() method removes the characters in the range specified by the input iterators first and last. This method returns the iterator that points to the character following the character position of the element that was erased. If that character does not exist then end() is returned. The iterators first and last must be valid iterators of the current object.

Method             find()

Access             Public

Classification     Accessor

Syntax             size_type find(const basic_string& str,
                                  size_type pos = 0) const;

Parameters         str contains the character sequence to be located in the
                   character sequence of the current object.

                   pos is the position in character sequence of the
                   current object to start the search.

Returns            This method returns the position of the beginning
                   of the first occurence of the character
                   sequence of the basic_string object str in the
                   current object.

Description

This find() method returns the position of the beginning of the first occurence of the character sequence of the basic_string object str in the current object. The search of the character sequence begins at position pos of the current object. If the substring cannot be found npos is returned.

Method             find()

Access             Public

Classification     Accessor

Syntax             size_type find(const charT* s, size_type pos,
                                  size_type n) const;

Parameters         s points to the character array to be located
                   in the character sequence of the current object.

                   pos is the position in the character sequence of the
                   current object to start the search.

                   n is the number of characters in the character
                   array to be located.

Returns            This method returns the position of the beginning
                   of the first occurence of the first n characters
                   of the character array s in the character sequence
                   of the current object.

Description

This find() method returns the position of the beginning of the first occurence of the first n characters of the character array s in the character sequence of the current object. The search of the character array begins at position pos in the character sequence of the current object. If the substring cannot be found npos is returned.

Method             find()

Access             Public

Classification     Accessor

Syntax             size_type find(const charT* s,
                                  size_type pos = 0) const;

Parameters         s points to the character array to be located
                   in the character sequence of the current object.

                   pos is the position in the character sequence of the
                   current object to start the search.

Returns            This method returns the position of the beginning
                   of the first occurence of the character array s in
                   the character sequence of the current object.

Description

This find() method returns the position of the beginning of the first occurence of the character array s in the current object. The search of the character sequence begins at position pos of the character sequence of the current object. If the substring cannot be found npos is returned.

Method             find()

Access             Public

Classification     Accessor

Syntax             size_type find(const charT c, size_type pos = 0) const;

Parameters         c is the character to be located.

                   pos is the position in the character sequence of the
                   current object to start the search.

Returns            This method returns the position of the first occurence
                   of the character c in the current object.

Description

Thsi find() method returns the position of the first occurence of the character c in the character sequence of the current object. The search of the character begins at position pos in the character sequence of the current object. If the character cannot be found npos is returned.

Method             find_first_not_of()

Access             Public

Classification     Accessor

Syntax             size_type find_first_not_of(const basic_string& str,
                                               size_type pos = 0) const;

Parameters         str contains the characters not located in the
                   character sequence of the current object.

                   pos is the position in character sequence of the
                   current object to start the search.

Returns            This method returns the position in the current
                   object of the first occurence of any character
                   not in the character sequence of the basic_string
                   str.

Description

This find_first_not_of() method returns the position in the current object of the first occurence of any character not in the character sequence of the basic_string str. The search of the character begins at position pos of the current object. If the character cannot be found npos is returned.

Method             find_first_not_of()

Access             Public

Classification     Accessor

Syntax             size_type find_first_not_of(const charT* s,
                                               size_type pos,
                                               size_type n) const;

Parameters         s points to the character array not located
                   in the character sequence of the current object.

                   pos is the position in the character sequence of the
                   current object to start the search.

                   n is the length of the character array.

Returns            This method returns the position in the character
                   sequence of the current object of the first
                   occurence of any character not in the character
                   array s.

Description

This find_first_not_of() method returns the position in the character sequence of the current object of the first occurence of any character not in the character array s of length n . The search of the character begins at position pos of the character sequence of the current object. If the character cannot be found npos is returned.

Method             find_first_not_of()

Access             Public

Classification     Accessor

Syntax             size_type find_first_not_of(const charT* s,
                                               size_type pos = 0) const;

Parameters         s points to the character array not located
                   in the character sequence of the current object.

                   pos is the position in the character sequence of the
                   current object to start the search.

Returns            This method returns the position in the current
                   object of the first occurence of any character not
                   in the character array s.

Description

This find_first_not_of() method returns the position in the character sequence of the current object of the first occurence of any character not in the character array s. The search of the character begins at position pos of the character sequence of the current object. If the character cannot be found npos is returned.

Method             find_first_not_of()

Access             Public

Classification     Accessor

Syntax             size_type find_first_not_of(const charT c,
                                               size_type pos = 0) const;

Parameters         c is the character not located in the
                   character sequence of the current object.

                   pos is the position in the character sequence of the
                   current object to start the search.

Returns            This method returns the position in the current
                   object of the first occurence of a character that
                   is not c.

Description

This find_first_not_of() method returns the position in the current object of the first occurence of a character that is not c. The search of the character begins at position pos of the character sequence of the current object. If the character cannot be found npos is returned.

Method             find_first_of()

Access             Public

Classification     Accessor

Syntax             size_type find_first_of(const basic_string& str,
                                           size_type pos = 0) const;

Parameters         str contains the characters located in the
                   character sequence of the current object.

                   pos is the position in character sequence of the
                   current object to start the search.

Returns            This method returns the position in the character
                   sequence of the current object of the first
                   occurence of any character in the character
                   sequence of the basic_string str.

Description

This find_first_of() method returns the position in the character sequence of the current object of the first occurence of any character in the character sequence of the basic_string str. The search of the character begins at position pos of the current object. If the character cannot be found npos is returned.

Method             find_first_of()

Access             Public

Classification     Accessor

Syntax             size_type find_first_of(const charT* s,
                                           size_type pos,
                                           size_type n) const;

Parameters         s points to the character array to be located
                   in the character sequence of the current object.

                   pos is the position in the character sequence of the
                   current object to start the search.

                   n is the length of the character array.

Returns            This method returns the position in the character
                   sequence of the current object of the first occurence
                   of any character in the character array s of length n.

Description

This find_first_of() method returns the position in the current object of the first occurence of any character in the character array s of length n . The search of the character begins at position pos of the current object. If the character cannot be found npos is returned.

Method             find_first_of()

Access             Public

Classification     Accessor

Syntax             size_type find_first_of(const charT* s,
                                           size_type pos = 0) const;

Parameters         s points to the character array to be located
                   in the character sequence of the current object.

                   pos is the position in the character sequence of the
                   current object to start the search.

Returns            This method returns the position in the character
                   sequence of the current object of the first
                   occurence of any character in the character array s.

Description

This find_first_of() method returns the position in the character sequence current object of the first occurence of any character in the character array s. The search of the character begins at position pos of the current object. If the character cannot be found npos is returned.

Method             find_first_of()

Access             Public

Classification     Accessor

Syntax             size_type find_first_of(const charT c,
                                           size_type pos = 0) const;

Parameters         c is the character to be located in the
                   character sequence of the current object.

                   pos is the position in the character sequence of the
                   current object to start the search.

Returns            This method returns the position in the character
                   sequence of the current object of the first
                   occurence of the character c.

Description

This find_first_of() method returns the position in the character sequence of the current object of the first occurence of the character c. The search of the character begins at position pos of the current object. If the character cannot be found npos is returned.

Method             find_last_of()

Access             Public

Classification     Accessor

Syntax             size_type find_last_of(const basic_string& str,
                                          size_type pos = npos) const;

Parameters         str contains the characters to be located in the
                   character sequence of the current object.

                   pos is the position in character sequence of the
                   current object to start the search.

Returns            This method returns the position in the character
                   sequence of the current object of the last
                   occurence of any character in the character
                   sequence of the basic_string str.

Description

This find_last_of() method returns the position in the character sequence of the current object of the last occurence of any character in the character sequence of the basic_string str. The search of the character begins at or before position pos of the current object. If the character cannot be found npos is returned.

Method             find_last_of()

Access             Public

Classification     Accessor

Syntax             size_type find_last_of(const charT* s,
                                          size_type pos,
                                          size_type n) const;

Parameters         s points to the character array to be located
                   in the character sequence of the current object.

                   pos is the position in the character sequence of the
                   current object to start the search.

                   n is the length of the character array.

Returns            This method returns the position in the character
                   sequence of the current object of the last
                   occurence of any character in the character array
                   s of length n.

Description

This find_last_of() method returns the position in the character sequence of the current object of the last occurence of any character in the character array s of length n . The search of the character begins at or before position pos of the current object. If the character cannot be found npos is returned.

Method             find_last_of()

Access             Public

Classification     Accessor

Syntax             size_type find_last_of(const charT* s,
                                          size_type pos = npos) const;

Parameters         s points to the character array to be located
                   in the character sequence of the current object.

                   pos is the position in the character sequence of the
                   current object to start the search.

Returns            This method returns the position in the character
                   sequence of the current object of the last
                   occurence of any character in the character array s.

Description

This find_last_of() method returns the position in the character sequence of the current object of the last occurence of any character in the character array s. The search of the character begins at or before position pos of the current object. If the character cannot be found npos is returned.

Method             find_last_of()

Access             Public

Classification     Accessor

Syntax             size_type find_last_of(const charT c,
                                          size_type pos = npos) const;

Parameters         c is the character to be located in the
                   character sequence of the current object.

                   pos is the position in the character sequence of the
                   current object to start the search.

Returns            This method returns the position in the character
                   sequence of the current object of the last occurence
                   of the character c.

Description

This find_last_of() method returns the position in the character sequence of the current object of the last occurence of the character c. The search of the character begins at or before position pos of the current object. If the character cannot be found npos is returned.

Method             find_last_not_of()

Access             Public

Classification     Accessor

Syntax             size_type find_last_not_of(const basic_string& str,
                                              size_type pos = npos) const;

Parameters         str contains the characters not located in the
                   character sequence of the current object.

                   pos is the position in character sequence of the
                   current object to start the search.

Returns            This method returns the position in the character
                   sequence of the current object of the last occurence
                   of any character not in the character sequence of the
                   basic_string str.

Description

This find_last_not_of()method returns the position in the character sequence of the current object of the last occurence of any character not in the character sequence of the basic_string str. The search of the character begins at or before position pos of the current object. If the character cannot be found npos is returned.

Method             find_last_not_of()

Access             Public

Classification     Accessor

Syntax             size_type find_last_not_of(const charT* s,
                                              size_type pos,
                                              size_type n) const;

Parameters         s points to the character array not located
                   in the character sequence of the current object.

                   pos is the position in the character sequence of the
                   current object to start the search.

                   n is the length of the character array.

Returns            This method returns the position in the character
                   sequence of the current object of the last
                   occurence of any character not in the character
                   array s of length n.

Description

This find_last_not_of() method returns the position in the character sequence of the current object of the last occurence of any character not in the character array s of length n . The search of the character begins at or before position pos of the current object. If the character cannot be found npos is returned.

Method             find_last_not_of()

Access             Public

Classification     Accessor

Syntax             size_type find_last_not_of(const charT* s,
                                              size_type pos = npos) const;

Parameters         s points to the character array not located
                   in the character sequence of the current object.

                   pos is the position in the character sequence of the
                   current object to start the search.

Returns            This method returns the position in the character
                   sequence of the current object of the last occurence
                   of any character not in the character array s.

Description

This find_last_not_of() method returns the position in the character sequence of the current object of the last occurence of any character not in the character array s. The search of the character begins at or before position pos of the current object. If the character cannot be found npos is returned.

Method             find_last_not_of()

Access             Public

Classification     Accessor

Syntax             size_type find_last_not_of(const charT c,
                                              size_type pos = npos) const;

Parameters         c is the character not located in the
                   character sequence of the current object.

                   pos is the position in the character sequence of the
                   current object to start the search.

Returns            This method returns the position in the character
                   sequence of the current object of the last occurence
                   of any character that is not c.

Description

This find_last_not_of() method returns the position in the character sequence of the current object of the last occurence of any character that is not c. The search of the character begins at or before position pos of the current object. If the character cannot be found npos is returned.

Method             get_allocator()

Access             Public

Classification     Accessor

Syntax             allocator_type get_allocator() const;

Parameters         None

Returns            This method returns a copy of the allocator object
                   that allocates memory for the basic_string object.

Description

The get_allocator() method returns a copy of the allocator object that allocates memory for the basic_string object.

Method             insert()

Access             Public

Classification     Modifier

Syntax             basic_string& insert(size_type pos1,
                                        const basic_string& str);

Parameters         pos1 is the insertion point in the character sequence of
                   the current object.

                   str contains the character sequence to be inserted
                   into the character sequence of the current object.

Returns            This method returns a pointer to the current object.

Description

This insert() method inserts basic_string str's character sequence into the character sequence of the current object before position pos1. The method returns *this. An exception out_of_range is thrown if pos1 > size(). If the resulting sequence is greater than npos then the exception length_error is thrown.

Method             insert()

Access             Public

Classification     Modifier

Syntax             basic_string& insert(size_type pos1,
                                        const basic_string& str,
                                        size_type pos2,
                                        size_type n);

Parameters         pos1 is the insertion point in the character sequence of
                   the current object.

                   str contains the character sequence to be inserted
                   into the character sequence of the current object.

                   pos2 is the starting position in the character sequence
                   of the basic_string str to be inserted.

                   n is the length of the sequence to be inserted.

Returns            This method returns a pointer to the current object.

Description

This insert() method inserts basic_string str's character sequence starting at position pos2 into the character sequence of the current object before position pos1. The method returns *this. An exception out_of_range is thrown if pos1 > size() or pos2 > str.size(). If the resulting sequence is greater than npos then the exception length_error is thrown.

Method             insert()

Access             Public

Classification     Modifier

Syntax             basic_string& insert(size_type pos,const charT* s,
                                        size_type n);

Parameters         pos is the insertion point in the character sequence of
                   the current object.

                   s points to the character array to be inserted
                   in the character sequence of the current object.

                   n is the length of the character array to be inserted.

Returns            This method returns a pointer to the current object.

Description

This insert() method inserts the character array s of length n into the character sequence of the current object before position pos. The method returns *this. An exception out_of_range is thrown if pos > size(). If the resulting sequence is greater than npos then the exception length_error is thrown.

Method             insert()

Access             Public

Classification     Modifier

Syntax             basic_string& insert(size_type pos, const charT* s);

Parameters         pos is the insertion point in the character sequence of
                   the current object.

                   s points to the character array to be inserted
                   in the character sequence of the current object.

Returns            This method returns a pointer to the current object.

Description

This insert() method inserts the character array s into the character sequence of the current object before position pos. The method returns *this. An exception out_of_range is thrown if pos > size(). If the resulting sequence is greater than npos then the exception length_error is thrown.

Method             insert()

Access             Public

Classification     Modifier

Syntax             basic_string& insert(size_type pos, size_type n,
                                        charT c);

Parameters         pos is the insertion point in the character sequence of
                   the current object.

                   n is the number of characters to be inserted.

                   c is the character to be inserted.

Returns            This method returns a pointer to the current object.

Description

This insert() method inserts n number of character c into the character sequence of the current object before position pos. The method returns *this. An exception out_of_range is thrown if pos > size(). If the resulting sequence is greater than npos then the exception length_error is thrown.

Method             insert()

Access             Public

Classification     Modifier

Syntax             iterator insert(iterator p, charT c = charT());

Parameters         p is an iterator that points to the insertion point
                   in the character sequence of the current object.

                   c is the character to be inserted.

Returns            This method returns the iterator that points to
                   the newly inserted character.

Description

This insert() method inserts the character c into the character sequence of the current object before the character iterator p is pointing to. The method returns the iterator that points to the newly inserted character. The iterator p must be a valid iterator of the current object.

Method             insert()

Access             Public

Classification     Modifier

Syntax             void insert(iterator p, size_type n, charT c);

Parameters         p is an iterator that points to the insertion point
                   in the character sequence of the current object.

                   n is the number of characters to be inserted.

                   c is the character to be inserted.

Returns            void

Description

The insert() method inserts n number of character c into the character sequence of the current object before character iterator p is pointing to. The iterator p must be a valid iterator of the current object.

Method             insert()

Access             Public

Classification     Modifier

Syntax             template
                   void insert(iterator p, InputIterator first,
                               InputIterator last);

Parameters         p is an iterator that points to the insertion point
                   in the character sequence of the current object.

                   first points to the beginning of a character
                   range.

                   last points to the end of a character range.

Returns            void

Description

This insert() method is a template function that inserts a range specified by the input iterators first and last into the character sequence of the current object before character iterator p is pointing to. The iterator p must be a valid iterator of the current object.

Method             length()

Access             Public

Classification     Accessor

Syntax             size_type length() const;

Parameters         None

Returns            This method returns size().

Description

The length() method returns size().

Method             max_size()

Access             Public

Classification     Accessor

Syntax             size_type max_size() const;

Parameters         None

Returns            This method returns the maximum number of allowable
                   characters in the sequence.

Description

The max_size() method returns the maximum number of allowable characters in the sequence.

Method             rbegin()

Access             Public

Classification     Accessor

Syntax             reverse_iterator rbegin();

Parameters         None

Returns            This method returns a reverse_iterator.

Description

This rbegin() method returns a reverse_iterator; equivalent to reverse_iterator(end()).

Method             rbegin()

Access             Public

Classification     Accessor

Syntax             const_reverse_iterator rbegin() const;

Parameters         None

Returns            This method returns a const_reverse_iterator.

Description

This rbegin() method returns a const_reverse_iterator; equivalent to const_reverse_iterator(end()).

Method             rend()

Access             Public

Classification     Accessor

Syntax             reverse_iterator rend();

Parameters         None

Returns            This method returns a reverse_iterator.

Description

This rend() method returns an reverse_iterator; equivalent to reverse_iterator(begin()).

Method             rend()

Access             Public

Classification     Accessor

Syntax             const_reverse_iterator rend() const;

Parameters         None

Returns            This method returns a const_reverse_iterator.

Description

This rend() method returns a const_reverse_iterator; equivalent to const_reverse_iterator(begin()).

Method             replace()

Access             Public

Classification     Modifier

Syntax             basic_string& replace(size_type pos1, size_type n1,
                                         const basic_string& str);

Parameters         pos1 is the starting point in the sequence of
                   the current object of the characters to be replaced.

                   str contains the character sequence that will
                   replace a sequence of characters in the current object.

                   n1 is the length of the replacement sequence.

Returns            This method returns a pointer to the current object.

Description

This replace() method replaces a sequence of characters in the current object starting at position pos1 with a length of n1 with basic_string str's character sequence. The method returns *this. An exception out_of_range is thrown if pos1 > size(). An exception length_error is thrown if the new character sequence is greater than npos.

Method             replace()

Access             Public

Classification     Modifier

Syntax             basic_string& replace(size_type pos1, size_type n1,
                                         const basic_string& str,
                                         size_type pos2, size_type n2);

Parameters         pos1 is the starting point in the sequence of
                   the current object of the characters to be replaced.

                   str contains the character sequence that will
                   replace a sequence of characters in the current object.

                   n1 is the length of the replacement sequence.

                   pos2 is the starting point in the character sequence of
                   the basic_string str that serves as the replacement.

                   n2 is the length of the replacement sequence.

Returns            This method returns a pointer to the current object.

Description

This replace() method replaces sequence of characters in the current object starting at position pos1 with a length of n1 with basic_string str's character sequence starting at position pos2 with a length of n2. The method returns *this. An exception out_of_range is thrown if pos1 > size() or pos2 > str.size(). An exception length_error is thrown if the new character sequence is greater than npos.

Method             replace()

Access             Public

Classification     Modifier

Syntax             basic_string& replace(size_type pos1, size_type n1,
                                         const charT* s, size_type n2);

Parameters         pos1 is the starting point in the sequence of
                   the current object of the characters to be replaced.

                   s points to the character array that serves
                   as the replacement sequence.

                   n1 is the length of the sequence to be replaced.

                   pos2 is the starting point in the character sequence of
                   the basic_string str that serves as the replacement.

                   n2 is the length of the replacement sequence.

Returns            This method returns a pointer to the current object.

Description

The replace() method replaces a sequence of characters in the current object starting at position pos1 with a length of n1 with the character array s with length n2. The method returns *this. An exception out_of_range is thrown if pos1 > size(). An exception length_error is thrown if the new character sequence is greater than npos.

Method             replace()

Access             Public

Classification     Modifier

Syntax             basic_string& replace(size_type pos1, size_type n1,
                                         const charT* s);

Parameters         pos1 is the starting position in the sequence of
                   the current object of the characters to be replaced.

                   s points to the character array that serves
                   as the replacement sequence.

                   n1 is the length of the sequence to be replaced.

Returns            This method returns a pointer to the current object.

Description

This replace() method replaces a sequence of characters in the current object starting at position pos1 with a length of n1 with the character array s. The method returns *this. An exception out_of_range is thrown if pos1 > size(). An exception length_error is thrown if the new character sequence is greater than npos.

Method             replace()

Access             Public

Classification     Modifier

Syntax             basic_string& replace(size_type pos, size_type n1,
                                         size_type n2, charT c);

Parameters         pos is the starting position in the sequence of
                   the current object of the characters to be replaced.

                   n1 is the length of the sequence to be replaced.

                   n2 is the number of characters that serves
                   as the replacement sequence.

                   c is the replacement character.

Returns            This method returns a pointer to the current object.
H3>Description

This replace() method replaces a sequence of characters in the current object starting at position pos with a length of n1 with n2 number of character c. The method returns *this. An exception out_of_range is thrown if pos > size(). An exception length_error is thrown if the new character sequence is greater than npos.

Method             replace()

Access             Public

Classification     Modifier

Syntax             basic_string& replace(iterator i1, iterator i2,
                                         const basic_string& str);

Parameters         i1 points to the beginning of a character
                   range to be replaced in the current object.

                   i2 points to the end of a character range
                   to be replaced in the current object.

                   str contains the character sequence that will
                   replace a sequence of characters in the current object.

Returns            This method returns a pointer to the current object.

Description

This replace() replaces a sequence of characters in the range [i1, i2) of the current object with character sequence of the basic_string str. The method returns *this. The iterators i1 and i2 must be valid iterators of the current object. An exception length_error is thrown if the new character sequence is greater than npos.

Method             replace()

Access             Public

Classification     Modifier

Syntax             basic_string& replace(iterator i1, iterator i2,
                                         const charT* s, size_type n);

Parameters         i1 points to the beginning of a character
                   range to be replaced in the current object.

                   i2 points to the end of a character range
                   to be replaced in the current object.

                   s points to the character array that serves
                   as the replacement sequence.

                   n is the length of the replacement sequence.

Returns            This method returns a pointer to the current object.

Description

This replace() method replaces the sequence of characters in the range [i1, i2) of the current object with the character array s with a length n. The method returns *this. The iterators i1 and i2 must be valid iterators of the current object. An exception length_error is thrown if the new character sequence is greater than npos.

Method             replace()

Access             Public

Classification     Modifier

Syntax             basic_string& replace(iterator i1, iterator i2,
                                         const charT* s);

Parameters         i1 points to the beginning of a character
                   range to be replaced in the current object.

                   i2 points to the end of a character range
                   to be replaced in the current object.

                   s points to the character array that serves
                   as the replacement sequence.

Returns            This method returns a pointer to the current object.

Description

The replace() method replaces the sequence of characters in the range [i1, i2) of the current object with the character array s. The method returns *this. The iterators i1 and i2 must be valid iterators of the current object. An exception length_error is thrown if the new character sequence is greater than npos.

Method             replace()

Access             Public

Classification     Modifier

Syntax             basic_string& replace(iterator i1, iterator i2,
                                         size_type n, charT c);

Parameters         i1 points to the beginning of a character
                   range to be replaced in the current object.

                   i2 points to the end of a character range
                   to be replaced in the current object.

                   n is the number of characters that serves
                   as the replacement sequence.

                   c is the replacement character.

Returns            This method returns a pointer to the current object.

Description

The replace() method replaces the sequence of characters in the range [i1, i2) in the current object with n number of character c. The method returns *this. The iterators i1 and i2 must be valid iterators of the current object. An exception length_error is thrown if the new character sequence is greater than npos.

Method             replace()

Access             Public

Classification     Modifier

Syntax             template
                   basic_string& replace(iterator i1, iterator i2,
                                         InputIterator j1,
                                         InputIterator j2);

Parameters         i1 points to the beginning of the character
                   range to be replaced in the current object.

                   i2 points to the end of a character range
                   to be replaced in the current object.

                   j1 points to the beginning of a character
                   range of the replacement sequence.

                   j2 points to the end of a character range
                   of the replacement sequence.

Returns            This method returns a pointer to the current object.

Description

This replace() method is a template function that replaces the sequence in the range [i1, i2) of the current object with a range [j1 and j2). The method returns *this. The iterators i1 and i2 must be valid iterators of the current object. An exception length_error is thrown if the new character sequence is greater than npos.

Method             rfind()

Access             Public

Classification     Accessor

Syntax             size_type rfind (const basic_string& str,
                                    size_type pos = npos) const;

Parameters         pos is the position where the occurence
                   will start.

                   str contains the character sequence to be
                   located in the character sequence of the current object.

Returns            The method returns the position of the last occurence
                   of the character sequence of basic_string str
                   located in the character sequence of the current
                   object.

Description

The rfind() returns the position of the last occurence of the character sequence of the basic_string object str located in the character sequence of the current object. The occurence will start at or be before position pos in the sequence of the current object. If the substring cannot be found npos is returned.

Method             rfind()

Access             Public

Classification     Accessor

Syntax             size_type rfind(const charT* s, size_type pos,
                                   size_type n) const;

Parameters         s points to the character array to be located
                   in the character sequence of the current object.

                   pos is the position where the occurence
                   will start.

                   n is the length of the character array to be located
                   in the character sequence of the current object.

Returns            The method returns the position of the last occurence
                   of the first n characters of the array s
                   in the character sequence of the current object.

Description

The rfind() method returns the position of the last occurence of the first n characters of the array s in the character sequence of the current object. The occurence will start at or be before position pos in the sequence of the current object. If the substring cannot be found npos is returned.

Method             rfind()

Access             Public

Classification     Accessor

Syntax             size_type rfind(const charT* s,
                                   size_type pos = npos) const;

Parameters         s points to the character array to be located
                   in the character sequence of the current object.

                   pos is the position where the occurence
                   will start.

Returns            This method returns the position of the last
                   occurence of the character array s in the
                   character sequence of the current object.

Description

This rfind() returns the position of the last occurence of the character array s in the character sequence of the current object. The occurence will start at or before position pos in the current object. If the substring cannot be found npos is returned.

Method             rfind()

Access             Public

Classification     Accessor

Syntax             size_type rfind(const charT c,
                                   size_type pos = npos) const;

Parameters         c is the character to be located in the character
                   sequence of the current object.

                   pos is the position where the occurence
                   will start.

Returns            The method returns the position of the last occurence
                   of the character c in the sequence of the current
                   object.

Description

This rfind() returns the position of the last occurence of the character c in the sequence of the current object. The occurence will start at or be before position pos in the sequence of the current object. If the character cannot be found npos is returned.

Method             size()

Access             Public

Classification     Accessor

Syntax             size_type size() const;

Parameters         None

Returns            The method returns the number of elements in the
                   character sequence.

Description

The size() method returns the number of elements in the character sequence; it is equal to the distance between begin() and end().

Method             substr()

Access             Public

Classification     Accessor

Syntax             basic_string substr(size_type pos = 0,
                                       size_type n = npos) const;

Parameters         pos is the starting position of the substring in
                   the sequence of current object.

                   n is the length of the substring.

Returns            This method returns a basic_string object in which
                   the character sequence is a copy of the substring.

Description

The substr() method returns a basic_string object in which the character sequence of the object is a copy of the current object's sequence starting at position pos with a length of n or to the end of the sequence.

Method             swap()

Access             Public

Classification     Modifier

Syntax             void swap(basic_string& s);

Parameters         s is the basic_string in which the character sequence
                   is exchanged with the character sequence of the
                   current object.

Returns            void

Description

The swap() method swaps the contents of the current object's character sequence with the character sequence of s.

Method             reserve()

Access             Public

Classification     Modifier

Syntax             void reserve(size_type res_arg = 0);

Parameters         res_arg is the capacity of current object.

Returns            void

Description

The reserve() method sets the capacity of the current object greater than or equal to the argument res_arg. Since reallocation occurs, previous references, iterators, and pointers into the current object is voided.

Method             resize()

Access             Public

Classification     Modifier

Syntax             void resize(size_type n, charT c);

Parameters         n is the new size of the character sequence
                   of the current object.

                   c is the character used for padding.

Returns            void

Description

This resize() method changes the size of the character sequence of the current object to n. If the size() > n then the sequence will be truncated. If n > size() then the sequence is padded with character c. An out_of_range exception is thrown if n > npos.

Method             resize()

Access             Public

Classification     Modifier

Syntax             void resize(size_type n);

Parameters         n is the new size of the character sequence
                   of the current object.

Returns            void

Description

This resize() method changes the size of the character sequence of the current object to n. If the size() > n then the sequence will be truncated. If n > size() then the sequence is padded with a NULL character. An out_of_range exception is thrown if n > npos.

Method             clear()

Access             Public

Classification     Modifier

Syntax             void clear();

Parameters         None

Returns            void

Description

The clear() method removes all the characters from the character sequence of the current object.

The Class Relationship Diagram of string

 1
 2   #include
 3   #include
 4   #include
 5
 6   using namespace std;
 7
 8   class mystring : public string{
 9   public:
10       mystring(char *X);
11       void toUpper(void);
12       void removeWhitespace(void);
13   };
14
15
16   mystring::mystring(char *X) : string(X)
17   {
18   }
19
20   void mystring::toUpper(void)
21   {
22
23       char *X;
24       int N = length();
25       int Index;
26       X = new char[length() + 1];
27       strcpy(X,data());
28       for(Index = 0;Index < N;Index++)
29       {
30           X[Index] = toupper(X[Index]);
31       }
32       replace(0,N,X,N);
33
34   }
35
36   void mystring::removeWhitespace(void)
37   {
38
39       int N;
40
41       while(N != string::npos)
42       {
43             N = find(" ");
44             if(N != string::npos){
45                erase(N,1);
46             }
47       }
48
49   }
50
51
52   void main(void)
53   {
54       mystring X("started in lower case");
55       X.toUpper();
56       X.removeWhitespace();
57       cout << X;
58
59   }
60


time_get

Class Name            time_get

Header File          <locale>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

locale::id

Methods

dateorder date_order() const;

virtual dateorder do_date_order() const;

virtual iter_type do_get_date(iter_type s, iter_type end, ios_base&,
ios_base::iostate& err, tm* t) const;

virtual iter_type do_get_monthname(iter_type s, ios_base&,
ios_base::iostate& err, tm* t) const;

virtual iter_type do_get_time(iter_type s, iter_type end,
ios_base&, ios_base::iostate& err, tm* t) const;

virtual iter_type do_get_weekday(iter_type s, iter_type end, ios_base&,
ios_base::iostate& err, tm* t) const;

virtual iter_type do_get_year(iter_type s, iter_type end, ios_base&,
ios_base::iostate& err, tm* t) const;

iter_type get_date(iter_type s, iter_type end, ios_base& f,
ios_base::iostate& err, tm* t) const;

iter_type get_monthname(iter_type s, iter_type end, ios_base& f,
ios_base::iostate& err, tm* t) const;

iter_type get_time(iter_type s, iter_type end, ios_base& f,
ios_base::iostate& err, tm* t) const;

iter_type get_weekday(iter_type s, iter_type end, ios_base& f,
ios_base::iostate& err, tm* t) const;

iter_type get_year(iter_type s, iter_type end, ios_base& f,
ios_base::iostate& err, tm* t) const;

explicit time_get(size_t refs = 0);

~time_get();

Class Description

The time_get class describes a class used to parse character sequences and extract the components of time or dates. The get member functions will parse a particular format produced by time_put< >::put format specifier.

locale::id

locale::id is a class used to provide an identification of a locale facet interfaces used as an index for lookup and to encapsulate initialization.

Method             date_order()

Access             Public

Classification     Accessor

Syntax             dateorder date_order() const;

Parameters         None

Returns            This method returns a value which describes
                   the preferred order of the date components
                   composed of day, month and year.

Description

The date_order() member function returns do_date_order().

Method             do_date_order()

Access             Protected

Classification     Accessor

Syntax             virtual dateorder do_date_order() const;

Parameters         None

Returns            This method returns a value which describes
                   the preferred order of the date components
                   composed of day, month and year.

Description

The do_date_order() method returns a value of type dateorder which describes the preferred order of the date components composed of day, month and year. The method returns no_order if the date format contains other components (e.g. Julian day, week number, week day).

Method             do_get_date()

Access             Protected

Classification     Accessor

Syntax             virtual iter_type do_get_date(iter_type s,
                                                 iter_type end,
                                                 ios_base& str,
                                                 ios_base::iostate& err,
                                                 tm *t) const;

Parameters         s is an input iterator that points to the beginning
                   character of a character sequence.

                   end is an input iterator that points to the end
                   character of a character sequence.

                   str is the reference to the ios_base object.

                   err is set to ios_base::failbit when an error
                   occurs.

                   t is the struct tm in which the date field is
                   stored.

Returns            This method returns an iterator that points
                   immediately beyond the last character of the valid
                   date field.

Description

The do_get_date() method reads the characters from the character sequence (s, end] until it has extracted the members of the struct tm and the all of the remaining format characters that were used by time_put< >::put object. Characters are extracted until all the members of the struct tm has been removed, until an error has been encountered or the end of the sequence has been reached. The results are stored in the struct tm. It returns an iterator that points immediately beyond the last character of the valid date field. If the buffer does not contain a valid date (this being an error), the member function will set the err argument to the ios_base::failbit. But if the return value equals last, then the member function will set ios_base::eofbit in str.

Method             do_get_monthname()

Access             Protected

Classification     Accessor

Syntax             virtual iter_type do_get_monthname(iter_type s,
                                                      iter_type end,
                                                      ios_base& str,
                                                      ios_base::iostate& err,
                                                      tm *t) const;

Parameters         s is an input iterator that points to the beginning
                   character of a character sequence.

                   end is an input iterator that points to the end
                   character of a character sequence.

                   str is the reference to the ios_base object.

                   err is set to ios_base::failbit when an error
                   occurs.

                   t is the struct tm in which the month name field
                   is stored.

Returns            This method returns an iterator that points
                   immediately beyond the last character of the
                   valid month name field.

Description

The do_get_monthname() method reads the characters from the character sequence (s,end] until it has extracted the name of the month (perhaps an abbbreviation). If the sequence is an abbreviation, the member function will continue to extract the characters from the sequence until the full name is a match or it fails. If successful, the results are stored in the appropriate member of the struct tm t argument. If an error occurs, then err will be set to ios_base::failbit. It returns an iterator that points immediately beyond the last character of the valid date field.

Method             do_get_weekday()

Access             Protected

Classification     Accessor

Syntax             virtual iter_type do_get_weekday(iter_type s,
                                                    iter_type end,
                                                    ios_base& str,
                                                    ios_base::iostate& err,
                                                    tm *t) const;

Parameters         s is an input iterator that points to the beginning
                   character of a character sequence.

                   end is an input iterator that points to the end
                   character of a character sequence.

                   str is the reference to the ios_base object.

                   err is set to ios_base::failbit when an error
                   occurs.

                   t is the struct tm in which the weekday field
                   is stored.

Returns            This method returns an iterator that points
                   immediately beyond the last character of the valid
                   weekday field.

Description

The do_get_weekday() method reads the characters from the character sequence (s,end] until it has extracted the name of the weekday (perhaps an abbreviation). If the sequence is an abbreviation, the member function will continue to extract the characters from the sequence until the full name is a match or it fails. If successful, the results are stored in the appropriate member of the struct tm t argument. If an error occurs, then err will be set to ios_base::failbit. It returns an iterator that points immediately beyond the last character of the valid weekday field.

Method             do_get_time()

Access             Protected

Classification     Accessor

Syntax             virtual iter_type do_get_time(iter_type s,
                                                 iter_type end,
                                                 ios_base& str,
                                                 ios_base::iostate& err,
                                                 tm *t) const;

Parameters         s is an input iterator that points to the
                   beginning character of a character sequence.

                   end is an input iterator that points to the
                   end character of a character sequence.

                   str is the reference to the ios_base object.

                   err is set to ios_base::failbit when an error
                   occurs.

                   t is the struct tm in which the time field is
                   stored.

Returns            This method returns an iterator that points
                   immediately beyond the last character of the valid
                   time field.

Description

The do_get_time() method reads the characters from the character sequence (s,end] until it has extracted the time field. The results are stored in the appropriate member of the struct tm t. If an error occurs, then err will be set to ios_base::failbit. It returns an iterator that points immediately beyond the last character of the valid time field.

Method             do_get_year()

Access             Protected

Classification     Accessor

Syntax             virtual iter_type do_get_year(iter_type s,
                                                 iter_type end,
                                                 ios_base& str,
                                                 ios_base::iostate& err,
                                                 tm *t) const;

Parameters         s is an input iterator that points to the
                   beginning character of a character sequence.

                   end is an input iterator that points to the
                   end character of a character sequence.

                   str is the reference to the ios_base object.

                   err is set to ios_base::failbit when an error
                   occurs.

                   t is the struct tm in which the year field
                   is stored.

Returns            The method returns an iterator that points
                   immediately beyond the last character of the valid
                   year field.

Description

The do_get_year() method reads the characters from the character sequence (s,end] until it has extracted the year field. The manner in which the year is represented is implementation-defined. The results are stored in the appropriate member of the struct tm t. If an error occurs, then err will be set to ios_base::failbit. It returns an iterator that points immediately beyond the last character of the valid year field.

Method             get_date()

Access             Public

Classification     Accessor

Syntax             iter_type get_date(iter_type s, iter_type end,
                                      ios_base& str,
                                      ios_base::iostate& err,
                                      tm *t) const;

Parameters         s is an input iterator that points to the
                   beginning character of a character sequence.

                   end is an input iterator that points to the
                   end character of a character sequence.

                   str is the reference to the ios_base object.

                   err is set to ios_base::failbit when an error
                   occurs.

                   t is the struct tm in which the date field is
                   stored.

Returns            The method returns an iterator that points
                   immediately beyond the last character of the valid
                   date field.

Description

The get_date() method returns do_get_date(s, end, str, err, t).

Method             get_weekday()

Access             Public

Classification     Accessor

Syntax             iter_type get_weekday(iter_type s, iter_type end,
                                         ios_base& str,
                                         ios_base::iostate& err,
                                         tm *t) const;

Parameters         s is an input iterator that points to the
                   beginning character of a character sequence.

                   end is an input iterator that points to the
                   end character of a character sequence.

                   str is the reference to the ios_base object.

                   err is set to ios_base::failbit when an error
                   occurs.

                   t is the struct tm in which the weekday field is
                   stored.

Returns            The method returns an iterator that points
                   immediately beyond the last character of the valid
                   weekday field.

Description

The get_weekday() method returns do_get_weekday(s, end, str, err, t).

Method             get_monthname()

Access             Public

Classification     Accessor

Syntax             iter_type get_monthname(iter_type s, iter_type end,
                                           ios_base& str,
                                           ios_base::iostate& err,
                                           tm *t) const;

Parameters         s is an input iterator that points to the
                   beginning character of a character sequence.

                   end is an input iterator that points to the
                   end character of a character sequence.

                   str is the reference to the ios_base object.

                   err is set to ios_base::failbit when an error
                   occurs.

                   t is the struct tm in which the month name field
                   is stored.

Returns            The method returns an iterator that points
                   immediately beyond the last character of the valid
                   month name field.

Description

The get_monthname() member function returns do_get_monthname(s, end, str, err, t).

Method             get_year()

Access             Public

Classification     Accessor

Syntax             iter_type get_year(iter_type s, iter_type end,
                                      ios_base& str,
                                      ios_base::iostate& err,
                                      tm *t) const;

Parameters         s is an input iterator that points to the
                   beginning character of a character sequence.

                   end is an input iterator that points to the
                   end character of a character sequence.

                   str is the reference to the ios_base object.

                   err is set to ios_base::failbit when an error
                   occurs.

                   t is the struct tm in which the year field is
                   stored.

Returns            The method returns an iterator that points
                   immediately beyond the last character of the valid
                   year field.

Description

The get_year() member function returns do_get_year(s, end, str, err, t).

Method             get_time()

Access             Public

Classification     Accessor

Syntax             iter_type get_time(iter_type s, iter_type end,
                                      ios_base& str,
                                      ios_base::iostate& err,
                                      tm *t) const;

Parameters         s is an input iterator that points to the
                   beginning character of a character sequence.

                   end is an input iterator that points to the
                   end character of a character sequence.

                   str is the reference to the ios_base object.

                   err is set to ios_base::failbit when an error
                   occurs.

                   t is the struct tm in which the time field is
                   stored.

Returns            The method returns an iterator that points
                   immediately beyond the last character of the valid
                   time field.

Description

The get_time() member function returns do_get_time(s, end, str, err, t).

Method             time_get()

Access             Public

Classification     Constructor

Syntax             explicit time_get(size_t refs = 0);

Parameters         refs, if the refs argument = 0 then the destruction
                   of the object is delegated to the locale or locales
                   which contain it. If refs = 1 then the object must
                   be explicitly deleted. The locale will not delete
                   it. The object can then be maintained across the
                   lifetime of multiple locales.

Returns            None

Description

This constructor constructs a time_get facet object.

Method             time_get()

Access             Protected

Classification     Destructor

Syntax             ~time_get();

Parameters         None

Returns            None

Description

This destructor destroys a time_get facet object.

The Class Relationship Diagram for time_get


time_put

Class Name            time_put

Header File          <locale>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

locale::id

Methods

virtual iter_type do_put(iter_type s, ios_base&, char_type,
const tm* t, char format, char modifier) const;

iter_type put(iter_type s, ios_base& f, char_type fill, const tm* tmb,
const charT* pattern, const charT* pat_end) const;

iter_type put(iter_type s, ios_base& f, char_type fill, const tm* tmb,
char format, char modifier = 0) const;

explicit time_put_(size_t refs = 0);

~time_put_();

Class Description

The time_put class describes a class that provides the functionality for formatting output of date and time values.

locale::id

locale::id is a class used to provide an identification of a locale facet interfaces used as an index for lookup and to encapsulate initialization.

Method             do_put()

Access             Protected

Classification     Modifier

Syntax             virtual iter_type do_put(iter_type s, ios_base& str,
                                             char_type fill, const tm* t,
                                             char format,
                                             char modifier) const;

Parameters         s is an iterator that points to the character
                   buffer used for output.

                   str is a reference to the ios_base object.

                   fill is the character used for padding.

                   t is the structure that contains the date/time
                   values.

                   format is a specifier used to control formatting.

                   modifier is a modifier used to control formatting.

Returns            The method returns an iterator that points to the
                   character past the last character produced.

Description

The do_put() method formats the date/time contained in the parameter t. It writes out a character string that is placed character buffer pointed to by s. The string is formatted according to the parameters format and modifer. They are iterpreted identically in the same way as the strftime function that interprets its format and modifier flags. The fill character is used for padding. The method returns an iterator that points to the character past the last character produced.

Method             put()

Access             Public

Classification     Modifier

Syntax             iter_type put(iter_type s, ios_base& f,
                                 char_type fill, const tm* tmb,
                                 const charT* pattern,
                                 const charT* pat_end) const;

Parameters         s is an iterator that points to the character buffer
                   used for output.

                   f is a reference to the ios_base object.

                   fill is the character used for padding.

                   tmb is the structure that contains the
                   date/time values.

                   pattern is the beginning of the pattern sequence.

                   pat_end is the end of the pattern sequence.

Returns            The method returns an iterator that points to the
                   character past the last character produced.

Description

The put() method creates a string representing the date/time contained in the argument tmb. It interprets the characters in the sequence between pattern and pat_end arguments. The formatting of the string is determined by the format specifiers used by the function strftime(). The resulting string is written out to the character buffer pointed to by s. The fill character is used for padding. The method returns an iterator that points to the character past the last character produced.

Method             put()

Access             Public

Classification     Modifier

Syntax             iter_type put(iter_type s, ios_base& f,
                                 char_type fill, const tm* t,
                                 char format, char modifier = 0) const;

Parameters         s is an iterator that points to the character
                   buffer used for output.

                   f is a reference to the ios_base object.

                   fill is the character used for padding.

                   t is the structure that contains the date/time
                   values.

                   format is a specifier used to control formatting.

                   modifier is a modifier used to control formatting.

Returns            The method returns an iterator that points to the
                   character past the last character produced.

Description

The do() member function returns do_put(s, f, fill, t, format, modifier).

Method             time_put()

Access             Public

Classification     Constructor

Syntax             explicit time_put(size_t refs = 0);

Parameters         refs, if the refs argument = 0 then the destruction
                   of the object is delegated to the locale or locales
                   which contain it. If refs = 1 then the object must
                   be explicitly deleted. The locale will not delete
                   it. The object can then be maintained across the
                   lifetime of multiple locales.

Returns            None

Description

The constructor constructs a time_put facet object.

Method             time_put()

Access             Protected

Classification     Destructor

Syntax             ~time_put();

Parameters         None

Returns            None

Description

This destructor destroys the time_put facet object.

The Class Relationship Diagram for time_put


time_base

Class Name            time_base

Header File          <locale>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

None

Class Description

The time_base class is a base class for the class time_get. It defines the enumerated type dateorder and several constants of this type. The constants represents different ways to order the components of a date. The constants are:

     no_order Specifies no particular order.

     dmy      Specifies the order day, month, then year.

     mdy      Specifies the order month, day, then year.

     ymd      Specifies the order year, month, then day.

     ydm      Specifies the order year, day, then month.

The Class Relationship Diagram for time_base


time_get_name

Class Name            time_get_byname

Header File          <locale>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

None

Methods

virtual dateorder do_date_order() const;

virtual iter_type do_get_date(iter_type s, iter_type end,
ios_base&, ios_base::iostate& err, tm* t) const;

virtual iter_type do_get_monthname(iter_type s, iter_type end,
ios_base&, ios_base::iostate& err, tm* t) const;

virtual iter_type do_get_time(iter_type s, iter_type end,
ios_base&, ios_base::iostate& err, tm* t) const;

virtual iter_type do_get_weekday(iter_type s, iter_type end,
ios_base&, ios_base::iostate& err, tm* t) const;

virtual iter_type do_get_year(iter_type s, iter_type end, ios_base&,
ios_base::iostate& err, tm* t) const;

explicit time_get_byname(const char*, size_t refs = 0);

~time_get_byname();

Class Description

The time_get_byname class describes a class that provides the same functionality as the time_get class for a particular named locale.

Method             do_date_order()

Access             Protected

Classification     Accessor

Syntax             virtual dateorder do_date_order() const;

Parameters         None

Returns            This method returns a value which describes
                   the preferred order of the date components
                   composed of day, month and year.

Description

The do_date_order() method returns a value of type dateorder which describes the preferred order of the date components composed of day, month and year. The method returns no_order if the date format contains other components (e.g. Julian day, week number, week day).

Method             do_get_date()

Access             Protected

Classification     Accessor

Syntax             virtual iter_type do_get_date(iter_type s,
                                                 iter_type end,
                                                 ios_base& str,
                                                 ios_base::iostate& err,
                                                 tm *t) const;

Parameters         s is an input iterator that points to the beginning
                   character of a character sequence.

                   end is an input iterator that points to the end
                   character of a character sequence.

                   str is the reference to the ios_base object.

                   err is set to ios_base::failbit when an error
                   occurs.

                   t is the struct tm in which the date field is
                   stored.

Returns            This method returns an iterator that points
                   immediately beyond the last character of the valid
                   date field.

Description

The do_get_date() method reads the characters from the character sequence (s, end] until it has extracted the members of the struct tm and the all of the remaining format characters that were used by time_put< >::put object. Characters are extracted until all the members of the struct tm has been removed, until an error has been encountered or the end of the sequence has been reached. The results are stored in the struct tm. It returns an iterator that points immediately beyond the last character of the valid date field. If the buffer does not contain a valid date (this being an error), the member function will set the err argument to the ios_base::failbit. But if the return value equals last, then the member function will set ios_base::eofbit in str.

Method             do_get_monthname()

Access             Protected

Classification     Accessor

Syntax             virtual iter_type do_get_monthname(iter_type s,
                                                      iter_type end,
                                                      ios_base& str,
                                                      ios_base::iostate& err,
                                                      tm *t) const;

Parameters         s is an input iterator that points to the beginning
                   character of a character sequence.

                   end is an input iterator that points to the end
                   character of a character sequence.

                   str is the reference to the ios_base object.

                   err is set to ios_base::failbit when an error
                   occurs.

                   t is the struct tm in which the month name field
                   is stored.

Returns            This method returns an iterator that points
                   immediately beyond the last character of the
                   month name date field.

Description

The do_get_monthname() method reads the characters from the character sequence (s,end] until it has extracted the name of the month (perhaps an abbreviation). If the sequence is an abbreviation, the member function will continue to extract the characters from the sequence until the full name is a match or it fails. If successful, the results are stored in the appropriate member of the struct tm t argument. If an error occurs, then err will be set to ios_base::failbit. It returns an iterator that points immediately beyond the last character of the valid date field.

Method             do_get_weekday()

Access             Protected

Classification     Accessor

Syntax             virtual iter_type do_get_weekday(iter_type s,
                                                    iter_type end,
                                                    ios_base& str,
                                                    ios_base::iostate& err,
                                                    tm *t) const;

Parameters         s is an input iterator that points to the beginning
                   character of a character sequence.

                   end is an input iterator that points to the end
                   character of a character sequence.

                   str is the reference to the ios_base object.

                   err is set to ios_base::failbit when an error
                   occurs.

                   t is the struct tm in which the weekday field
                   is stored.

Returns            This method returns an iterator that points
                   immediately beyond the last character of the valid
                   weekday field.

Description

The do_get_weekday() method reads the characters from the character sequence (s,end] until it has extracted the name of the weekday (perhaps an abbreviation). If the sequence is an abbreviation, the member function will continue to extract the characters from the sequence until the full name is a match or it fails. If successful, the results are stored in the appropriate member of the struct tm t argument. If an error occurs, then err will be set to ios_base::failbit. It returns an iterator that points immediately beyond the last character of the valid weekday field.

Method             do_get_time()

Access             Protected

Classification     Accessor

Syntax             virtual iter_type do_get_time(iter_type s,
                                                 iter_type end,
                                                 ios_base& str,
                                                 ios_base::iostate& err,
                                                 tm *t) const;

Parameters         s is an input iterator that points to the
                   beginning character of a character sequence.

                   end is an input iterator that points to the
                   end character of a character sequence.

                   str is the reference to the ios_base object.

                   err is set to ios_base::failbit when an error
                   occurs.

                   t is the struct tm in which the time field is
                   stored.

Returns            This method returns an iterator that points
                   immediately beyond the last character of the valid
                   time field.

Description

The do_get_time() method reads the characters from the character sequence (s,end] until it has extracted the time field. The results are stored in the appropriate member of the struct tm t. If an error occurs, then err will be set to ios_base::failbit. It returns an iterator that points immediately beyond the last character of the valid time field.

Method             do_get_year()

Access             Protected

Classification     Accessor

Syntax             virtual iter_type do_get_year(iter_type s,
                                                 iter_type end,
                                                 ios_base& str,
                                                 ios_base::iostate& err,
                                                 tm *t) const;

Parameters         s is an input iterator that points to the
                   beginning character of a character sequence.

                   end is an input iterator that points to the
                   end character of a character sequence.

                   str is the reference to the ios_base object.

                   err is set to ios_base::failbit when an error
                   occurs.

                   t is the struct tm in which the year field
                   is stored.

Returns            The method returns an iterator that points
                   immediately beyond the last character of the valid
                   year field.

Description

The do_get_year() method reads the characters from the character sequence (s,end] until it has extracted the year field. The manner in which the year is represented is implementation-defined. The results are stored in the appropriate member of the struct tm t. If an error occurs, then err will be set to ios_base::failbit. It returns an iterator that points immediately beyond the last character of the valid year field.

Method             time_get_byname()

Access             Public

Classification     Constructor

Syntax             explicit time_get_byname(const char* name, size_t refs = 0);

Parameters         name is the name of the named locale.

                   refs, if the refs argument = 0 then the destruction
                   of the object is delegated to the locale or locales
                   which contain it. If refs = 1 then the object must
                   be explicitly deleted. The locale will not delete
                   it. The object can then be maintained across the
                   lifetime of multiple locales.

Returns            None

Description

This constructor constructs a time_get_byname facet object for a named locale specified by the name argument.

Method             time_get_byname()

Access             Protected

Classification     Destructor

Syntax             ~time_get_byname();

Parameters         None

Returns            None

Description

This destructor destroys a time_get_byname facet object.

The Class Relationship Diagram for time_get_byname


time_put_byname

Class Name            time_put_byname

Header File          <locale>

Classification      abstract data type
Class Relationship Diagram

Class Description

Member Classes

locale::id

Methods

virtual iter_type do_put(iter_type s, ios_base&, char_type,
const tm* t, char format, char modifier) const;

explicit time_put_byname(const char*, size_t refs = 0);

~time_put_byname();

Class Description

The time_put_byname class describes a class that provides the same functionality as the time_put class for a named locale.

locale::id

locale::id is a class used to provide an identification of a locale facet interfaces used as an index for lookup and to encapsulate initialization.

Method             do_put()

Access             Protected

Classification     Modifier

Syntax             virtual iter_type do_put(iter_type s, ios_base& str,
                                            char_type fill, const tm* t,
                                            char format,
                                            char modifier) const;

Parameters         s is an iterator that points to the character
                   buffer used for output.

                   str is a reference to the ios_base object.

                   fill is the character used for padding.

                   t is the structure that contains the
                   date/time values.

                   format is a specifier used to control formatting.

                   modifier is a modifier used to control formatting.

Returns            The method returns an iterator that points to the
                   character past the last character produced.

Description

The do_put() method formats the date/time contained in the parameter t. It writes out a character string that is placed character buffer pointed to by s. The string is formatted according to the parameters format and modifier. They are iterpreted identically in the same way as the strftime function that interprets its format and modifer flags. The fill character is used for padding. The method returns an iterator that points to the character past the last character produced.

Method             time_put_byname()

Access             Public

Classification     Constructor

Syntax             explicit time_put_byname(const char* name,
                                            size_t refs = 0);

Parameters         name is the name of the named locale.

                   refs, if the refs argument = 0 then the destruction
                   of the object is delegated to the locale or locales
                   which contain it. If refs = 1 then the object must
                   be explicitly deleted. The locale will not delete
                   it. The object can then be maintained across the
                   lifetime of multiple locales.

Returns            None

Description

The constructor constructs a time_put_byname facet object for the named locale.

Method             time_put_byname()

Access             Protected

Classification     Destructor

Syntax             ~time_put_byname();

Parameters         None

Returns            None

Description

This destructor destroys the time_put_byname facet object.

The Class Relationship Diagram for time_put_byname


type_info

Class Name            type_info

Header File          <typeinfo>

Classification      Runtime Support
Class Relationship Diagram

Class Description

Member Classes

None

Methods

bool before(const type_info&) const;

const char* name() const;

virtual ~type_info();

Operators

bool operator==(const type_info&) const;

bool operator!=(const type_info&) const;

Class Description

The type_info class describes a class stores a pointer to a name for the object type. When pointers can be of a base or derived types, this class can be used to detect the type of object at runtime. The type_info object has the operator==() and operator!=() defined to compare types.

Method             type_info()

Access             Public

Classification     Destructor

Syntax             virtual ~type_info();

Parameters         None

Returns            None

Description

The destructor destroys a type_info object.

Method             operator==()

Access             Public

Classification     Accessor

Syntax             bool operator==(const type_info& rhs) const;

Parameters         rhs is the type_info object to be compared to the
                   current object.

Returns            This operator returns true if the type_info objects
                   describe the same type.

Description

The equality operator will return a bool value true if the type_info objects describe the same type.

Method             operator!=()

Access             Public

Classification     Accessor

Syntax             bool operator!=(const type_info& rhs) const;

Parameters         rhs is the type_info object to be compared to the
                   current object.

Returns            This operator returns true if the type_info objects
                   are not the same type.

Description

The inequality operator will return a bool value true if the type_info objects are not the same type.

Method             before()

Access             Public

Classification     Accessor

Syntax             bool before(const type_info& x) const;

Parameters         x is a reference to type_info object in which
                   the method determines whether the current object
                   precedes this object.

Returns            This method returns true if the current object
                   precedes type_info x.

Description

The before() method is used to the determine order of these objects. This will allow type_info objects to be sorted. The ordering has nothing to do with inheritance order. The before() method returns a bool value true if the calling type_info object precedes the type_info object passed as a x. The manner in which the type_info objects are sorted is not defined and may differ from one program to another or even different executions of the same program. It is safe to assume that the collating sequence is similar or connected to the address operator.

Method             name()

Access             Public

Classification     Accessor

Syntax             const char* name() const;

Parameters         None

Returns            This method returns a pointer to a null terminated
                   string which represents the name of a type.

Description

The method name() will return the name of a type. It returns a const char* to a null terminated string.

The Class Relationship Diagram for type_info


The underflow_error Class

Class Name            underflow_error

Header File           <stdexcept>

Classification      Exception
Class Relationship Diagram

Class Description

Member Classes

None

Methods

underflow_error(const string &What_Arg)

Example

Class Description

The underflow_error class is derived from the runtime_error class. The underflow_error class represents exceptions that occur because arithmetic overflow error.

Method            underflow_error()

Access            Public

Classification    Constructor

Syntax            underflow_error(const string &What_Arg)

Parameters        The What_Arg parameter should contain a description of the kind of exception
                  that has occurred.

Return            None

Description

The underflow_error() method constructs an object of type underflow_error. The What_Arg parameter can be used to set a description of the kind of error that this exception represents. A set possible solutions is sometimes supplied with the exception description in addition to the type of error.

The Class Relationship Diagram of underflow_error

    1
    2   #include <stdexcept>
    3
    4
    5   void main(void)
    6   {
    7
    8
    9      try{
   10
   11            exception X;
   12            throw(X);
   13      }
   14      catch(const exception &X)
   15      {
   16          cout << X.what() << endl;
   17
   18      }
   19
   20      try
   21      {
   22          underflow_error UnderFlow("Arithmetic Operation Underflow");
   23          throw(UnderFlow);
   24      }
   25      catch(const exception &X)
   26      {
   27          cout << X.what() << endl;
   28      }
   29
   30
   31
   32   }
   33


The valarray Class

Class Name            valarray

Header File          <valarray>

Classification      ADT (Format Class)
Class Description

Member Classes

None

Methods

valarray<T> apply(T func(T)) const

valarray<T> apply(T func(const T&)) const

valarray<T> cshift(int Num) const

T max() const

T min() const

void resize(size_t Sz, T Value = T()

valarray<T> shift (int) const

size_t size() const

T sum() const

valarray()

explicit valarray(size_t Sz)

valarray(const T &X, size_t Sz)

valarray(const T *X, size_t Sz)

valarray(const valarray &X)

valarray(const slice_array &X)

valarray(const gslice_array &X)

valarray(const mask_array &X)

valarray(const indirect_array &X)

~valarray()

Operators

Functions

Example

Class Description

The valarray class is single dimension array that is optimized specifically for mathematical operations. The valarray class is designed to provide vector operations on numeric values. The valarray class defines vector addition, vector substraction. Scalar vector multiplication, and a host of transendental mathematical functions. The standard vector class does not provide these mathematical operations.

Method            apply()

Access            Public

Classification    Accessor

Syntax            valarray<T> apply(T func(T)) const

Parameters        func is the name of a function that takes a single argument
                  T is the type of elements  that are contained in the
                  valarray.

Return            The method returns a copy of the valarray that has been modified
                  by func.

Description

This apply() method applies the function func to each element of the valarray. It returns a new valarray with the new values that were generated by func.

Method            apply()

Access            Public

Classification    Accessor

Syntax            apply(T func(const T&)) const

Parameters        func is the name of a function that takes a single argument
                  T is the type of elements  that are contained in the
                  valarray.

Return            The method returns a copy of the valarray that has been modified
                  by func.

Description

This apply() method applies the function func to each element of the valarray. It returns a new valarray with the new values that were generated by func.

Method            cshift()

Access            Public

Classification    Accessor

Syntax            cshift(int Num) const

Parameters        Num is the number of positions to the left to shift the valarray.

Return            This method returns a copy of the valarray with each element shifted
                  Num positions.

Description

The cshift() method returns a valarray that has been left shifted Num positions. If Num is negative Then the shift starts with the element[abs(Num)] at stores that element at position Zero and performs a circular shift of the remaining elements accordingly.

Method            max()

Access            Public

Classification    Accessor

Syntax            T max() const

Parameters        None

Return            The largest element in the valarray object.

Description

The max() method returns the largest element in the valarray object.

Method            min()

Access            Public

Classification    Accessor

Syntax            T min() const

Parameters        None

Return            The smallest element in the valarray object.

Description

The min() method returns the smallest element in the valarray object.

Method            resize()

Access            Public

Classification    Accessor

Syntax            void resize(size_t Sz, T Value = T()

Parameters        Sz is the new size of the valarray.  Value will be used to initialize
                  each element in the valarray.

Return            None

Description

The resize() method resizes the valarray so that it has Sz elements. Value is assigned to each element in the valarray. All pointers and references to elements in the valarray prior to the resize() call are invalid.

Method            shift()

Access            Public

Classification    Accessor

Syntax            valarray<T> shift (int Num) const

Parameters        Num is the number of positions to the left to shift the valarray.

Return            This method returns a copy of the valarray with each element shifted
                  Num positions.

Description

The shift() method returns a valarray that has been left shifted Num positions. If Num is negative Then the shift starts with the element[abs(Num)] at stores that element at position Zero and shifts of the remaining elements accordingly.

Method            size()

Access            Public

Classification    Accessor

Syntax            valarray<T> size () const

Parameters        None

Return            This method returns the number of elements in the valarray.

Description

The size() method returns the number of elements in the valarray.

Method            sum()

Access            Public

Classification    Accessor

Syntax            T sum () const

Parameters        None

Return            This method returns the sum of the elements in the valarray.

Description

The sum() method returns the sum of the of elements in the valarray.

Method            valarray()

Access            Public

Classification    Modifier

Syntax            valarray()

Parameters        None

Return            None

Description

This valarray() method constructs an empty valarray.

Method            valarray()

Access            Public

Classification    Modifier

Syntax            explicit valarray(size_t Sz)

Parameters        Sz is the number of elements that the valarray will contain.

Return            None

Description

This valarray() method constructs an valarray that has Sz number of elements.

Description

This valarray() method constructs an empty valarray.

Method            valarray()

Access            Public

Classification    Modifier

Syntax            valarray(const T &X, size_t Sz)

Parameters        Sz is the number of elements that the valarray will contain.
                  The elements in the valarray will be initialized with X.

Return            None

Description

This valarray() method constructs an valarray that has Sz number of elements and that are initialized with the value of X.

Description

This valarray() method constructs an empty valarray.

Method            valarray()

Access            Public

Classification    Modifier

Syntax            valarray(const T *X, size_t Sz)

Parameters        Sz is the number of elements that the valarray will contain.
                  The elements in the valarray will be initialized with X.

Return            None

Description

This valarray() method constructs an valarray that has Sz number of elements and that are initialized with the first Sz values that X points to. X should point to at least Sz elements. If X points to less than Sz elements the results of this construction are unpredictable.

Description

This valarray() method constructs an empty valarray.

Method            valarray()

Access            Public

Classification    Modifier

Syntax            valarray(const valarray &X)

Parameters        X is an vector used to construct this valarray.

Return            None

Description

This valarray() method constructs a valarray from the vector X. The valarray will contain copies of the elements in X.

Method            valarray()

Access            Public

Classification    Modifier

Syntax            valarray(const slice_array &X)

Parameters        X is a slice_array used to construct this valarray.

Return            None

Description

This valarray() is constructed using the elements of the slice_array X.

Method            valarray()

Access            Public

Classification    Modifier

Syntax            valarray(const gslice_array &X)

Parameters        X is a gslice_array used to construct this valarray.

Return            None

Description

This valarray() is constructed using the elements of the gslice_array X.

Method            valarray()

Access            Public

Classification    Modifier

Syntax            valarray(const mask_array &X)

Parameters        X is a mask_array used to construct this valarray.

Return            None

Description

This valarray() is constructed using the elements of the mask_array X.

Method            valarray()

Access            Public

Classification    Modifier

Syntax            valarray(const indirect_array &X)

Parameters        X is a indirect_array used to construct this valarray.

Return            None

Description

This valarray() is constructed using the elements of the indirect_array X.

Method            valarray()

Access            Public

Classification    Modifier

Syntax            ~valarray()

Parameters        None

Return            None

Description

This ~valarray() destructs an object of type valarray.

valarray: Arithmetic Operations Description

___________________________________________________________________________________
Computed Assignment
    +=			addition
    -=			subtraction
    %=			modulus
    *=			multiplication
    /=			division

Global Operators
    sin()			sine
    sinh()			hyperbolic sine
    asin()			arcsine
    cos()			cosine
    cosh()			hyperbolic cosine
    acos()			arccosine
    tan()			tangent
    tanh()			hyperbolic tangent
    atan()			arctangent
    atan2()			arctangent of x[i] / y[i]
    pow()			raised to a power
    exp()			base e exponential
    log()			base e logarithm
    log10()			base 10 logarithm
    abs()			magnitude
    sqrt()			square root

___________________________________________________________________________________
NOTE: There is a global non-assignment counterpart for all bolded member operators.

    1   #include <valarray>
    2   #include <iostream>
    3
    4
    5   using namespace std;
    6
    7
    8   double triple(double X)
    9   {
   10         return(X * X * X);
   11   }
   12
   13   void main(void)
   14   {
   15
   16       valarray<double> X(5);
   17       int N;
   18       for(N = 0; N < 5;N++)
   19       {
   20           X[N] = N+5;
   21       }
   22       valarray<double> Y =  abs(sin(X));
   23       valarray<double> Z =  abs(cos(Y));
   24       Z = Z * Y;
   25       valarray<double> Alpha = Z.apply(triple);
   26       for(N = 0; N < Alpha.size();N++)
   27       {
   28           cout << X[N]  << '\t' << Y[N] << '\t' << Z[N] << '\t'<< Alpha[N] << endl;
   29       }
   30   }


The vector Class

Class Name            vector

Header File           <vector>

Classification      Container
Class Description

Member Classes

None

Methods

template <class InputIterator> void assign(InputIterator First, InputIterator Last)

template <class Size, class U> void assign(Size n, const U& u = U())

reference at(size_type N)

const_reference at(size_type N) const

reference back()

const_reference back() const

iterator begin()

const_iterator begin() const

size_type capacity() const

void clear()

iterator end()

const_iterator end() const

iterator erase(iterator Pos)

iterator erase(iterator First, iterator Last)

reference front()

const_reference front() const

allocator_type get_allocator() const

iterator insert(iterator position, const T& x = T())

void insert(iterator position, size_type n, const T& x)

template <class InputIterator> void insert(iterator Pos, InputIterator First, InputIterator Last)

size_type max_size() const

void pop_back()

void push_back(const T& X)

reverse_iterator rbegin()

const_reverse_iterator rbegin() const

reverse_iterator rend()

void reserve(size_type N)

void resize(size_type Sz, T C = T())

const_reverse_iterator rend() const

size_type size() const

void swap(vector<T,Allocator>& X)

explicit vector(const Allocator& = Allocator())

explicit vector(size_type n, const T& value = T(),const Allocator& = Allocator())

template <class InputIterator>vector(InputIterator First, InputIterator Last,const Allocator& = Allocator())

vector(const vector<T,Allocator>& X)

~vector()

Operators

vector<T,Allocator>& operator=(const vector<T,Allocator>& X); reference operator[](size_type N); const_reference operator[](size_type N) const;

Example

Class Description

Like the traditional C++ array, a vector is a container that provides direct access to the objects it contains. The object oriented vector is a dynamic structure. This means that its size is not fixed. The size of the C++ vector may grow or shrink during program execution. This one of primary advantages of using the object oriented vector over using the traditional C++ array.

Method            at()

Access            Public

Classification    Accessor

Syntax            reference at(size_type N)

Parameters        N is the position in the container

Return            This method returns a reference to the object at position N in the container.

Description

The at() method returns the object located at position N in the container.

Method            back()

Access            Public

Classification    Accessor

Syntax            reference back()

Parameters        None

Return            This method returns a reference to the object at end of the container.

Description

The back() method returns the object located at end of the container.

Method            capacity()

Access            Public

Classification    Accessor

Syntax            size_type capacity() const

Parameters        None

Return            This method returns the largest number of objects that the container
                  can store without reallocation.

Description

The capacity() method returns the largest number of objects that the container can store without reallocation.

Method            front()

Access            Public

Classification    Accessor

Syntax            reference front()

Parameters        None

Return            This method returns a reference to the object at the front of the container.

Description

The front() method returns the object at the head/front of the container.

Method            pop_back()

Access            Public

Classification    Modifier

Syntax            void pop_back()

Parameters        None

Return            None

Description

The pop_back() method removes the last object from the container. The container must be contain elements prior to the call to pop_back().

Method            push_back()

Access            Public

Classification    Modifier

Syntax            void push_back(const T& X)

Parameters        X is the object to be inserted into the rear of the container.

Return            None

Description

The push_back() method inserts an element X at the end of the container.

Method            reserve()

Access            Public

Classification    Modifier

Syntax            void reserve(size_type N)

Parameters        N is the number of objects that the reserve method should reserve
                  space for.

Return            None

Description

The reserve() method insures that space for N objects has been allocated for the container. If size() == N no action is taken. However if N > size() then the reserve method allocates the additional space necessary. Any pointers or references to objects in the container at the time a reallocation takes place become invalid.

Method            swap()

Access            Public

Classification    Modifier

Syntax            void swap(vector<T,Allocator>& X)

Parameters        X is the vector to be swapped with the contents of the current vector.

Return            X is the vector to be swapped.

Description

The swap() method swaps the contents of the current vector with vector X.

Method            vector()

Access            Public

Classification    Constructor

Syntax            explicit vector(const Allocator& X = Allocator())

Parameters        X is a allocator object.

Return            None.

Description

The vector() method constructs an empty vector container.

Method            vector()

Access            Public

Classification    Constructor

Syntax            explicit vector(size_type N, const T& Value = T(),const Allocator& X = Allocator())

Parameters        X is a allocator object.  N is the number of objects that have been initialized
                  with value that will be inserted into the vector.

Return            None.

Description

The vector() method constructs a vector that contains N objects that have been initialized to value.

Method            vector()

Access            Public

Classification    Constructor

Syntax            template <class InputIterator>vector(InputIterator First, InputIterator Last,const Allocator &X = Allocator())

Parameters        The range [First,Last) will be used to construct the vector object. X is an allocator object.

Return            None.

Description

The vector() method constructs a vector that contains copies of the objects that are located in the range [First,Last).

Method            vector()

Access            Public

Classification    Constructor

Syntax            vector(const vector<T,Allocator>& X)

Parameters         X is a vector used to construct a new vector.

Return            None.

Description

The vector() method constructs a vector that contains a copy of vector X.

Method            vector()

Access            Public

Classification    Destructor

Syntax            ~vector()

Parameters        None.

Return            None.

Description

The ~vector() method destructs a vector object.

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

void main(void)
{
   vector<char> VectB;
   vector<char>::iterator P;
   VectB.push_back('B');
   VectB.push_back('@');
   VectB.push_back('#');
   VectB.push_back('Z');
   VectB.push_back('%');
   P = VectB.begin();
   P += 2;
   vector<char> VectA(P,VectB.end());
   int N = 0;
   for(N = 0;N < VectA.size();N++)
   {
    cout << VectA[N] << endl;
   }
   vector<char>VectC(VectA);
   ostream_iterator<char> Out(cout," ");
   copy(VectC.begin(),VectC.end(),Out);

}


logical view of standard classes

The Logical View of the Standard C++ Classes