======================================================================== +-----------------------------------------------------------+ |catch export reinterpret_cast throw typename| |const_cast mutable static_cast try using | |dynamic_cast namespace template typeid wchar_t | +-----------------------------------------------------------+ ======================================================================== |
======================================================================== void* operator new(size_t); void* operator new[](size_t); void operator delete(void*); void operator delete[](void*); ======================================================================== |
======================================================================== unqualified-id: identifier operator-function-id conversion-function-id ~ class-name nested-name-specifier: class-or-namespace-name :: nested-name-specifier_opt ======================================================================== |
======================================================================== postfix-expression: primary-expression postfix-expression [ expression ] postfix-expression ( expression-list_opt ) simple-type-specifier ( expression-list_opt ) postfix-expression . template_opt id-expression postfix-expression -> template_opt id-expression postfix-expression . pseudo-destructor-name postfix-expression -> pseudo-destructor-name postfix-expression ++ postfix-expression -- pseudo-destructor-name: ::_opt nested-name-specifier_opt type-name :: ~ type-name ::_opt nested-name-specifier_opt ~ type-name ======================================================================== |
======================================================================== assignment-expression: conditional-expression logical-or-expression assignment-operator assignment-expression ======================================================================== |
======================================================================== statement: labeled-statement expression-statement compound-statement selection-statement iteration-statement jump-statement declaration-statement ======================================================================== |
======================================================================== declaration: block-declaration function-definition linkage-specification block-declaration: simple-declaration asm-definition ======================================================================== |
======================================================================== storage-class-specifier: auto register static extern ======================================================================== |
======================================================================== const int ci = 3; // cv-qualified (initialized as required) ci = 4; // ill-formed: attempt to modify const int i = 2; // not cv-qualified const int* cip; // pointer to const int cip = &i; // OK: cv-qualified access path to unqualified *cip = 4; // ill-formed: attempt to modify through ptr to const int* ip; ip = (int*)(cip); // cast needed to convert const int* to int* *ip = 4; // defined: *ip points to i, a non-const object const int* ciq = new const int (3); // initialized as required int* iq = (int*)(ciq); // cast required *iq = 4; // undefined: modifies a const object ======================================================================== |
======================================================================== simple-type-specifier: ::_opt nested-name-specifier_opt type-name char bool short int long signed unsigned float double ======================================================================== |
======================================================================== elaborated-type-specifier: class-key ::_opt nested-name-specifier_opt identifier enum ::_opt nested-name-specifier_opt identifier ======================================================================== |
======================================================================== function-definition: decl-specifier-seq_opt declarator ctor-initializer_opt function-body ======================================================================== |
======================================================================== class-name: identifier class-head: class-key identifier_opt base-clause_opt class-key nested-name-specifier identifier base-clause_opt ======================================================================== |
======================================================================== member-declarations: decl-specifier-seq_opt member-declarator-list_opt ; function-definition ;_opt ::_opt nested-name-specifier template_opt unqualified-id ; using-declaration ======================================================================== |
======================================================================== base-specifier-list: base-specifier base-specifier: ::_opt nested-name-specifier_opt class-name ======================================================================== |
======================================================================== struct B { B(int); /* ... */ }; struct D : B { D(int); B b; const int c; } D::D(int a) : B(a+1), c(a+3), b(a+4) { /* ... */ } D d(10); ======================================================================== |
======================================================================== 4 The strings components provide support for manipulating text represented as sequences of type char. ======================================================================== |
======================================================================== character means only char objects in Embedded C++ Standard library. ======================================================================== |
======================================================================== a group of library entities directly related as members, parameters, or return types. For example, the class string and the non-member functions that operate on strings are referred to as the string component. ======================================================================== |
======================================================================== class defined in clause 27. ======================================================================== |
======================================================================== classes in Embedded C++ Standard library and The traditional iostream classes are regarded as the narrow-oriented iostream classes (27.3.1). ======================================================================== |
======================================================================== - Throws: the conditions that would cause the undefined behavior ======================================================================== |
======================================================================== The bitmasks can be written: enum bitmask { V0 = 1 << 0,V1 = 1 << 1,V2 = 1 << 2, V3 = 1 << 3, ..... }; static const bitmask C0(V0); static const bitmask C1(V1); static const bitmask C2(V2); static const bitmask C3(V3); ..... bitmask& operator&=(bitmask& X, bitmask Y) { X = bitmask(X & Y); return X;} bitmask& operator|=(bitmask& X, bitmask Y) { X = bitmask(X | Y); return X;} bitmask& operator^=(bitmask& X, bitmask Y) { X = bitmask(X ^ Y); return X;} bitmask operator& (bitmask X, bitmask Y) { return bitmask(X & Y);} bitmask operator| (bitmask X, bitmask Y) { return bitmask(X | Y);} bitmask operator^ (bitmask X, bitmask Y) { return bitmask(X ^ Y);} bitmask operator~ (bitmask X) { return (bitmask)~X;} ======================================================================== |
======================================================================== +-----------------------------------------------------------------+ | <complex> <istream> | | <iomanip> <new> | | <ios> <ostream> | | <iosfwd> <streambuf> | | <iostream> <string> | +-----------------------------------------------------------------+ ======================================================================== |
======================================================================== +--------------------------------------------------+ |<cctype> <ciso646> <csetjmp> <cstdio> | |<cerrno> <climits> <cstdarg> <cstdlib> | |<cfloat> <cmath> <cstdef> <cstring> | +--------------------------------------------------+ ======================================================================== |
======================================================================== 1 In certain cases (replacement functions, handler functions, operations on types used in standard library components), the C++ Standard library depends on components supplied by a C++ program. If these components do not meet their requirements, the Standard places no requirements on the implementation. ======================================================================== |
======================================================================== 1 Violation of the preconditions specified in a function's Required behavior paragraph results in undefined behavior. ======================================================================== |
======================================================================== Header <new> synopsis typedef void (*new_handler)(); new_handler set_new_handler(new_handler new_P); void * operator new(size_t size); void operator delete(void * ptr); void * operator new[](size_t); void operator delete[](void * ptr); void * operator new(size_t size,void * ptr); void * operator new[](size_t size,void * ptr); void operator delete(void * ptr, void *); void operator delete[](void * ptr,void *); ======================================================================== |
======================================================================== void* operator new(size_t size); 3 Required behavior: Return a non-null pointer to suitably aligned storage(3.7.3), or else the behavior is undefined. This requirement is binding on a replacement version of this function. 4 Default behavior: --Executes a loop: Within the loop, the function first attempts to allocate the requested storage. Whether the attempt involves a call to the Standard C library function malloc is unspecified. --Returns a pointer to the allocated storage if the attempt is suc- cessful. Otherwise, if the last argument to set_new_handler() was a null pointer, the behavior is undefined. --Otherwise, the function calls the current new_handler. If the called function returns, the loop repeats. --The loop terminates when an attempt to allocate the requested stor- age is successful or when a called new_handler function does not return. ======================================================================== |
======================================================================== void operator delete(void* ptr); |
======================================================================== void* operator new[](size_t size); ======================================================================== |
======================================================================== void operator delete[](void* ptr); 11 Required behavior: accept a value of ptr that is null or that was returned by an earlier call to operator new[](size_t). 12 Default behavior: --For a null value of ptr, does nothing. --Any other value of ptr shall be a value returned earlier by a call to the default operator new[](size_t).212) For such a non-null value of ptr, reclaims storage allocated by the earlier call to the default operator new[]. ======================================================================== |
======================================================================== 2 Required behavior: A new_handler shall perform one of the following: --make more storage available for allocation and then return; --otherwise the behavior is undefined. 3 Default behavior: The implementation's default new_handler is undefined. ======================================================================== |
======================================================================== Header <string> synopsis // 21.3, string: class string; string operator + (const string &lhs,const string &rhs); string operator + (const char *lhs,const string &rhs); string operator + (char lhs,const string &rhs); string operator + (const string &lhs,const char *rhs); string operator + (const string &lhs,char rhs); bool operator == (const string &lhs,const string &rhs); bool operator == (const char *lhs,const string &rhs); bool operator == (const string &lhs,const char *rhs); bool operator != (const string &lhs,const string &rhs); bool operator != (const char *lhs,const string &rhs); bool operator != (const string &lhs,const char *rhs); bool operator < (const string &lhs,const string &rhs); bool operator < (const string &lhs,const char *rhs); bool operator < (const char *lhs,const string &rhs); bool operator > (const string &lhs,const string &rhs); bool operator > (const string &lhs,const char *rhs); bool operator > (const char *lhs,const string &rhs); bool operator <= (const string &lhs,const string &rhs); bool operator <= (const string &lhs,const char *rhs); bool operator <= (const char *lhs,const string &rhs); bool operator >= (const string &lhs,const string &rhs); bool operator >= (const string &lhs,const char *rhs); bool operator >= (const char *lhs,const string &rhs); // 21.3.7.8: void swap(string &lhs, string &rhs); istream & operator >> (istream &is,string &str); ostream & operator << (ostream &os,const string &str); istream & getline (istream &is,string &str,char delim); istream & getline (istream &is,string &str); ======================================================================== |
======================================================================== 1 For a char type , the class string describes objects that can store a sequence consisting of a varying number of arbitrary char objects (clause21). The first element of the sequence is at position zero. Such a sequence is also called a string if the given char type is clear from context. Storage for the string is allocated and freed as necessary by the member functions of class string. ======================================================================== |
======================================================================== class string { public: // types: typedef implementation defined iterator; // See 23.1 typedef implementation defined const_iterator; // See 23.1 static const size_t npos = -1; // 21.3.1 construct/copy/destroy: explicit string(void); string(const string& str, size_t pos = 0, size_t n = npos); string(const char* s, size_t n); string(const char* s); string(size_t n, char c); ~string(); string& operator=(const string& str); string& operator=(const char* s); string& operator=(char c); // 21.3.2 iterators: iterator begin(); const_iterator begin() const; iterator end(); const_iterator end() const; // 21.3.3 capacity: size_t size() const; size_t length() const; size_t max_size() const; void resize(size_t n, char c); void resize(size_t n); size_t capacity() const; void reserve(size_t res_arg = 0); void clear(); bool empty() const; // 21.3.4 element access: const char & operator[](size_t pos) const; char & operator[](size_t pos); const char & at(size_t n) const; char & at(size_t n); // 21.3.5 modifiers: string& operator+=(const string& str); string& operator+=(const char* s); string& operator+=(char c); string& append(const string& str); string& append(const string& str, size_t pos, size_t n); string& append(const char* s, size_t n); string& append(const char* s); string& append(size_t n, char c); string& assign(const string&); string& assign(const string& str, size_t pos, size_t n); string& assign(const char* s, size_t n); string& assign(const char* s); string& assign(size_t n, char c); string& insert(size_t pos1, const string& str); string& insert(size_t pos1, const string& str, size_t pos2, size_t n); string& insert(size_t pos, const char* s, size_t n); string& insert(size_t pos, const char* s); string& insert(size_t pos, size_t n, char c); iterator insert(iterator p, char c); void insert(iterator p, size_t n, char c); string& erase(size_t pos = 0, size_t n = npos); iterator erase(iterator position); iterator erase(iterator first, iterator last); string& replace(size_t pos1, size_t n1, const string& str); string& replace(size_t pos1, size_t n1, const string& str, size_t pos2, size_t n2); string& replace(size_t pos, size_t n1, const char* s, size_t n2); string& replace(size_t pos, size_t n1, const char* s); string& replace(size_t pos, size_t n1, size_t n2, char c); string& replace(iterator i1, iterator i2, const string& str); string& replace(iterator i1, iterator i2, const char* s, size_t n); string& replace(iterator i1, iterator i2, const char* s); string& replace(iterator i1, iterator i2, size_t n, char c); size_t copy(char* s, size_t n, size_t pos = 0) const; void swap(string&); // 21.3.6 string operations: const char* c_str() const; // explicit const char* data() const; size_t find (const string& str, size_t pos = 0) const; size_t find (const char* s, size_t pos, size_t n) const; size_t find (const char* s, size_t pos = 0) const; size_t find (char c, size_t pos = 0) const; size_t rfind(const string& str, size_t pos = npos) const; size_t rfind(const char* s, size_t pos, size_t n) const; size_t rfind(const char* s, size_t pos = npos) const; size_t rfind(char c, size_t pos = npos) const; size_t find_first_of(const string& str, size_t pos = 0) const; size_t find_first_of(const char* s, size_t pos, size_t n) const; size_t find_first_of(const char* s, size_t pos = 0) const; size_t find_first_of(char c, size_t pos = 0) const; size_t find_last_of (const string& str, size_t pos = npos) const; size_t find_last_of (const char* s, size_t pos, size_t n) const; size_t find_last_of (const char* s, size_t pos = npos) const; size_t find_last_of (char c, size_t pos = npos) const; size_t find_first_not_of(const string& str, size_t pos = 0) const; size_t find_first_not_of(const char* s, size_t pos, size_t n) const; size_t find_first_not_of(const char* s, size_t pos = 0) const; size_t find_first_not_of(char c, size_t pos = 0) const; size_t find_last_not_of (const string& str, size_t pos = npos) const; size_t find_last_not_of (const char* s, size_t pos, size_t n) const; size_t find_last_not_of (const char* s, size_t pos = npos) const; size_t find_last_not_of (char c, size_t pos = npos) const; string substr(size_t pos = 0, size_t n = npos) const; int compare(const string& str) const; int compare(size_t pos1, size_t n1, const string& str) const; int compare(size_t pos1, size_t n1, const string& str, size_t pos2, size_t n2) const; int compare(const char* s) const; int compare(size_t pos1, size_t n1, const char* s, size_t n2 = npos) const; }; ======================================================================== |
======================================================================== explicit string(void); ======================================================================== |
======================================================================== string(const string& str, size_t pos = 0, size_t n = npos); 4 Throws: if pos > str.size(), then the behavior is undefined. ======================================================================== |
======================================================================== string(const char* s, size_t n); 7 Throws: if n == pos, then the behavior is undefined. ======================================================================== |
======================================================================== string(const char* s); ======================================================================== |
======================================================================== string(size_t n, char c); 13 Throws: if n == npos, then the behavior is undefined. ======================================================================== |
======================================================================== string& operator=(const string& str); ======================================================================== |
======================================================================== string& operator=(const char* s); 18 Returns: *this = string(s). 19 Notes: Uses ::strlen(). string& operator=(char c); 20 Returns: *this = string(1,c). ======================================================================== |
======================================================================== 5 Throws: if n > max_size(), then the behavior is undefined. ======================================================================== |
======================================================================== 5 Throws: if reg_arg > max_size(), then the behavior is undefined. ======================================================================== |
======================================================================== const char & operator[](size_t pos) const; char & operator[](size_t pos); const char & at(size_t n) const; char & at(size_t n); 4 Throws: if pos >= size(), then the behavior is undefined. ======================================================================== |
======================================================================== string& operator+=(const string& str); 1 Returns: append(str). string& operator+=(const char* s); 2 Returns: *this += string(s). 3 Notes: Uses ::strlen(). string& operator+=(char c); 4 Returns: *this += string(1,c). ======================================================================== |
======================================================================== string& append(const string& str); string& append(const string& str, size_t pos, size_t n); 3 Throws: if pos > str.size(), then the behavior is undefined. 4 Effects: Determines the effective length rlen of the string to append as the smaller of n and str.size() - pos. If size() >= npos - rlen, then the behavior is undefined. Otherwise, the function replaces the string controlled by *this with a string of length size() + rlen whose first size() elements are a copy of the original string controlled by *this and whose remaining elements are a copy of the initial elements of the string controlled by str beginning at position pos. string& append(const char* s, size_t n); 6 Returns: append(string(s,n)). string& append(const char* s); 7 Returns: append(string(s)). 8 Notes: Uses ::strlen(). string& append(size_t n, char c); 9 Returns: append(string(n,c)). ======================================================================== |
======================================================================== string& assign(const string& str); string& assign(const string& str, size_t pos, size_t n); 3 Throws: if pos > str.size(), then the behavior is undefined. string& assign(const char* s, size_t n); 6 Returns: assign(string(s,n)). string& assign(const char* s); 7 Returns: assign(string(s)). 8 Notes: Uses ::strlen(). string& assign(size_t n, char c); 9 Returns: assign(string(n,c)). ======================================================================== |
======================================================================== string& insert(size_t pos1, const string& str); string& insert(size_t pos1, const string& str, size_t pos2, size_t n); 3 Throws: if pos1 > size() or pos2 > str.size(), the behavior is undefined. 4 Effects: Determines the effective length rlen of the string to insert as the smaller of n and str.size() - pos2. Then the behavior is undefined if size() >= npos - rlen. Otherwise, the function replaces the string controlled by *this with a string of length size() + rlen whose first pos1 elements are a copy of the initial elements of the original string controlled by *this, whose next rlen elements are a copy of the elements of the string controlled by str beginning at position pos2, and whose remaining elements are a copy of the remaining elements of the original string controlled by *this. string& insert(size_t pos, const char* s, size_t n); 6 Returns: insert(pos,string(s,n)). string& insert(size_t pos, const char* s); 7 Returns: insert(pos,string(s)). 8 Notes: Uses ::strlen(). string& insert(size_t pos, size_t n, char c); 9 Returns: insert(pos,string(n,c)). iterator insert(iterator p, char c); void insert(iterator p, size_t n, char c); ======================================================================== |
======================================================================== string& erase(size_t pos = 0, size_t n = npos); 2 Throws: if pos > size(), then the behavior is undefined. iterator erase(iterator p); iterator erase(iterator first, iterator last); ======================================================================== |
======================================================================== string& replace(size_t pos1, size_t n1, const string& str); string& replace(size_t pos1, size_t n1, const string& str, size_t pos2, size_t n2); 3 Throws: if pos1 > size() or pos2 > str.size(), then the behavior is undefined. 4 Effects: Determines the effective length xlen of the string to be removed as the smaller of n1 and size() - pos1. It also determines the effective length rlen of the string to be inserted as the smaller of n2 and str.size() - pos2 . 5 Throws: If size() - xlen >= npos - rlen, then the behavior is undefined. Otherwise, the function replaces the string controlled by *this with a string of length size() - xlen + rlen whose first pos1 elements are a copy of the initial elements of the original string controlled by *this, whose next rlen elements are a copy of the initial elements of the string controlled by str beginning at position pos2, and whose remaining elements are a copy of the elements of the original string controlled by *this beginning at position pos1 + xlen. string& replace(size_t pos, size_t n1, const char* s, size_t n2); 7 Returns: replace(pos,n1,string(s,n2)). string& replace(size_t pos, size_t n1, const char* s); 8 Returns: replace(pos,n1,string(s)). 9 Notes: Uses ::strlen(). string& replace(size_t pos, size_t n1, size_t n2, char c); 10 Returns: replace(pos,n1,string(n2,c)). string& replace(iterator i1, iterator i2, const string& str); string& replace(iterator i1, iterator i2, const char* s, size_t n); 15 Returns: replace(i1,i2,string(s,n)). string& replace(iterator i1, iterator i2, const char* s); 17 Returns: replace(i1,i2,string(s)). 18 Notes: Length change: ::strlen(s) - (i2 - i1). Uses ::strlen(). string& replace(iterator i1, iterator i2, size_t n, char c); 19 Returns: replace(i1,i2,string(n,c)). ======================================================================== |
======================================================================== size_t copy(char* s, size_t n, size_t pos = 0) const; 2 Throws: if pos > size(), then the behavior is undefined. ======================================================================== |
======================================================================== void swap(string& s); ======================================================================== |
======================================================================== size_t find(const string& str, size_t pos = 0) const; size_t find(const char* s, size_t pos, size_t n) const; 4 Returns: find(string(s,n),pos). size_t find(const char* s, size_t pos = 0) const; 5 Returns: find(string(s),pos). 6 Notes: Uses ::strlen(). size_t find(char c, size_t pos = 0) const; 7 Returns: find(string(1,c),pos). ======================================================================== |
======================================================================== size_t rfind(const string& str, size_t pos = npos) const; size_t rfind(const char* s, size_t pos, size_t n) const; 4 Returns: rfind(string(s,n),pos). size_t rfind(const char* s, size_t pos = npos) const; 5 Returns: rfind(string(s),pos). 6 Notes: Uses ::strlen(). size_t rfind(char c, size_t pos = npos) const; 7 Returns: rfind(string(1,c),pos). ======================================================================== |
======================================================================== size_t find_first_of(const string& str, size_t pos = 0) const; size_t find_first_of(const char* s, size_t pos, size_t n) const; 4 Returns: find_first_of(string(s,n),pos). size_t find_first_of(const char* s, size_t pos = 0) const; 5 Returns: find_first_of(string(s),pos). 6 Notes: Uses ::strlen(). size_t find_first_of(char c, size_t pos = 0) const; 7 Returns: find_first_of(string(1,c),pos). ======================================================================== |
======================================================================== size_t find_last_of(const string& str, size_t pos = npos) const; size_t find_last_of(const char* s, size_t pos, size_t n) const; 4 Returns: find_last_of(string(s,n),pos). size_t find_last_of(const char* s, size_t pos = npos) const; 5 Returns: find_last_of(string(s),pos). 6 Notes: Uses ::strlen(). size_t find_last_of(char c, size_t pos = npos) const; 7 Returns: find_last_of(string(1,c),pos). ======================================================================== |
======================================================================== size_t find_first_not_of(const string& str, size_t pos = 0) const; size_t find_first_not_of(const char* s, size_t pos, size_t n) const; 4 Returns: find_first_not_of(string(s,n),pos). size_t find_first_not_of(const char* s, size_t pos = 0) const; 5 Returns: find_first_not_of(string(s),pos). 6 Notes: Uses ::strlen(). size_ find_first_not_of(char c, size_t pos = 0) const; 7 Returns: find_first_not_of(string(1,c),pos). ======================================================================== |
======================================================================== size_t find_last_not_of(const string& str, size_t pos = npos) const; size_t find_last_not_of(const char* s, size_t pos, size_t n) const; 4 Returns: find_last_not_of(string(s,n),pos). size_t find_last_not_of(const char* s, size_t pos = npos) const; 5 Returns: find_last_not_of(string(s),pos). 6 Notes: Uses ::strlen(). size_t find_last_not_of(char c, size_t pos = npos) const; 7 Returns: find_last_not_of(string(1,c),pos). ======================================================================== |
======================================================================== string substr(size_t pos = 0, size_t n = npos) const; 2 Throws: if pos > size(), then the behavior is undefined. 4 Returns: string(data()+pos,rlen). ======================================================================== |
======================================================================== int compare(const string& str) const 1 Effects: Determines the effective length rlen of the strings to compare as the smallest of size() and str.size(). The function then compares the two strings by calling ::memcmp(data(), str.data(), rlen). int compare(size_t pos1, size_t n1, const string& str) const; 3 Returns: string(*this,pos1,n1).compare(str) . int compare(size_t pos1, size_t n1, const string& str, size_t pos2, size_t n2) const; 4 Returns: string(*this,pos1,n1).compare(string(str,pos2,n2)) . int compare(const char *s) const; 5 Returns: this->compare(string(s)). int compare(size_t pos, size_t n1, char *s, size_t n2 = npos) const; 6 Returns: string(*this,pos,n1).compare(string(s,n2)) ======================================================================== |
======================================================================== string operator+(const string& lhs, const string& rhs); 1 Returns: string(lhs).append(rhs) string operator+(const char* lhs, const string& rhs); 2 Returns: string(lhs) + rhs. 3 Notes: Uses ::strlen(). string operator+(char lhs, const string& rhs); 4 Returns: string(1,lhs) + rhs. string operator+(const string& lhs, const char* rhs); 5 Returns: lhs + string(rhs). 6 Notes: Uses ::strlen(). string operator+(const string& lhs, char rhs); 7 Returns: lhs + string(1,rhs). ======================================================================== |
======================================================================== bool operator==(const string& lhs, const string& rhs); bool operator==(const char* lhs, const string& rhs); 2 Returns: string(lhs) == rhs. bool operator==(const string& lhs, const char* rhs); 3 Returns: lhs == string(rhs). 4 Notes: Uses ::strlen(). ======================================================================== |
======================================================================== bool operator!=(const string& lhs, const string& rhs); bool operator!=(const char* lhs, const string& rhs); 2 Returns: string(lhs) != rhs. bool operator!=(const string& lhs, const char* rhs); 3 Returns: lhs != string(rhs). 4 Notes: Uses ::strlen(). ======================================================================== |
======================================================================== bool operator< (const string& lhs, const string& rhs); bool operator< (const char* lhs, const string& rhs); 2 Returns: string(lhs) < rhs. bool operator< (const string& lhs, const char* rhs); 3 Returns: lhs < string(rhs). ======================================================================== |
======================================================================== bool operator> (const string& lhs, const string& rhs); bool operator> (const char* lhs, const string& rhs); 2 Returns: string(lhs) > rhs. bool operator> (const string& lhs, const char* rhs); 3 Returns: lhs > string(rhs). ======================================================================== |
======================================================================== bool operator<=(const string& lhs, const string& rhs); bool operator<=(const char* lhs, const string& rhs); 2 Returns: string(lhs) <= rhs. bool operator<=(const string& lhs, const char* rhs); ======================================================================== |
======================================================================== bool operator>=(const string& lhs, const string& rhs); bool operator>=(const char* lhs, const string& rhs); 2 Returns: string(lhs) >= rhs. bool operator>=(const string& lhs, const char* rhs); 3 Returns: lhs >= string(rhs). ======================================================================== |
======================================================================== void swap(string& lhs, string& rhs); ======================================================================== |
======================================================================== 21.3.7.9 Inserters and extractors [lib.string.io] istream& operator>>(istream& is, string& str); 1 Effects: Begins by constructing a sentry object k as if k were constructed by typename istream::sentry k(is). If bool(k) is true, it calls str.erase() and then extracts characters from is and appends them to str as if by calling str.append(1,c). If is.width() is greater than zero, the maximum number n of characters appended is is.width(); otherwise n is str.max_size(). Characters are extracted and appended until any of the following occurs: - n characters are stored; - end-of-file occurs on the input sequence; - isspace(c) is true for the next available input character c. 2 After the last character (if any) is extracted, is.width(0) is called and the sentry object k is destroyed. 3 Returns: is ostream& operator<<(ostream& os, const string& str); 4 Effects: Begins by constructing a sentry object k as if k were constructed by ostream::sentry k(os). If bool(k) is true, inserts characters as if by calling os.rdbuf()->sputn(str.data(), n); then calls os.width(0). If the call to sputn fails, calls os.setstate(ios_base::failbit). 5 Returns: os istream& getline(istream& is, string& str, char delim); 6 Effects: Begins by constructing a sentry object k as if by typename istream::sentry k(is,true). If bool(k) is true, it calls str.erase() and then extracts characters from is and appends them to str as if by calling str.append(1,c) until any of the following occurs: - end-of-file occurs on the input sequence (in which case, the getline function calls is.setstate(ios_base::eofbit)). - c == delim for the next available input character c (in which case, c is extracted but not appended) (27.4.4.3) - str.max_size() characters are stored (in which case, the function calls is.setstate(ios_base::failbit) (27.4.4.3) 7 The conditions are tested in the order shown. In any case, after the last character is extracted, the sentry object k is destroyed. 8 If the function extracts no characters, it calls is.setstate(ios_base::failbit). 9 Returns: is. istream& getline(istream& is, string& str) 10 Returns: getline(is,str,'\n') ======================================================================== |
======================================================================== 1 The header <complex> defines 'float_complex', 'double_complex', and numerous functions for them. ======================================================================== |
======================================================================== class float_complex; class double_complex; // 26.2.6 operators: float_complex operator+(const float_complex&, const float_complex&); float_complex operator+(const float_complex&, const float&); float_complex operator+(const float&, const float_complex&); float_complex operator-(const float_complex&, const float_complex&); float_complex operator-(const float_complex&, const float&); float_complex operator-(const float&, const float_complex&); float_complex operator*(const float_complex&, const float_complex&); float_complex operator*(const float_complex&, const float&); float_complex operator*(const float&, const float_complex&); float_complex operator/(const float_complex&, const float_complex&); float_complex operator/(const float_complex&, const float&); float_complex operator/(const float&, const float_complex&); float_complex operator+(const float_complex&); float_complex operator-(const float_complex&); bool operator==(const float_complex&, const float_complex&); bool operator==(const float_complex&, const float&); bool operator==(const float&, const float_complex&); bool operator!=(const float_complex&, const float_complex&); bool operator!=(const float_complex&, const float&); bool operator!=(const float&, const float_complex&); istream& operator>>(istream&, float_complex&); ostream& operator<<(ostream&, const float_complex&); double_complex operator+(const double_complex&, const double_complex&); double_complex operator+(const double_complex&, const double&); double_complex operator+(const double&, const double_complex&); double_complex operator-(const double_complex&, const double_complex&); double_complex operator-(const double_complex&, const double&); double_complex operator-(const double&, const double_complex&); double_complex operator*(const double_complex&, const double_complex&); double_complex operator*(const double_complex&, const double&); double_complex operator*(const double&, const double_complex&); double_complex operator/(const double_complex&, const double_complex&); double_complex operator/(const double_complex&, const double&); double_complex operator/(const double&, const double_complex&); double_complex operator+(const double_complex&); double_complex operator-(const double_complex&); bool operator==(const double_complex&, const double_complex&); bool operator==(const double_complex&, const double&); bool operator==(const double&, const double_complex&); bool operator!=(const double_complex&, const double_complex&); bool operator!=(const double_complex&, const double&); bool operator!=(const double&, const double_complex&); istream& operator>>(istream&, double_complex&); ostream& operator<<(ostream&, const double_complex&); // 26.2.7 values: float real(const float_complex&); float imag(const float_complex&); float abs(const float_complex&); float arg(const float_complex&); float norm(const float_complex&); float_complex conj(const float_complex&); float_complex polar(const float&, const float&); double real(const double_complex&); double imag(const double_complex&); double abs(const double_complex&); double arg(const double_complex&); double norm(const double_complex&); double_complex conj(const double_complex&); double_complex polar(const double&, const double&); // 26.2.8 transcendentals: float_complex cos (const float_complex&); float_complex cosh (const float_complex&); float_complex exp (const float_complex&); float_complex log (const float_complex&); float_complex log10(const float_complex&); float_complex pow(const float_complex&, int); float_complex pow(const float_complex&, const float&); float_complex pow(const float_complex&, const float_complex&); float_complex pow(const float&, const float_complex&); float_complex sin (const float_complex&); float_complex sinh (const float_complex&); float_complex sqrt (const float_complex&); float_complex tan (const float_complex&); float_complex tanh (const float_complex&); double_complex cos (const double_complex&); double_complex cosh (const double_complex&); double_complex exp (const double_complex&); double_complex log (const double_complex&); double_complex log10(const double_complex&); double_complex pow(const double_complex&, int); double_complex pow(const double_complex&, const double&); double_complex pow(const double_complex&, const double_complex&); double_complex pow(const double&, const double_complex&); double_complex sin (const double_complex&); double_complex sinh (const double_complex&); double_complex sqrt (const double_complex&); double_complex tan (const double_complex&); double_complex tanh (const double_complex&); ======================================================================== |
======================================================================== class float_complex { public: typedef float value_type; float_complex(float re = 0.0f, float im = 0.0f); explicit float_complex(const double_complex&); float real() const; float imag() const; float_complex& operator= (float); float_complex& operator+=(float); float_complex& operator-=(float); float_complex& operator*=(float); float_complex& operator/=(float); float_complex& operator=(const float_complex&); float_complex& operator+=(const float_complex&); float_complex& operator-=(const float_complex&); float_complex& operator*=(const float_complex&); float_complex& operator/=(const float_complex&); }; class double_complex { public: typedef double value_type; double_complex(double re = 0.0, double im = 0.0); double_complex(const float_complex&); double real() const; double imag() const; double_complex& operator= (double); double_complex& operator+=(double); double_complex& operator-=(double); double_complex& operator*=(double); double_complex& operator/=(double); double_complex& operator=(const double_complex&); double_complex& operator+=(const double_complex&); double_complex& operator-=(const double_complex&); double_complex& operator*=(const double_complex&); double_complex& operator/=(const double_complex&); }; ======================================================================== |
======================================================================== float_complex(float re = 0.0f, float im = 0.0f); double_complex(double re = 0.0, double im = 0.0); Effects: 1 Constructs an object of class float_complex, double_complex. 2 Postcondition: real() == re && imag() == im. ======================================================================== |
======================================================================== float_complex& operator+=(float rhs); double_complex& operator+=(double rhs); float_complex& operator-=(float rhs); double_complex& operator-=(double rhs); float_complex& operator*=(float rhs); double_complex& operator*=(double rhs); float_complex& operator/=(float rhs); double_complex& operator/=(double rhs); float_complex& operator+=(const float_complex& rhs); double_complex& operator+=(const double_complex& rhs); float_complex& operator-=(const float_complex& rhs); double_complex& operator-=(const double_complex& rhs); float_complex& operator*=(const float_complex& rhs); double_complex& operator*=(const double_complex& rhs); float_complex& operator/=(const float_complex& rhs); double_complex& operator/=(const double_complex& rhs); ======================================================================== |
======================================================================== float_complex operator+(const float_complex& lhs); double_complex operator+(const double_complex& lhs); 1 Notes: unary operator. 2 Returns: float_complex(lhs), for float_complex, double_complex(lhs), for double_complex. float_complex operator+(const float_complex& lhs, const float_complex& rhs); float_complex operator+(const float_complex& lhs, const float& rhs); float_complex operator+(const float& lhs, const float_complex& rhs); double_complex operator+(const double_complex& lhs, const double_complex& rhs); double_complex operator+(const double_complex& lhs, const double& rhs); double_complex operator+(const double& lhs, const double_complex& rhs); 3 Returns: float_complex(lhs) += rhs, for float_complex, double_complex(lhs) += rhs, for double_complex. float_complex operator-(const float_complex& lhs); double_complex operator-(const double_complex& lhs); 4 Notes: unary operator. 5 Returns: float_complex(-lhs.real(),-lhs.imag()), for float_complex, double_complex(-lhs.real(),-lhs.imag()), for double_complex. float_complex operator-(const float_complex& lhs, const float_complex& rhs); float_complex operator-(const float_complex& lhs, const float& rhs); float_complex operator-(const float& lhs, const float_complex& rhs); double_complex operator-(const double_complex& lhs, const double_complex& rhs); double_complex operator-(const double_complex& lhs, const double& rhs); double_complex operator-(const double& lhs, const double_complex& rhs); 6 Returns: float_complex(lhs) -= rhs, for float_complex, double_complex(lhs) -= rhs, for double_complex. float_complex operator*(const float_complex& lhs, const float_complex& rhs); float_complex operator*(const float_complex& lhs, const float& rhs); float_complex operator*(const float& lhs, const float_complex& rhs); double_complex operator*(const double_complex& lhs, const double_complex& rhs); double_complex operator*(const double_complex& lhs, const double& rhs); double_complex operator*(const double& lhs, const double_complex& rhs); 7 Returns: float_complex(lhs) *= rhs, for float_complex, double_complex(lhs) *= rhs, for double_complex. float_complex operator/(const float_complex& lhs, const float_complex& rhs); float_complex operator/(const float_complex& lhs, const float& rhs); float_complex operator/(const float& lhs, const float_complex& rhs); double_complex operator/(const double_complex& lhs, const double_complex& rhs); double_complex operator/(const double_complex& lhs, const double& rhs); double_complex operator/(const double& lhs, const double_complex& rhs); 8 Returns: float_complex(lhs) /= rhs, for float_complex, double_complex(lhs) /= rhs, for double_complex. bool operator==(const float_complex& lhs, const float_complex& rhs); bool operator==(const float_complex& lhs, const float& rhs); bool operator==(const float& lhs, const float_complex& rhs); bool operator==(const double_complex& lhs, const double_complex& rhs); bool operator==(const double_complex& lhs, const double& rhs); bool operator==(const double& lhs, const double_complex& rhs); 9 Returns: lhs.real() == rhs.real() && lhs.imag() == rhs.imag(). 10 Notes: For float_complex, the imaginary part is assumed to be float(), or 0.0f, for the float arguments. For double_complex, the imaginary part is assumed to be double(), or 0.0, for the double arguments. bool operator!=(const float_complex& lhs, const float_complex& rhs); bool operator!=(const float_complex& lhs, const float& rhs); bool operator!=(const float& lhs, const float_complex& rhs); bool operator!=(const double_complex& lhs, const double_complex& rhs); bool operator!=(const double_complex& lhs, const double& rhs); bool operator!=(const double& lhs, const double_complex& rhs); 11 Returns: rhs.real() != lhs.real() || rhs.imag() != lhs.imag(). istream& operator>>(istream& is, float_complex& x); istream& operator>>(istream& is, double_complex& x); 12 Effects: Extracts a complex number x of the form: u, (u), or (u,v), where u is the real part and v is the imaginary part. 13 Requires: The input values be convertible to float for float_complex, and to double for double_complex. If bad input is encountered, calls is.setstate(ios::failbit). 14 Returns: is. ostream& operator<<(ostream& o, const float_complex& x); ostream& operator<<(ostream& o, const double_complex& x); 15 Returns: o << '(' << x.real() << "," << x.imag() << ')' << ends. ======================================================================== |
======================================================================== float real(const float_complex& x); double real(const double_complex& x); float imag(const float_complex& x); double imag(const double_complex& x); float abs(const float_complex& x); double abs(const double_complex& x); float arg(const float_complex& x); double arg(const double_complex& x); float norm(const float_complex& x); double norm(const double_complex& x); float_complex conj(const float_complex& x); double_complex conj(const double_complex& x); float_complex polar(const float& rho, const float& theta = 0.0f); double_complex polar(const double& rho, const double& theta = 0.0); ======================================================================== |
======================================================================== float_complex cos(const float_complex& x); double_complex cos(const double_complex& x); float_complex cosh(const float_complex& x); double_complex cosh(const double_complex& x); float_complex exp(const float_complex& x); double_complex exp(const double_complex& x); float_complex log(const float_complex& x); double_complex log(const double_complex& x); float_complex log10(const float_complex& x); double_complex log10(const double_complex& x); float_complex pow(const float_complex& x, int y); float_complex pow(const float_complex& x, const float_complex& y); float_complex pow (const float_complex& x, const float& y); float_complex pow (const float& x, const float_complex& y); double_complex pow(const double_complex& x, int y); double_complex pow(const double_complex& x, const double_complex& y); double_complex pow (const double_complex& x, const double& y); double_complex pow (const double& x, const double_complex& y); float_complex sin (const float_complex& x); double_complex sin (const double_complex& x); float_complex sinh (const float_complex& x); double_complex sinh (const double_complex& x); float_complex sqrt (const float_complex& x); double_complex sqrt (const double_complex& x); float_complex tan (const float_complex& x); double_complex tan (const double_complex& x); float_complex tanh (const float_complex& x); double_complex tanh (const double_complex& x); ======================================================================== |
======================================================================== Header <iosfwd> synopsis class ios; class streambuf; class istream; class ostream; [Note: 1 The class ios serves as a base class for the classes istream, ostream, and classes derived from them. -end note] ======================================================================== |
======================================================================== Header <iostream> synopsis extern istream cin; extern ostream cout; 1 The header <iostream> declares objects that associate objects with the standard C streams provided for by the functions declared in <cstdio>. ======================================================================== |
======================================================================== #include <iosfwd> typedef OFF_T streamoff; typedef SZ_T streamsize; class ios_base; class ios; // 27.4.6, manipulators: ios_base& boolalpha (ios_base& str); ios_base& noboolalpha(ios_base& str); ios_base& showbase (ios_base& str); ios_base& noshowbase (ios_base& str); ios_base& showpoint (ios_base& str); ios_base& noshowpoint(ios_base& str); ios_base& showpos (ios_base& str); ios_base& noshowpos (ios_base& str); ios_base& skipws (ios_base& str); ios_base& noskipws (ios_base& str); ios_base& uppercase (ios_base& str); ios_base& nouppercase(ios_base& str); // 27.4.6.2 adjustfield: ios_base& internal (ios_base& str); ios_base& left (ios_base& str); ios_base& right (ios_base& str); // 27.4.6.3 basefield: ios_base& dec (ios_base& str); ios_base& hex (ios_base& str); ios_base& oct (ios_base& str); // 27.4.6.4 floatfield: ios_base& fixed (ios_base& str); ios_base& scientific (ios_base& str); ======================================================================== |
======================================================================== 1 Returns: true if the standard iostream objects(27.3) are synchronized and otherwise returns false. The first time it is called, the function returns true. ======================================================================== |
======================================================================== class ios : public ios_base { public: // Types: typedef INT_T int_type; typedef POS_T pos_type; typedef OFF_T off_type; operator void*() const; bool operator!() const; iostate rdstate() const; void clear(iostate state = goodbit); void setstate(iostate state); bool good() const; bool eof() const; bool fail() const; bool bad() const; iostate exceptions() const; void exceptions(iostate except); // 27.4.4.1 Constructor/destructor: explicit ios(streambuf* sb); virtual ~ios(); // 27.4.4.2 Members: ostream* tie() const; ostream* tie(ostream* tiestr); streambuf* rdbuf() const; streambuf* rdbuf(streambuf* sb); ios& copyfmt(const ios& rhs); char fill() const; char fill(char ch); protected: ios(); void init(streambuf* sb); private: ios(const ios&); // not defined ios & operator=(const ios&); // not defined }; ======================================================================== |
======================================================================== explicit ios(streambuf* sb); 1 Effects: Constructs an object of class ios, assigning initial values to its member objects by calling init(sb). ios(); 2 Effects: Constructs an object of class basic_ios (27.4.2.7) leaving its member objects uninitialized. The object must be initialized by calling its init member function. If it is destroyed before it has been initialized the behavior is undefined. void init(streambuf *sb); ======================================================================== |
======================================================================== _________________________________________________________ | Element Value | |________________________________________________________| | rdbuf() sb | | tie() 0 | | rdstate() goodbit if sb is not a null pointer,| | otherwise badbit. | | exceptions() goodbit | | flags() skipws | dec | | width() 0 | | precision() 6 | | fill() ' ' | | iarray a null pointer | | parray a null pointer | |________________________________________________________| ======================================================================== |
======================================================================== ostream* tie() const; ostream* tie(ostream* tiestr); streambuf* rdbuf() const; streambuf* rdbuf(streambuf* sb); char fill() const; char fill(char ch); ios& copyfmt(const ios& rhs); ======================================================================== |
======================================================================== void clear(iostate state = goodbit); 4 Postcondition: If rdbuf()!=0 then state == rdstate(); otherwise rdstate()==state|ios_base::badbit. 5 Effects: If (rdstate() & exceptions()) == 0, returns. Otherwise, the behavior is undefined. void setstate(iostate state); 6 Effects: Calls clear(rdstate() | state). iostate exceptions() const; 11 Returns: A mask that determines what elements set in rdstate() cause undefined behavior. ======================================================================== |
======================================================================== Header <streambuf> synopsis class streambuf; ======================================================================== |
======================================================================== class streambuf { public: // Types: typedef INT_T int_type; typedef POS_T pos_type; typedef OFF_T off_type; virtual ~streambuf(); // 27.5.2.2.2 buffer and positioning: streambuf* pubsetbuf(char* s, streamsize n); pos_type pubseekoff(off_type off, ios_base::seekdir way, ios_base::openmode which = ios_base::in | ios_base::out); pos_type pubseekpos(pos_type sp, ios_base::openmode which = ios_base::in | ios_base::out); int pubsync(); // Get and put areas: // 27.5.2.2.3 Get area: streamsize in_avail(); int_type snextc(); int_type sbumpc(); int_type sgetc(); streamsize sgetn(char* s, streamsize n); // 27.5.2.2.4 Putback: int_type sputbackc(char c); int_type sungetc(); // 27.5.2.2.5 Put area: int_type sputc(char c); streamsize sputn(const char* s, streamsize n); protected: streambuf(); // 27.5.2.3.1 Get area: char* eback() const; char* gptr() const; char* egptr() const; void gbump(int n); void setg(char* gbeg, char* gnext, char* gend); // 27.5.2.3.2 Put area: char* pbase() const; char* pptr() const; char* epptr() const; void pbump(int n); void setp(char* pbeg, char* pend); // 27.5.2.4 virtual functions: // 27.5.2.4.2 Buffer management and positioning: virtual streambuf* setbuf(char* s, streamsize n); 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 int sync(); // 27.5.2.4.3 Get area: virtual int showmanyc(); virtual streamsize xsgetn(char* s, streamsize n); virtual int_type underflow(); virtual int_type uflow(); // 27.5.2.4.4 Putback: virtual int_type pbackfail(int_type c = EOF); // 27.5.2.2.5 Put area: virtual streamsize xsputn(const char* s, streamsize n); virtual int_type overflow (int_type c = EOF); }; 1 The class streambuf serves as an abstract base class for deriving various stream buffers whose objects each control two character sequences: --a character input sequence; --a character output sequence. ======================================================================== |
======================================================================== streambuf(); 1 Effects: Constructs an object of class streambuf and initializes:273) --all its pointer member objects to null pointers, __________________________ 273) The default constructor is protected for class streambuf to assure that only objects for classes derived from this class may be constructed. ======================================================================== |
======================================================================== streambuf* pubsetbuf(char* s, streamsize n); pos_type pubseekoff(off_type off, ios_base::seekdir way, ios_base::openmode which = ios_base::in | ios_base::out); pos_type pubseekpos(pos_type sp, ios_base::openmode which = ios_base::in | ios_base::out); int pubsync(); ======================================================================== |
======================================================================== streambuf* setbuf(char* s, streamsize n); ======================================================================== |
======================================================================== 259) The intention is not only that the calls will not return EOF but that they will return ``immediately.'' ======================================================================== |
======================================================================== 6 Returns: EOF or undefined if the function fails. Otherwise, returns some value other than EOF to indicate success.262) ======================================================================== |
======================================================================== Header <istream> synopsis class istream; istream& ws(istream& is); Header <ostream> synopsis class ostream; ostream& endl(ostream& os); ostream& ends(ostream& os); ostream& flush(ostream& os); Header <iomanip> synopsis // Types T1, T2, ... are unspecified // implementation types T1 resetiosflags(ios_base::fmtflags mask); T2 setiosflags (ios_base::fmtflags mask); T3 setbase(int base); T4 setfill(char c); T5 setprecision(int n); T6 setw(int n); ======================================================================== |
======================================================================== class istream : public ios { public: // Types (inherited from ios): typedef INT_T int_type; typedef POS_T pos_type; typedef OFF_T off_type; // 27.6.1.1.1 Constructor/destructor: explicit istream(streambuf* sb); virtual ~istream(); // 27.6.1.1.2 Prefix/suffix: class sentry; // 27.6.1.2 Formatted input: istream& operator>> (istream& (*pf)(istream&)); istream& operator>> (ios& (*pf)(ios&)); istream& operator>> (ios_base& (*pf)(ios_base&)); istream& operator>>(bool& n); istream& operator>>(short& n); istream& operator>>(unsigned short& n); istream& operator>>(int& n); istream& operator>>(unsigned int& n); istream& operator>>(long& n); istream& operator>>(unsigned long& n); istream& operator>>(float& f); istream& operator>>(double& f); istream& operator>>(long double& f); istream& operator>>(void*& p); istream& operator>>(streambuf* sb); // 27.6.1.3 Unformatted input: streamsize gcount() const; int_type get(); istream& get(char& c); istream& get(char* s, streamsize n); istream& get(char* s, streamsize n, char delim); istream& get(streambuf& sb); istream& get(streambuf& sb, char delim); istream& getline(char* s, streamsize n); istream& getline(char* s, streamsize n, char delim); istream& ignore(streamsize n = 1, int_type delim = EOF); int_type peek(); istream& read (char* s, streamsize n); streamsize readsome(char* s, streamsize n); istream& putback(char c); istream& unget(); int sync(); pos_type tellg(); istream& seekg(pos_type); istream& seekg(off_type, ios_base::seekdir); }; // 27.6.1.2.3 character extraction templates: istream& operator>>(istream&, char&); istream& operator>>(istream&, unsigned char&); istream& operator>>(istream&, signed char&); istream& operator>>(istream&, char*); istream& operator>>(istream&, unsigned char*); istream& operator>>(istream&, signed char*); ======================================================================== |
======================================================================== 3 If rdbuf()->sbumpc() or rdbuf()->sgetc() returns EOF, then the input function, except as explicitly noted otherwise, completes its actions and does setstate(eofbit). ======================================================================== |
======================================================================== explicit istream(streambuf* sb); virtual ~istream(); ======================================================================== |
======================================================================== class istream::sentry { bool ok_; // exposition only public: explicit sentry(istream& is, bool noskipws = false); ~sentry(); operator bool() const { return ok_; } private: sentry(const sentry&); // not defined setry & operator=(const sentry&); // not defined }; ======================================================================== |
======================================================================== explicit sentry(istream& is, bool noskipws = false); ======================================================================== |
======================================================================== 6 [Example: A typical implementation of the sentry constructor might include code such as: istream::sentry(istream& is, bool noskipws = false) { ... int_type c; while ((c = is.rdbuf()->snextc()) != EOF) { if (!isspace(c)) { is.rdbuf()->sputbackc (c); break; } } ... } -end example] ======================================================================== |
======================================================================== 1 Each formatted input function begins execution by constructing an object of class sentry with the noskipws (second) argument false. If the sentry object returns true, when converted to a value of type bool, the function endeavors to obtain the requested input. If (exception()&badbit)!= 0 then the behavior is undefined. In any case, the formatted input function destructs the sentry object. If undefined behavior has not happened thrown it returns *this ======================================================================== |
======================================================================== istream& operator>>(istream& (*pf)(istream&)) istream& operator>>(ios& (*pf)(ios&)); istream& operator>>(ios_base& (*pf)(ios_base&)); istream& operator>>(istream& in, char* s); istream& operator>>(istream& in, unsigned char* s); istream& operator>>(istream& in, signed char* s); istream& operator>>(istream& in, char& c); istream& operator>>(istream& in, unsigned char& c); istream& operator>>(istream& in, signed char& c); istream& operator>>(streambuf* sb); ======================================================================== |
======================================================================== 7 Characters are extracted and stored until any of the following occurs: - n-1 characters are stored; - end of file occurs on the input sequence; - isspace(c) is true for the next available input character c. - A null byte ('\0') in the next position, which may be the first position if no characters were extracted. operator>> then calls width(0). ======================================================================== |
======================================================================== 12 Effects: If sb is null, calls setstate(failbit). Extracts characters from *this and inserts them in the output sequence controlled by sb. Characters are extracted and inserted until any of the following occurs: - end-of-file occurs on the input sequence; - inserting in the output sequence fails (in which case the character to be inserted is not extracted); 13 If the function inserts no characters, it calls setstate(failbit). ======================================================================== |
======================================================================== 1 Each unformatted input function begins execution by constructing an object of class sentry with the default argument noskipws (second) argument true. If the sentry object returns true, when converted to a value of type bool, the function endeavors to obtain the requested input. If (exception()&badbit)!= 0 then the behavior is undefined. It also counts the number of characters extracted. If undefined behavior has not happened it ends by storing the count in a member object and returning the value specified. In any event the sentry object is destroyed before leaving the unformatted input function. ======================================================================== |
======================================================================== int_type get(); 3 Effects: Extracts a character c, if one is available. Otherwise, the func- tion calls setstate(failbit). istream& get(char &c); 5 Effects: Extracts a character, if one is available, and assigns it to c.269) Otherwise, the function calls setstate(failbit). ======================================================================== |
======================================================================== istream& get(char* s, streamsize n, char delim); 8 If the function stores no characters, it calls setstate(failbit). In any case, it then stores a null character into the next successive loca- tion of the array. ======================================================================== |
======================================================================== istream& get(char *s, streamsize n) 10 Effects: Calls get(s,n,'\n'); 11 Returns: Value returned by the call. ======================================================================== |
======================================================================== istream& get(streambuf& sb, char delim); 12 Effects: Extracts characters and inserts them in the output sequence con- trolled by sb. Characters are extracted and inserted until any of the following occurs: --end-of-file occurs on the input sequence; --inserting in the output sequence fails (in which case the character to be inserted is not extracted); --c == delim for the next available input character c (in which case c is not extracted); 13 If the function inserts no characters, it calls setstate(failbit). ======================================================================== |
======================================================================== istream& get(streambuf& sb); 15 Effects: Calls get(s,n,'\n'); 16 Returns: Value returned by the call. ======================================================================== |
======================================================================== istream& getline(char* s, streamsize n, char delim); 19 If the function extracts no characters, it calls setstate(failbit). 20 In any case, it then stores a null character into the next successive location of the array. 22 [Example: #include <iostream> int main() { const int line_buffer_size = 100; char buffer[line_buffer_size]; int line_number = 0; while (cin.getline(buffer, line_buffer_size) || cin.gcount()) { int count = cin.gcount(); if (cin.eof()) cout << "Partial final line"; // cin.fail() is false else if (cin.fail()) { cout << "Partial long line"; cin.clear(cin.rdstate() & ~ios::failbit); } else { count--; // Don't include newline in count cout << "Line " << ++line_number; } cout << " (" << count << " chars): " << buffer << endl; } } --end example] ======================================================================== |
======================================================================== istream& getline(char *s, streamsize n); 23 Returns: getline(s,n,'\n'); ======================================================================== |
======================================================================== istream& ignore(int n = 1, int_type delim = EOF); 24 Effects: Extracts characters and discards them. Characters are extracted until any of the following occurs: --if n != INT_MAX, n characters are extracted --end-of-file occurs on the input sequence (in which case the function calls setstate(eofbit). --c == delim for the next available input character c (in which case c is extracted). ======================================================================== |
======================================================================== istream& read(char* s, streamsize n); 28 Effects: Extracts characters and stores them into successive locations of an array whose first element is designated by s.291) Characters are extracted and stored until either of the following occurs: --n characters are stored; --end-of-file occurs on the input sequence (in which case the function calls setstate(failbit). ======================================================================== |
======================================================================== streamsize readsome(char* s, streamsize n); 30 Effects: If !good() calls setstate(failbit), and return. Otherwise extracts characters and stores them into successive locations of an array whose first element is designated by s. If rdbuf()->in_avail() == -1, calls setstate(eofbit), and extracts no characters; - If rdbuf()->in_avail() == 0, extracts no characters - If rdbuf()->in_avail() > 0, extracts min(rdbuf()->in_avail(),n)). ======================================================================== |
======================================================================== istream& putback(char c); 32 Effects: If !good() calls setstate(failbit), and return. If rdbuf() is not null, calls rdbuf->sputbackc() . If rdbuf() is null, or if sputback() returns EOF, calls setstate(badbit). istream& unget(); 34 Effects: If !good() calls setstate(failbit), and return. If rdbuf() is not null, calls rdbuf()->sungetc(). If rdbuf() is null, or if sungetc() returns EOF, calls setstate(badbit). int sync(); 36 Effects: If rdbuf() is a null pointer, returns -1 . Otherwise, calls rdbuf()->pubsync() and, if that function returns -1 calls setstate(badbit), and returns EOF. Otherwise, returns zero. ======================================================================== |
======================================================================== streamsize gcount() const; int_type peek(); pos_type tellg(); istream& seekg(pos_type pos); istream& seekg(off_type& off, ios_base::seekdir dir); ======================================================================== |
======================================================================== istream& ws(istream& is); ======================================================================== |
======================================================================== class ostream : public ios { public: // Types (inherited from ios): // typedef INT_T int_type; // typedef POS_T pos_type; // typedef OFF_T off_type; // 27.6.2.2 Constructor/destructor: explicit ostream(streambuf* sb); virtual ~ostream(); // 27.6.2.3 Prefix/suffix: class sentry; // 27.6.2.5 Formatted output: ostream& operator<< (ostream& (*pf)(ostream&)); ostream& operator<< (ios& (*pf)(ios&)); ostream& operator<< (ios_base& (*pf)(ios_base&)); ostream& operator<<(bool n); ostream& operator<<(short n); ostream& operator<<(unsigned short n); ostream& operator<<(int n); ostream& operator<<(unsigned int n); ostream& operator<<(long n); ostream& operator<<(unsigned long n); ostream& operator<<(float f); ostream& operator<<(double f); ostream& operator<<(long double f); ostream& operator<<(const void* p); ostream& operator<<(streambuf* sb); // 27.6.2.6 Unformatted output: ostream& put(char c); ostream& write(const char* s, streamsize n); ostream& flush(); // 27.6.2.4 seeks: pos_type tellp(); ostream& seekp(pos_type); ostream& seekp(off_type, ios_base::seekdir); }; // 27.6.2.5.4 character inserters ostream& operator<<(ostream&, char); // signed and unsigned ostream& operator<<(ostream&, signed char); ostream& operator<<(ostream&, unsigned char); ostream& operator<<(ostream&, const char*); // signed and unsigned ostream& operator<<(ostream&, const signed char*); ostream& operator<<(ostream&, const unsigned char*); ======================================================================== |
======================================================================== explicit ostream(streambuf* sb); virtual ~ostream(); ======================================================================== |
======================================================================== class ostream::sentry { bool ok_; // exposition only public: explicit sentry(ostream& os); ~sentry(); operator bool() { return ok_; } private: sentry(const sentry&); // not defined sentry& operator=(const sentry&); // not defined }; ======================================================================== |
======================================================================== explicit sentry(ostream& os); ======================================================================== |
======================================================================== ostream& seekp(pos_type& pos); ostream& seekp(off_type& off, ios_base::seekdir dir); ======================================================================== |
======================================================================== 1 Each formatted output function begins execution by constructing an object of class sentry. If this object returns true when converted to a value of type bool, the function endeavors to generate the requested output. If the generation fails, then the formatted output function does setstate(ios::failbit). If (exception()&badbit)!= 0 then the behavior is undefined. In any case, the sentry object is destroyed before leaving the formatted output function. If undefined behavior has not happened , the result of the formatted output function is *this. ======================================================================== |
======================================================================== ostream& operator<<(ostream& (*pf)(ostream&)); ostream& operator<<(ios& (*pf)(ios&)); ostream& operator<<(ios_base& (*pf)(ios_base&)); ostream& operator<<(streambuf *sp); ======================================================================== |
======================================================================== 7 Gets characters from sb and inserts them in *this. Characters are read from sb and inserted until any of the following occurs: - end-of-file occurs on the input sequence; - inserting in the output sequence fails (in which case the character to be inserted is not extracted); 8 If the function inserts no characters, it calls setstate(failbit). ======================================================================== |
======================================================================== ostream& operator<<(ostream& out, char c); // signed and unsigned ostream& operator<<(ostream& out, signed char c); ostream& operator<<(ostream& out, unsigned char c); 1 Effects: Behaves like an formatted inserter (as described in 27.6.2.5.1) of out. After a sentry object is constructed it insert characters. The character to be inserted is c. width(0) is called. The insertion character is inserted into out. 2 Returns: out ostream& operator<<(ostream& out, const char* s); ostream& operator<<(ostream& out, const signed char* s); ostream& operator<<(ostream& out, const unsigned char* s); 3 Requires: s is non-null. 4 Effects: Behaves like an formatted inserter (as described in 27.6.2.5.1) of out. After a sentry object is constructed it insert characters. The number of characters starting at s to be inserted is ::strlen(s). The ::strlen(s) characters starting at s is inserted into out. Calls width(0). 5 Returns: out ======================================================================== |
======================================================================== ostream& put(char c); ostream& write(const char* s, streamsize n); ostream& flush(); ======================================================================== |
======================================================================== ostream& endl(ostream& os); 1 Effects: Calls os.put(os.widen('\n')), then os.flush(). 2 Returns: os.300) ostream& ends(ostream& os); 3 Effects: Inserts a null character into the output sequence: calls os.put('\0'). 4 Returns: os. ostream& flush(ostream& os); 5 Effects: Calls os.flush(). 6 Returns: os. ======================================================================== |
======================================================================== smanip setfill(char c); 6 Returns: An object s of unspecified type such that if out is (or is derived from) ostream and c has type char then the expression out<<s behaves as if f(s) were called, where f can be defined as: ios& f(ios& str, char c) { // set fill character str.fill(c); return str; } ======================================================================== |
======================================================================== +--------------------------------------------------------------------+ | Type Name(s) | +--------------------------------------------------------------------+ |Macros: | |EOF NULL <cstdio> | +--------------------------------------------------------------------+ |Types: size_t <cstdio> | +--------------------------------------------------------------------+ |Functions: | |getchar puts vprintf | |gets scanf vsprintf | |printf sprintf | |putchar sscanf | +--------------------------------------------------------------------+ ======================================================================== |