diff options
| author | Alexander Kabaev <kan@FreeBSD.org> | 2003-07-11 03:42:04 +0000 |
|---|---|---|
| committer | Alexander Kabaev <kan@FreeBSD.org> | 2003-07-11 03:42:04 +0000 |
| commit | 1b86b14eacf30b52bd5b9e48116db15982432eda (patch) | |
| tree | ce14546aca3a67fa3440aed52f132bafaf68fe70 /contrib/libstdc++/include/std | |
| parent | bd0df3aa27aac083bd60b649fa5347076a5126eb (diff) | |
Notes
Diffstat (limited to 'contrib/libstdc++/include/std')
19 files changed, 2854 insertions, 1966 deletions
diff --git a/contrib/libstdc++/include/std/std_bitset.h b/contrib/libstdc++/include/std/std_bitset.h index fe60b01f347c..ebe16504d188 100644 --- a/contrib/libstdc++/include/std/std_bitset.h +++ b/contrib/libstdc++/include/std/std_bitset.h @@ -219,7 +219,7 @@ namespace std void _Base_bitset<_Nw>::_M_do_left_shift(size_t __shift) { - if (__shift != 0) + if (__builtin_expect(__shift != 0, 1)) { const size_t __wshift = __shift / _GLIBCPP_BITSET_BITS_PER_WORD; const size_t __offset = __shift % _GLIBCPP_BITSET_BITS_PER_WORD; @@ -244,7 +244,7 @@ namespace std void _Base_bitset<_Nw>::_M_do_right_shift(size_t __shift) { - if (__shift != 0) + if (__builtin_expect(__shift != 0, 1)) { const size_t __wshift = __shift / _GLIBCPP_BITSET_BITS_PER_WORD; const size_t __offset = __shift % _GLIBCPP_BITSET_BITS_PER_WORD; @@ -570,6 +570,7 @@ namespace std struct _Sanitize<0> { static void _S_do_sanitize(unsigned long) { } }; + /** * @brief The %bitset class represents a @e fixed-size sequence of bits. * @@ -578,17 +579,19 @@ namespace std * (Note that %bitset does @e not meet the formal requirements of a * <a href="tables.html#65">container</a>. Mainly, it lacks iterators.) * - * The template argument, @a _Nb, may be any nonzero number of type - * size_t. + * The template argument, @a Nb, may be any non-negative number, + * specifying the number of bits (e.g., "0", "12", "1024*1024"). * - * A %bitset of size N has N % (sizeof(unsigned long) * CHAR_BIT) unused - * bits. (They are the high-order bits in the highest word.) It is - * a class invariant that those unused bits are always zero. + * In the general unoptimized case, storage is allocated in word-sized + * blocks. Let B be the number of bits in a word, then (Nb+(B-1))/B + * words will be used for storage. B - Nb%B bits are unused. (They are + * the high-order bits in the highest word.) It is a class invariant + * that those unused bits are always zero. * * If you think of %bitset as "a simple array of bits," be aware that * your mental picture is reversed: a %bitset behaves the same way as * bits in integers do, with the bit at index 0 in the "least significant - * / right-hand" position, and the bit at index N-1 in the "most + * / right-hand" position, and the bit at index Nb-1 in the "most * significant / left-hand" position. Thus, unlike other containers, a * %bitset's index "counts from right to left," to put it very loosely. * @@ -619,6 +622,7 @@ namespace std * @endcode * * Also see http://gcc.gnu.org/onlinedocs/libstdc++/ext/sgiexts.html#ch23 + * for a description of extensions. * * @if maint * Most of the actual code isn't contained in %bitset<> itself, but in the @@ -805,16 +809,26 @@ namespace std bitset<_Nb>& operator<<=(size_t __pos) { - this->_M_do_left_shift(__pos); - this->_M_do_sanitize(); + if (__builtin_expect(__pos < _Nb, 1)) + { + this->_M_do_left_shift(__pos); + this->_M_do_sanitize(); + } + else + this->_M_do_reset(); return *this; } bitset<_Nb>& operator>>=(size_t __pos) { - this->_M_do_right_shift(__pos); - this->_M_do_sanitize(); + if (__builtin_expect(__pos < _Nb, 1)) + { + this->_M_do_right_shift(__pos); + this->_M_do_sanitize(); + } + else + this->_M_do_reset(); return *this; } //@} @@ -1183,6 +1197,7 @@ namespace std typename basic_istream<_CharT, _Traits>::sentry __sentry(__is); if (__sentry) { + ios_base::iostate __state = ios_base::goodbit; basic_streambuf<_CharT, _Traits>* __buf = __is.rdbuf(); for (size_t __i = 0; __i < _Nb; ++__i) { @@ -1191,7 +1206,7 @@ namespace std typename _Traits::int_type __c1 = __buf->sbumpc(); if (_Traits::eq_int_type(__c1, __eof)) { - __is.setstate(ios_base::eofbit); + __state |= ios_base::eofbit; break; } else @@ -1201,19 +1216,21 @@ namespace std if (__c == '0' || __c == '1') __tmp.push_back(__c); - else if (_Traits::eq_int_type(__buf->sputbackc(__c2), - __eof)) + else if (_Traits::eq_int_type(__buf->sputbackc(__c2), __eof)) { - __is.setstate(ios_base::failbit); + __state |= ios_base::failbit; break; } } } if (__tmp.empty() && !_Nb) - __is.setstate(ios_base::failbit); + __state |= ios_base::failbit; else __x._M_copy_from_string(__tmp, static_cast<size_t>(0), _Nb); + + if (__state != ios_base::goodbit) + __is.setstate(__state); // may throw an exception } return __is; diff --git a/contrib/libstdc++/include/std/std_complex.h b/contrib/libstdc++/include/std/std_complex.h index bcfcedde8e9a..252070b13895 100644 --- a/contrib/libstdc++/include/std/std_complex.h +++ b/contrib/libstdc++/include/std/std_complex.h @@ -390,7 +390,7 @@ namespace std __s.flags(__os.flags()); __s.imbue(__os.getloc()); __s.precision(__os.precision()); - __s << '(' << __x.real() << "," << __x.imag() << ')'; + __s << '(' << __x.real() << ',' << __x.imag() << ')'; return __os << __s.str(); } @@ -456,7 +456,7 @@ namespace std inline _Tp norm(const complex<_Tp>& __z) { - return _Norm_helper<__is_floating<_Tp>::_M_type>::_S_do_it(__z); + return _Norm_helper<__is_floating<_Tp>::_M_type && !_GLIBCPP_FAST_MATH>::_S_do_it(__z); } template<typename _Tp> @@ -565,24 +565,30 @@ namespace std } template<typename _Tp> - inline complex<_Tp> + complex<_Tp> pow(const complex<_Tp>& __x, const _Tp& __y) { - return exp(__y * log(__x)); + if (__x.imag() == _Tp()) + return pow(__x.real(), __y); + + complex<_Tp> __t = log(__x); + return polar(exp(__y * __t.real()), __y * __t.imag()); } template<typename _Tp> inline complex<_Tp> pow(const complex<_Tp>& __x, const complex<_Tp>& __y) { - return exp(__y * log(__x)); + return __x == _Tp() ? _Tp() : exp(__y * log(__x)); } template<typename _Tp> inline complex<_Tp> pow(const _Tp& __x, const complex<_Tp>& __y) { - return exp(__y * log(__x)); + return __x == _Tp() + ? _Tp() + : polar(pow(__x, __y.real()), __y.imag() * log(__x)); } // 26.2.3 complex specializations diff --git a/contrib/libstdc++/include/std/std_deque.h b/contrib/libstdc++/include/std/std_deque.h index 0fca0d1a3d49..921c25fa4931 100644 --- a/contrib/libstdc++/include/std/std_deque.h +++ b/contrib/libstdc++/include/std/std_deque.h @@ -70,8 +70,9 @@ #include <bits/stl_uninitialized.h> #include <bits/stl_deque.h> +#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT +# include <bits/deque.tcc> +#endif + #endif /* _CPP_DEQUE */ -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/std/std_fstream.h b/contrib/libstdc++/include/std/std_fstream.h index 838b99dc08bd..bcbbb971946a 100644 --- a/contrib/libstdc++/include/std/std_fstream.h +++ b/contrib/libstdc++/include/std/std_fstream.h @@ -50,6 +50,15 @@ namespace std { + // [27.8.1.1] template class basic_filebuf + /** + * @brief The actual work of input and output (for files). + * + * This class associates both its input and output sequence with an + * external disk file, and maintains a joint file position for both + * sequences. Many of its sematics are described in terms of similar + * behavior in the Standard C Library's @c FILE streams. + */ template<typename _CharT, typename _Traits> class basic_filebuf : public basic_streambuf<_CharT, _Traits> { @@ -61,30 +70,55 @@ namespace std typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; - // Non-standard Types: + //@{ + /** + * @if maint + * @doctodo + * @endif + */ typedef basic_streambuf<char_type, traits_type> __streambuf_type; typedef basic_filebuf<char_type, traits_type> __filebuf_type; typedef __basic_file<char> __file_type; typedef typename traits_type::state_type __state_type; typedef codecvt<char_type, char, __state_type> __codecvt_type; - typedef typename __codecvt_type::result __res_type; typedef ctype<char_type> __ctype_type; + //@} friend class ios_base; // For sync_with_stdio. protected: // Data Members: // MT lock inherited from libio or other low-level io library. + /** + * @if maint + * @doctodo + * @endif + */ __c_lock _M_lock; // External buffer. + /** + * @if maint + * @doctodo + * @endif + */ __file_type _M_file; // Current and beginning state type for codecvt. + /** + * @if maint + * @doctodo + * @endif + */ __state_type _M_state_cur; __state_type _M_state_beg; // Set iff _M_buf is allocated memory from _M_allocate_internal_buffer. + /** + * @if maint + * @doctodo + * @endif + */ bool _M_buf_allocated; // XXX Needed? @@ -92,12 +126,26 @@ namespace std // The position in the buffer corresponding to the external file // pointer. + /** + * @if maint + * @doctodo + * @endif + */ char_type* _M_filepos; public: // Constructors/destructor: + /** + * @brief Does not open any files. + * + * The default constructor initializes the parent class using its + * own default ctor. + */ basic_filebuf(); + /** + * @brief The destructor closes the file first. + */ virtual ~basic_filebuf() { @@ -106,23 +154,61 @@ namespace std } // Members: + /** + * @brief Returns true if the external file is open. + */ bool - is_open() const { return _M_file.is_open(); } + is_open() const throw() { return _M_file.is_open(); } + /** + * @brief Opens an external file. + * @param s The name of the file. + * @param mode The open mode flags. + * @return @c this on success, NULL on failure + * + * If a file is already open, this function immediately fails. + * Otherwise it tries to open the file named @a s using the flags + * given in @a mode. + * + * [Table 92 gives the relation between openmode combinations and the + * equivalent fopen() flags, but the table has not been copied yet.] + */ __filebuf_type* open(const char* __s, ios_base::openmode __mode); + /** + * @brief Closes the currently associated file. + * @return @c this on success, NULL on failure + * + * If no file is currently open, this function immediately fails. + * + * If a "put buffer area" exists, @c overflow(eof) is called to flush + * all the characters. The file is then closed. + * + * If any operations fail, this function also fails. + */ __filebuf_type* - close(); + close() throw(); protected: + /** + * @if maint + * @doctodo + * @endif + */ void _M_allocate_internal_buffer(); + /** + * @if maint + * @doctodo + * @endif + */ void - _M_destroy_internal_buffer(); + _M_destroy_internal_buffer() throw(); - // Overridden virtual functions: + // [27.8.1.4] overridden virtual functions + // [documentation is inherited] virtual streamsize showmanyc(); @@ -137,15 +223,23 @@ namespace std // the underflow() case in order to maintain synchronization. So // instead of calling underflow() from uflow(), we create a common // subroutine to do the real work. + /** + * @if maint + * @doctodo + * @endif + */ int_type _M_underflow_common(bool __bump); + // [documentation is inherited] virtual int_type underflow(); + // [documentation is inherited] virtual int_type uflow(); + // [documentation is inherited] virtual int_type pbackfail(int_type __c = _Traits::eof()); @@ -157,6 +251,8 @@ namespace std // this in actuality be a helper function that checks for the // eccentricities of this implementation, and then call // overflow() if indeed the buffer is full. + + // [documentation is inherited] virtual int_type overflow(int_type __c = _Traits::eof()); @@ -167,28 +263,54 @@ namespace std // character c. // 27.5.2.4.5 // Consume some sequence of the characters in the pending sequence. + /** + * @if maint + * @doctodo + * @endif + */ int_type _M_really_overflow(int_type __c = _Traits::eof()); // Convert internal byte sequence to external, char-based // sequence via codecvt. + /** + * @if maint + * @doctodo + * @endif + */ void _M_convert_to_external(char_type*, streamsize, streamsize&, streamsize&); + /** + * @brief Manipulates the buffer. + * @param s Pointer to a buffer area. + * @param n Size of @a s. + * @return @c this + * + * If no file has been opened, and both @a s and @a n are zero, then + * the stream becomes unbuffered. Otherwise, @c s is used as a + * buffer; see + * http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#2 + * for more. + */ virtual __streambuf_type* setbuf(char_type* __s, streamsize __n); + // [documentation is inherited] virtual pos_type seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode = ios_base::in | ios_base::out); + // [documentation is inherited] virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode = ios_base::in | ios_base::out); + // [documentation is inherited] virtual int sync() { + int __ret = 0; bool __testput = _M_out_cur && _M_out_beg < _M_out_end; // Make sure that the internal buffer resyncs its idea of @@ -197,19 +319,26 @@ namespace std { // Need to restore current position after the write. off_type __off = _M_out_cur - _M_out_end; - _M_really_overflow(); // _M_file.sync() will be called within - if (__off) + + // _M_file.sync() will be called within + if (traits_type::eq_int_type(_M_really_overflow(), + traits_type::eof())) + __ret = -1; + else if (__off) _M_file.seekoff(__off, ios_base::cur); } else _M_file.sync(); + _M_last_overflowed = false; - return 0; + return __ret; } + // [documentation is inherited] virtual void imbue(const locale& __loc); + // [documentation is inherited] virtual streamsize xsgetn(char_type* __s, streamsize __n) { @@ -231,6 +360,7 @@ namespace std return __ret; } + // [documentation is inherited] virtual streamsize xsputn(const char_type* __s, streamsize __n) { @@ -238,6 +368,11 @@ namespace std return __streambuf_type::xsputn(__s, __n); } + /** + * @if maint + * @doctodo + * @endif + */ void _M_output_unshift(); @@ -248,6 +383,11 @@ namespace std // internal buffer does not truly reflect the contents of the // external buffer. At this point, for whatever reason, it is in // an indeterminate state. + /** + * @if maint + * @doctodo + * @endif + */ void _M_set_indeterminate(void) { @@ -258,6 +398,11 @@ namespace std _M_filepos = _M_buf; } + /** + * @if maint + * @doctodo + * @endif + */ void _M_set_determinate(off_type __off) { @@ -270,6 +415,11 @@ namespace std _M_filepos = _M_buf + __off; } + /** + * @if maint + * @doctodo + * @endif + */ bool _M_is_indeterminate(void) { @@ -286,7 +436,7 @@ namespace std } }; - // Explicit specializations. + // Explicit specialization declarations, defined in src/fstream.cc. template<> basic_filebuf<char>::int_type basic_filebuf<char>::_M_underflow_common(bool __bump); @@ -299,19 +449,24 @@ namespace std // Generic definitions. template <typename _CharT, typename _Traits> - basic_filebuf<_CharT, _Traits>::int_type + typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits>::underflow() { return _M_underflow_common(false); } template <typename _CharT, typename _Traits> - basic_filebuf<_CharT, _Traits>::int_type + typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits>::uflow() { return _M_underflow_common(true); } - // 27.8.1.5 Template class basic_ifstream + // [27.8.1.5] Template class basic_ifstream /** - * Derivation of general input streams, specific to files. + * @brief Controlling input for files. + * + * This class supports reading from named files, using the inherited + * functions from std::basic_istream. To control the associated + * sequence, an instance of std::basic_filebuf is used, which this page + * refers to as @c sb. */ template<typename _CharT, typename _Traits> class basic_ifstream : public basic_istream<_CharT, _Traits> @@ -329,20 +484,33 @@ namespace std typedef basic_istream<char_type, traits_type> __istream_type; private: + /** + * @if maint + * @doctodo + * @endif + */ __filebuf_type _M_filebuf; public: - // Constructors/Destructors: - /** Default constructor. Create an input file stream. */ + // Constructors/Destructors: + /** + * @brief Default constructor. + * + * Initializes @c sb using its default constructor, and passes + * @c &sb to the base class initializer. Does not open any files + * (you haven't given it a filename to open). + */ basic_ifstream() : __istream_type(NULL), _M_filebuf() { this->init(&_M_filebuf); } /** - * @brief Create an input file stream. - * @param s Null terminated string specifying filename. + * @brief Create an input file stream. + * @param s Null terminated string specifying the filename. * @param mode Open file in specified mode (see std::ios_base). * + * @c ios_base::in is automatically included in @a mode. + * * Tip: When using std::string to hold the filename, you must use * .c_str() before passing it to this constructor. */ @@ -354,21 +522,44 @@ namespace std this->open(__s, __mode); } + /** + * @brief The destructor does nothing. + * + * The file is closed by the filebuf object, not the formatting + * stream. + */ ~basic_ifstream() { } // Members: /** - * @brief Get a pointer to the file stream's buffer. - * @return Pointer to basic_filebuf. + * @brief Accessing the underlying buffer. + * @return The current basic_filebuf buffer. + * + * This hides both signatures of std::basic_ios::rdbuf(). */ __filebuf_type* rdbuf() const { return const_cast<__filebuf_type*>(&_M_filebuf); } + /** + * @brief Wrapper to test for an open file. + * @return @c rdbuf()->is_open() + */ bool is_open() { return _M_filebuf.is_open(); } + /** + * @brief Opens an external file. + * @param s The name of the file. + * @param mode The open mode flags. + * + * Calls @c std::basic_filebuf::open(s,mode|in). If that function + * fails, @c failbit is set in the stream's error state. + * + * Tip: When using std::string to hold the filename, you must use + * .c_str() before passing it to this constructor. + */ void open(const char* __s, ios_base::openmode __mode = ios_base::in) { @@ -376,7 +567,12 @@ namespace std this->setstate(ios_base::failbit); } - /** Close the file. */ + /** + * @brief Close the file. + * + * Calls @c std::basic_filebuf::close(). If that function + * fails, @c failbit is set in the stream's error state. + */ void close() { @@ -386,9 +582,14 @@ namespace std }; - // 27.8.1.8 Template class basic_ofstream + // [27.8.1.8] Template class basic_ofstream /** - * Derivation of general output streams, specific to files. + * @brief Controlling output for files. + * + * This class supports reading from named files, using the inherited + * functions from std::basic_ostream. To control the associated + * sequence, an instance of std::basic_filebuf is used, which this page + * refers to as @c sb. */ template<typename _CharT, typename _Traits> class basic_ofstream : public basic_ostream<_CharT,_Traits> @@ -406,20 +607,34 @@ namespace std typedef basic_ostream<char_type, traits_type> __ostream_type; private: + /** + * @if maint + * @doctodo + * @endif + */ __filebuf_type _M_filebuf; public: // Constructors: - /** Default constructor for output file_stream. */ + /** + * @brief Default constructor. + * + * Initializes @c sb using its default constructor, and passes + * @c &sb to the base class initializer. Does not open any files + * (you haven't given it a filename to open). + */ basic_ofstream() : __ostream_type(NULL), _M_filebuf() { this->init(&_M_filebuf); } /** - * @brief Create an output stream. - * @param s Null terminated string specifying filename. + * @brief Create an output file stream. + * @param s Null terminated string specifying the filename. * @param mode Open file in specified mode (see std::ios_base). * + * @c ios_base::out|ios_base::trunc is automatically included in + * @a mode. + * * Tip: When using std::string to hold the filename, you must use * .c_str() before passing it to this constructor. */ @@ -432,29 +647,40 @@ namespace std this->open(__s, __mode); } + /** + * @brief The destructor does nothing. + * + * The file is closed by the filebuf object, not the formatting + * stream. + */ ~basic_ofstream() { } // Members: /** - * @brief Get a pointer to the file stream's buffer. - * @return Pointer to basic_filebuf. + * @brief Accessing the underlying buffer. + * @return The current basic_filebuf buffer. + * + * This hides both signatures of std::basic_ios::rdbuf(). */ __filebuf_type* rdbuf() const { return const_cast<__filebuf_type*>(&_M_filebuf); } /** - * @brief Query to see if file stream is open. - * @return True if stream is open. + * @brief Wrapper to test for an open file. + * @return @c rdbuf()->is_open() */ bool is_open() { return _M_filebuf.is_open(); } /** - * @brief Specify a file to open for output. - * @param s Null terminated string specifying filename. - * @param mode Mode in which to open file (see std::ios_base). + * @brief Opens an external file. + * @param s The name of the file. + * @param mode The open mode flags. + * + * Calls @c std::basic_filebuf::open(s,mode|out|trunc). If that + * function fails, @c failbit is set in the stream's error state. * * Tip: When using std::string to hold the filename, you must use * .c_str() before passing it to this constructor. @@ -467,7 +693,12 @@ namespace std this->setstate(ios_base::failbit); } - /** Close the file stream. */ + /** + * @brief Close the file. + * + * Calls @c std::basic_filebuf::close(). If that function + * fails, @c failbit is set in the stream's error state. + */ void close() { @@ -477,9 +708,14 @@ namespace std }; - // 27.8.1.11 Template class basic_fstream + // [27.8.1.11] Template class basic_fstream /** - * Derivation of general input/output streams, specific to files. + * @brief Controlling intput and output for files. + * + * This class supports reading from and writing to named files, using + * the inherited functions from std::basic_iostream. To control the + * associated sequence, an instance of std::basic_filebuf is used, which + * this page refers to as @c sb. */ template<typename _CharT, typename _Traits> class basic_fstream : public basic_iostream<_CharT, _Traits> @@ -498,18 +734,29 @@ namespace std typedef basic_iostream<char_type, traits_type> __iostream_type; private: + /** + * @if maint + * @doctodo + * @endif + */ __filebuf_type _M_filebuf; public: // Constructors/destructor: - /** Default constructor. Create a file stream. */ + /** + * @brief Default constructor. + * + * Initializes @c sb using its default constructor, and passes + * @c &sb to the base class initializer. Does not open any files + * (you haven't given it a filename to open). + */ basic_fstream() : __iostream_type(NULL), _M_filebuf() { this->init(&_M_filebuf); } /** - * @brief Create an input/output stream. - * @param s Null terminated string specifying filename. + * @brief Create an input/output file stream. + * @param s Null terminated string specifying the filename. * @param mode Open file in specified mode (see std::ios_base). * * Tip: When using std::string to hold the filename, you must use @@ -524,29 +771,40 @@ namespace std this->open(__s, __mode); } + /** + * @brief The destructor does nothing. + * + * The file is closed by the filebuf object, not the formatting + * stream. + */ ~basic_fstream() { } // Members: /** - * @brief Get a pointer to the file stream's buffer. - * @return Pointer to basic_filebuf. + * @brief Accessing the underlying buffer. + * @return The current basic_filebuf buffer. + * + * This hides both signatures of std::basic_ios::rdbuf(). */ __filebuf_type* rdbuf() const { return const_cast<__filebuf_type*>(&_M_filebuf); } /** - * @brief Query to see if file stream is open. - * @return True if stream is open. + * @brief Wrapper to test for an open file. + * @return @c rdbuf()->is_open() */ bool is_open() { return _M_filebuf.is_open(); } /** - * @brief Specify a file to open for input and/or output. - * @param s Null terminated string specifying filename. - * @param mode Mode in which to open file (see std::ios_base). + * @brief Opens an external file. + * @param s The name of the file. + * @param mode The open mode flags. + * + * Calls @c std::basic_filebuf::open(s,mode). If that + * function fails, @c failbit is set in the stream's error state. * * Tip: When using std::string to hold the filename, you must use * .c_str() before passing it to this constructor. @@ -559,7 +817,12 @@ namespace std setstate(ios_base::failbit); } - /** Close the file stream. */ + /** + * @brief Close the file. + * + * Calls @c std::basic_filebuf::close(). If that function + * fails, @c failbit is set in the stream's error state. + */ void close() { diff --git a/contrib/libstdc++/include/std/std_iomanip.h b/contrib/libstdc++/include/std/std_iomanip.h index 23237ce210d6..490d5ac1cfba 100644 --- a/contrib/libstdc++/include/std/std_iomanip.h +++ b/contrib/libstdc++/include/std/std_iomanip.h @@ -1,6 +1,7 @@ // Standard stream manipulators -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2001, 2002, 2003 +// Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -47,8 +48,18 @@ namespace std { + // [27.6.3] standard manipulators + // Also see DR 183. + struct _Resetiosflags { ios_base::fmtflags _M_mask; }; + /** + * @brief Manipulator for @c setf. + * @param mask A format flags mask. + * + * Sent to a stream object, this manipulator resets the specified flags, + * via @e stream.setf(0,mask). + */ inline _Resetiosflags resetiosflags(ios_base::fmtflags __mask) { @@ -76,6 +87,13 @@ namespace std struct _Setiosflags { ios_base::fmtflags _M_mask; }; + /** + * @brief Manipulator for @c setf. + * @param mask A format flags mask. + * + * Sent to a stream object, this manipulator sets the format flags + * to @a mask. + */ inline _Setiosflags setiosflags(ios_base::fmtflags __mask) { @@ -103,6 +121,14 @@ namespace std struct _Setbase { int _M_base; }; + /** + * @brief Manipulator for @c setf. + * @param base A numeric base. + * + * Sent to a stream object, this manipulator changes the + * @c ios_base::basefield flags to @c oct, @c dec, or @c hex when @a base + * is 8, 10, or 16, accordingly, and to 0 if @a base is any other value. + */ inline _Setbase setbase(int __base) { @@ -137,6 +163,13 @@ namespace std template<typename _CharT> struct _Setfill { _CharT _M_c; }; + /** + * @brief Manipulator for @c fill. + * @param c The new fill character. + * + * Sent to a stream object, this manipulator calls @c fill(c) for that + * object. + */ template<typename _CharT> inline _Setfill<_CharT> setfill(_CharT __c) @@ -165,6 +198,13 @@ namespace std struct _Setprecision { int _M_n; }; + /** + * @brief Manipulator for @c precision. + * @param n The new precision. + * + * Sent to a stream object, this manipulator calls @c precision(n) for + * that object. + */ inline _Setprecision setprecision(int __n) { @@ -192,6 +232,13 @@ namespace std struct _Setw { int _M_n; }; + /** + * @brief Manipulator for @c width. + * @param n The new width. + * + * Sent to a stream object, this manipulator calls @c width(n) for + * that object. + */ inline _Setw setw(int __n) { @@ -219,6 +266,7 @@ namespace std // Inhibit implicit instantiations for required instantiations, // which are defined via explicit instantiations elsewhere. // NB: This syntax is a GNU extension. +#if _GLIBCPP_EXTERN_TEMPLATE extern template ostream& operator<<(ostream&, _Setfill<char>); extern template ostream& operator<<(ostream&, _Setiosflags); extern template ostream& operator<<(ostream&, _Resetiosflags); @@ -246,6 +294,7 @@ namespace std extern template wistream& operator>>(wistream&, _Setprecision); extern template wistream& operator>>(wistream&, _Setw); #endif +#endif } // namespace std #endif diff --git a/contrib/libstdc++/include/std/std_iosfwd.h b/contrib/libstdc++/include/std/std_iosfwd.h index 797f4936dc8a..55b0e0b19fa7 100644 --- a/contrib/libstdc++/include/std/std_iosfwd.h +++ b/contrib/libstdc++/include/std/std_iosfwd.h @@ -1,6 +1,7 @@ // Forwarding declarations -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2001, 2002, 2003 +// Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -42,7 +43,9 @@ #pragma GCC system_header #include <bits/c++config.h> -#include <bits/stringfwd.h> // For string forward declarations. +#include <bits/c++locale.h> +#include <cctype> // For isspace, etc. +#include <bits/stringfwd.h> // For string forward declarations. #include <bits/fpos.h> #include <bits/functexcept.h> @@ -102,35 +105,64 @@ namespace std class ios_base; #endif - typedef basic_ios<char> ios; - typedef basic_streambuf<char> streambuf; - typedef basic_istream<char> istream; - typedef basic_ostream<char> ostream; - typedef basic_iostream<char> iostream; - typedef basic_stringbuf<char> stringbuf; - typedef basic_istringstream<char> istringstream; - typedef basic_ostringstream<char> ostringstream; - typedef basic_stringstream<char> stringstream; - typedef basic_filebuf<char> filebuf; - typedef basic_ifstream<char> ifstream; - typedef basic_ofstream<char> ofstream; - typedef basic_fstream<char> fstream; + /** + * @defgroup s27_2_iosfwd I/O Forward Declarations + * + * Nearly all of the I/O classes are parameterized on the type of + * characters they read and write. (The major exception is ios_base at + * the top of the hierarchy.) This is a change from pre-Standard + * streams, which were not templates. + * + * For ease of use and compatibility, all of the basic_* I/O-related + * classes are given typedef names for both of the builtin character + * widths (wide and narrow). The typedefs are the same as the + * pre-Standard names, for example: + * + * @code + * typedef basic_ifstream<char> ifstream; + * @endcode + * + * Because properly forward-declaring these classes can be difficult, you + * should not do it yourself. Instead, include the <iosfwd> + * header, which contains only declarations of all the I/O classes as + * well as the typedefs. Trying to forward-declare the typedefs + * themselves (e.g., "class ostream;") is not valid ISO C++. + * + * For more specific declarations, see + * http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#10 + * + * @{ + */ + typedef basic_ios<char> ios; ///< @isiosfwd + typedef basic_streambuf<char> streambuf; ///< @isiosfwd + typedef basic_istream<char> istream; ///< @isiosfwd + typedef basic_ostream<char> ostream; ///< @isiosfwd + typedef basic_iostream<char> iostream; ///< @isiosfwd + typedef basic_stringbuf<char> stringbuf; ///< @isiosfwd + typedef basic_istringstream<char> istringstream; ///< @isiosfwd + typedef basic_ostringstream<char> ostringstream; ///< @isiosfwd + typedef basic_stringstream<char> stringstream; ///< @isiosfwd + typedef basic_filebuf<char> filebuf; ///< @isiosfwd + typedef basic_ifstream<char> ifstream; ///< @isiosfwd + typedef basic_ofstream<char> ofstream; ///< @isiosfwd + typedef basic_fstream<char> fstream; ///< @isiosfwd #ifdef _GLIBCPP_USE_WCHAR_T - typedef basic_ios<wchar_t> wios; - typedef basic_streambuf<wchar_t> wstreambuf; - typedef basic_istream<wchar_t> wistream; - typedef basic_ostream<wchar_t> wostream; - typedef basic_iostream<wchar_t> wiostream; - typedef basic_stringbuf<wchar_t> wstringbuf; - typedef basic_istringstream<wchar_t> wistringstream; - typedef basic_ostringstream<wchar_t> wostringstream; - typedef basic_stringstream<wchar_t> wstringstream; - typedef basic_filebuf<wchar_t> wfilebuf; - typedef basic_ifstream<wchar_t> wifstream; - typedef basic_ofstream<wchar_t> wofstream; - typedef basic_fstream<wchar_t> wfstream; + typedef basic_ios<wchar_t> wios; ///< @isiosfwd + typedef basic_streambuf<wchar_t> wstreambuf; ///< @isiosfwd + typedef basic_istream<wchar_t> wistream; ///< @isiosfwd + typedef basic_ostream<wchar_t> wostream; ///< @isiosfwd + typedef basic_iostream<wchar_t> wiostream; ///< @isiosfwd + typedef basic_stringbuf<wchar_t> wstringbuf; ///< @isiosfwd + typedef basic_istringstream<wchar_t> wistringstream; ///< @isiosfwd + typedef basic_ostringstream<wchar_t> wostringstream; ///< @isiosfwd + typedef basic_stringstream<wchar_t> wstringstream; ///< @isiosfwd + typedef basic_filebuf<wchar_t> wfilebuf; ///< @isiosfwd + typedef basic_ifstream<wchar_t> wifstream; ///< @isiosfwd + typedef basic_ofstream<wchar_t> wofstream; ///< @isiosfwd + typedef basic_fstream<wchar_t> wfstream; ///< @isiosfwd #endif + /** @} */ } // namespace std #endif diff --git a/contrib/libstdc++/include/std/std_iostream.h b/contrib/libstdc++/include/std/std_iostream.h index d0736b835132..d70949377df1 100644 --- a/contrib/libstdc++/include/std/std_iostream.h +++ b/contrib/libstdc++/include/std/std_iostream.h @@ -47,17 +47,31 @@ namespace std { - extern istream cin; - extern ostream cout; - extern ostream cerr; - extern ostream clog; + /** + * @name Standard Stream Objects + * + * The <iostream> header declares the eight <em>standard stream + * objects</em>. For other declarations, see + * http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#10 and the + * @link s27_2_iosfwd I/O forward declarations @endlink + * + * They are required by default to cooperate with the global C library's + * @c FILE streams, and to be available during program startup and + * termination. For more information, see the HOWTO linked to above. + */ + //@{ + extern istream cin; ///< Linked to standard input + extern ostream cout; ///< Linked to standard output + extern ostream cerr; ///< Linked to standard error (unbuffered) + extern ostream clog; ///< Linked to standard error (buffered) #ifdef _GLIBCPP_USE_WCHAR_T - extern wistream wcin; - extern wostream wcout; - extern wostream wcerr; - extern wostream wclog; + extern wistream wcin; ///< Linked to standard input + extern wostream wcout; ///< Linked to standard output + extern wostream wcerr; ///< Linked to standard error (unbuffered) + extern wostream wclog; ///< Linked to standard error (buffered) #endif + //@} // For construction of filebuffers for cout, cin, cerr, clog et. al. static ios_base::Init __ioinit; diff --git a/contrib/libstdc++/include/std/std_istream.h b/contrib/libstdc++/include/std/std_istream.h index 8aa9123ed5c5..da9c7db18838 100644 --- a/contrib/libstdc++/include/std/std_istream.h +++ b/contrib/libstdc++/include/std/std_istream.h @@ -46,7 +46,14 @@ namespace std { - // 27.6.1.1 Template class basic_istream + // [27.6.1.1] Template class basic_istream + /** + * @brief Controlling input. + * + * This is the base class for all input streams. It provides text + * formatting of all builtin types, and communicates with any class + * derived from basic_streambuf to do the actual input. + */ template<typename _CharT, typename _Traits> class basic_istream : virtual public basic_ios<_CharT, _Traits> { @@ -66,12 +73,33 @@ namespace std typedef num_get<_CharT, __istreambuf_iter> __numget_type; typedef ctype<_CharT> __ctype_type; + template<typename _CharT2, typename _Traits2> + friend basic_istream<_CharT2, _Traits2>& + operator>>(basic_istream<_CharT2, _Traits2>&, _CharT2&); + + template<typename _CharT2, typename _Traits2> + friend basic_istream<_CharT2, _Traits2>& + operator>>(basic_istream<_CharT2, _Traits2>&, _CharT2*); + protected: // Data Members: + /** + * @if maint + * The number of characters extracted in the previous unformatted + * function; see gcount(). + * @endif + */ streamsize _M_gcount; public: - // 27.6.1.1.1 Constructor/destructor: + // [27.6.1.1.1] constructor/destructor + /** + * @brief Base constructor. + * + * This ctor is almost never called by the user directly, rather from + * derived classes' initialization lists, which pass a pointer to + * their own stream buffer. + */ explicit basic_istream(__streambuf_type* __sb) { @@ -79,16 +107,29 @@ namespace std _M_gcount = streamsize(0); } + /** + * @brief Base destructor. + * + * This does very little apart from providing a virtual base dtor. + */ virtual ~basic_istream() { _M_gcount = streamsize(0); } - // 27.6.1.1.2 Prefix/suffix: + // [27.6.1.1.2] prefix/suffix class sentry; friend class sentry; - // 27.6.1.2 Formatted input: - // 27.6.1.2.3 basic_istream::operator>> + // [27.6.1.2] formatted input + // [27.6.1.2.3] basic_istream::operator>> + //@{ + /** + * @brief Interface for manipulators. + * + * Manuipulators such as @c std::ws and @c std::dec use these + * functions in constructs like "std::cin >> std::ws". For more + * information, see the iomanip header. + */ __istream_type& operator>>(__istream_type& (*__pf)(__istream_type&)); @@ -97,8 +138,36 @@ namespace std __istream_type& operator>>(ios_base& (*__pf)(ios_base&)); + //@} - // 27.6.1.2.2 Arithmetic Extractors + // [27.6.1.2.2] arithmetic extractors + /** + * @name Arithmetic Extractors + * + * All the @c operator>> functions (aka <em>formatted input + * functions</em>) have some common behavior. Each starts by + * constructing a temporary object of type std::basic_istream::sentry + * with the second argument (noskipws) set to false. This has several + * effects, concluding with the setting of a status flag; see the + * sentry documentation for more. + * + * If the sentry status is good, the function tries to extract + * whatever data is appropriate for the type of the argument. + * + * If an exception is thrown during extraction, ios_base::badbit + * will be turned on in the stream's error state without causing an + * ios_base::failure to be thrown. The original exception will then + * be rethrown. + */ + //@{ + /** + * @brief Basic arithmetic extractors + * @param A variable of builtin type. + * @return @c *this if successful + * + * These functions use the stream's current locale (specifically, the + * @c num_get facet) to parse the input data. + */ __istream_type& operator>>(bool& __n); @@ -140,92 +209,431 @@ namespace std __istream_type& operator>>(void*& __p); + /** + * @brief Extracting into another streambuf. + * @param sb A pointer to a streambuf + * + * This function behaves like one of the basic arithmetic extractors, + * in that it also constructs a sentry onject and has the same error + * handling behavior. + * + * If @a sb is NULL, the stream will set failbit in its error state. + * + * Characters are extracted from this stream and inserted into the + * @a sb streambuf until one of the following occurs: + * + * - the input stream reaches end-of-file, + * - insertion into the output buffer fails (in this case, the + * character that would have been inserted is not extracted), or + * - an exception occurs (and in this case is caught) + * + * If the function inserts no characters, failbit is set. + */ __istream_type& operator>>(__streambuf_type* __sb); + //@} - // 27.6.1.3 Unformatted input: + // [27.6.1.3] unformatted input + /** + * @brief Character counting + * @return The number of characters extracted by the previous + * unformatted input function dispatched for this stream. + */ inline streamsize - gcount(void) const + gcount() const { return _M_gcount; } + /** + * @name Unformatted Input Functions + * + * All the unformatted input functions have some common behavior. + * Each starts by constructing a temporary object of type + * std::basic_istream::sentry with the second argument (noskipws) + * set to true. This has several effects, concluding with the + * setting of a status flag; see the sentry documentation for more. + * + * If the sentry status is good, the function tries to extract + * whatever data is appropriate for the type of the argument. + * + * The number of characters extracted is stored for later retrieval + * by gcount(). + * + * If an exception is thrown during extraction, ios_base::badbit + * will be turned on in the stream's error state without causing an + * ios_base::failure to be thrown. The original exception will then + * be rethrown. + */ + //@{ + /** + * @brief Simple extraction. + * @return A character, or eof(). + * + * Tries to extract a character. If none are available, sets failbit + * and returns traits::eof(). + */ int_type - get(void); + get(); + /** + * @brief Simple extraction. + * @param c The character in which to store data. + * @return *this + * + * Tries to extract a character and store it in @a c. If none are + * available, sets failbit and returns traits::eof(). + * + * @note This function is not overloaded on signed char and + * unsigned char. + */ __istream_type& get(char_type& __c); + /** + * @brief Simple multiple-character extraction. + * @param s Pointer to an array. + * @param n Maximum number of characters to store in @a s. + * @param delim A "stop" character. + * @return *this + * + * Characters are extracted and stored into @a s until one of the + * following happens: + * + * - @c n-1 characters are stored + * - the input sequence reaches EOF + * - the next character equals @a delim, in which case the character + * is not extracted + * + * If no characters are stored, failbit is set in the stream's error + * state. + * + * In any case, a null character is stored into the next location in + * the array. + * + * @note This function is not overloaded on signed char and + * unsigned char. + */ __istream_type& get(char_type* __s, streamsize __n, char_type __delim); + /** + * @brief Simple multiple-character extraction. + * @param s Pointer to an array. + * @param n Maximum number of characters to store in @a s. + * @return *this + * + * Returns @c get(s,n,widen('\n')). + */ inline __istream_type& get(char_type* __s, streamsize __n) { return this->get(__s, __n, this->widen('\n')); } + /** + * @brief Extraction into another streambuf. + * @param sb A streambuf in which to store data. + * @param delim A "stop" character. + * @return *this + * + * Characters are extracted and inserted into @a sb until one of the + * following happens: + * + * - the input sequence reaches EOF + * - insertion into the output buffer fails (in this case, the + * character that would have been inserted is not extracted) + * - the next character equals @a delim (in this case, the character + * is not extracted) + * - an exception occurs (and in this case is caught) + * + * If no characters are stored, failbit is set in the stream's error + * state. + */ __istream_type& get(__streambuf_type& __sb, char_type __delim); + /** + * @brief Extraction into another streambuf. + * @param sb A streambuf in which to store data. + * @return *this + * + * Returns @c get(sb,widen('\n')). + */ inline __istream_type& get(__streambuf_type& __sb) { return this->get(__sb, this->widen('\n')); } + /** + * @brief String extraction. + * @param s A character array in which to store the data. + * @param n Maximum number of characters to extract. + * @param delim A "stop" character. + * @return *this + * + * Extracts and stores characters into @a s until one of the + * following happens. Note that these criteria are required to be + * tested in the order listed here, to allow an input line to exactly + * fill the @a s array without setting failbit. + * + * -# the input sequence reaches end-of-file, in which case eofbit + * is set in the stream error state + * -# the next character equals @c delim, in which case the character + * is extracted (and therefore counted in @c gcount()) but not stored + * -# @c n-1 characters are stored, in which case failbit is set + * in the stream error state + * + * If no characters are extracted, failbit is set. (An empty line of + * input should therefore not cause failbit to be set.) + * + * In any case, a null character is stored in the next location in + * the array. + */ __istream_type& getline(char_type* __s, streamsize __n, char_type __delim); + /** + * @brief String extraction. + * @param s A character array in which to store the data. + * @param n Maximum number of characters to extract. + * @return *this + * + * Returns @c getline(s,n,widen('\n')). + */ inline __istream_type& getline(char_type* __s, streamsize __n) { return this->getline(__s, __n, this->widen('\n')); } + /** + * @brief Discarding characters + * @param n Number of characters to discard. + * @param delim A "stop" character. + * @return *this + * + * Extracts characters and throws them away until one of the + * following happens: + * - if @a n @c != @c std::numeric_limits<int>::max(), @a n + * characters are extracted + * - the input sequence reaches end-of-file + * - the next character equals @a delim (in this case, the character + * is extracted); note that this condition will never occur if + * @a delim equals @c traits::eof(). + */ __istream_type& ignore(streamsize __n = 1, int_type __delim = traits_type::eof()); + /** + * @brief Looking ahead in the stream + * @return The next character, or eof(). + * + * If, after constructing the sentry object, @c good() is false, + * returns @c traits::eof(). Otherwise reads but does not extract + * the next input character. + */ int_type - peek(void); + peek(); + /** + * @brief Extraction without delimiters. + * @param s A character array. + * @param n Maximum number of characters to store. + * @return *this + * + * If the stream state is @c good(), extracts characters and stores + * them into @a s until one of the following happens: + * - @a n characters are stored + * - the input sequence reaches end-of-file, in which case the error + * state is set to @c failbit|eofbit. + * + * @note This function is not overloaded on signed char and + * unsigned char. + */ __istream_type& read(char_type* __s, streamsize __n); + /** + * @brief Extraction until the buffer is exhausted, but no more. + * @param s A character array. + * @param n Maximum number of characters to store. + * @return The number of characters extracted. + * + * Extracts characters and stores them into @a s depending on the + * number of characters remaining in the streambuf's buffer, + * @c rdbuf()->in_avail(), called @c A here: + * - if @c A @c == @c -1, sets eofbit and extracts no characters + * - if @c A @c == @c 0, extracts no characters + * - if @c A @c > @c 0, extracts @c min(A,n) + * + * The goal is to empty the current buffer, and to not request any + * more from the external input sequence controlled by the streambuf. + */ streamsize readsome(char_type* __s, streamsize __n); + /** + * @brief Unextracting a single character. + * @param c The character to push back into the input stream. + * @return *this + * + * If @c rdbuf() is not null, calls @c rdbuf()->sputbackc(c). + * + * If @c rdbuf() is null or if @c sputbackc() fails, sets badbit in + * the error state. + * + * @note Since no characters are extracted, the next call to + * @c gcount() will return 0, as required by DR 60. + */ __istream_type& putback(char_type __c); + /** + * @brief Unextracting the previous character. + * @return *this + * + * If @c rdbuf() is not null, calls @c rdbuf()->sungetc(c). + * + * If @c rdbuf() is null or if @c sungetc() fails, sets badbit in + * the error state. + * + * @note Since no characters are extracted, the next call to + * @c gcount() will return 0, as required by DR 60. + */ __istream_type& - unget(void); + unget(); + /** + * @brief Synchronizing the stream buffer. + * @return 0 on success, -1 on failure + * + * If @c rdbuf() is a null pointer, returns -1. + * + * Otherwise, calls @c rdbuf()->pubsync(), and if that returns -1, + * sets badbit and returns -1. + * + * Otherwise, returns 0. + * + * @note This function does not count the number of characters + * extracted, if any, and therefore does not affect the next + * call to @c gcount(). + */ int - sync(void); + sync(); + /** + * @brief Getting the current read position. + * @return A file position object. + * + * If @c fail() is not false, returns @c pos_type(-1) to indicate + * failure. Otherwise returns @c rdbuf()->pubseekoff(0,cur,in). + * + * @note This function does not count the number of characters + * extracted, if any, and therefore does not affect the next + * call to @c gcount(). + */ pos_type - tellg(void); + tellg(); + /** + * @brief Changing the current read position. + * @param pos A file position object. + * @return *this + * + * If @c fail() is not true, calls @c rdbuf()->pubseekpos(pos). If + * that function fails, sets failbit. + * + * @note This function does not count the number of characters + * extracted, if any, and therefore does not affect the next + * call to @c gcount(). + */ __istream_type& seekg(pos_type); + /** + * @brief Changing the current read position. + * @param off A file offset object. + * @param dir The direction in which to seek. + * @return *this + * + * If @c fail() is not true, calls @c rdbuf()->pubseekoff(off,dir). + * If that function fails, sets failbit. + * + * @note This function does not count the number of characters + * extracted, if any, and therefore does not affect the next + * call to @c gcount(). + */ __istream_type& seekg(off_type, ios_base::seekdir); + //@} }; + /** + * @brief Performs setup work for input streams. + * + * Objects of this class are created before all of the standard + * extractors are run. It is responsible for "exception-safe prefix and + * suffix operations," although only prefix actions are currently required + * by the standard. Additional actions may be added by the + * implementation, and we list them in + * http://gcc.gnu.org/onlinedocs/libstdc++/17_intro/howto.html#5 + * under [27.6] notes. + */ template<typename _CharT, typename _Traits> class basic_istream<_CharT, _Traits>::sentry { public: + /// Easy access to dependant types. typedef _Traits traits_type; typedef basic_streambuf<_CharT, _Traits> __streambuf_type; typedef basic_istream<_CharT, _Traits> __istream_type; typedef typename __istream_type::__ctype_type __ctype_type; typedef typename _Traits::int_type __int_type; + /** + * @brief The constructor performs all the work. + * @param is The input stream to guard. + * @param noskipws Whether to consume whitespace or not. + * + * If the stream state is good (@a is.good() is true), then the + * following actions are performed, otherwise the sentry state is + * false ("not okay") and failbit is set in the stream state. + * + * The sentry's preparatory actions are: + * + * -# if the stream is tied to an output stream, @c is.tie()->flush() + * is called to synchronize the output sequence + * -# if @a noskipws is false, and @c ios_base::skipws is set in + * @c is.flags(), the sentry extracts and discards whitespace + * characters from the stream. The currently imbued locale is + * used to determine whether each character is whitespace. + * + * If the stream state is still good, then the sentry state becomes + * true ("okay"). + */ explicit sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false); + /** + * @brief Quick status checking. + * @return The sentry state. + * + * For ease of use, sentries may be converted to booleans. The + * return value is that of the sentry state (true == okay). + */ operator bool() { return _M_ok; } private: bool _M_ok; }; - // 27.6.1.2.3 Character extraction templates + // [27.6.1.2.3] character extraction templates + //@{ + /** + * @brief Character extractors + * @param in An input stream. + * @param c A character reference. + * @return in + * + * Behaves like one of the formatted arithmetic extractors described in + * std::basic_istream. After constructing a sentry object with good + * status, this function extracts a character (if one is available) and + * stores it in @a c. Otherwise, sets failbit in the input stream. + */ template<typename _CharT, typename _Traits> basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c); @@ -239,7 +647,34 @@ namespace std basic_istream<char, _Traits>& operator>>(basic_istream<char, _Traits>& __in, signed char& __c) { return (__in >> reinterpret_cast<char&>(__c)); } + //@} + //@{ + /** + * @brief Character string extractors + * @param in An input stream. + * @param s A pointer to a character array. + * @return in + * + * Behaves like one of the formatted arithmetic extractors described in + * std::basic_istream. After constructing a sentry object with good + * status, this function extracts up to @c n characters and stores them + * into the array starting at @a s. @c n is defined as: + * + * - if @c width() is greater than zero, @c n is width() + * - otherwise @c n is "the number of elements of the largest array of + * @c char_type that can store a terminating @c eos." [27.6.1.2.3]/6 + * + * Characters are extracted and stored until one of the following happens: + * - @c n-1 characters are stored + * - EOF is reached + * - the next character is whitespace according to the current locale + * - the next character is a null byte (i.e., @c charT() ) + * + * @c width(0) is then called for the input stream. + * + * If no characters are extracted, sets failbit. + */ template<typename _CharT, typename _Traits> basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s); @@ -253,8 +688,15 @@ namespace std basic_istream<char,_Traits>& operator>>(basic_istream<char,_Traits>& __in, signed char* __s) { return (__in >> reinterpret_cast<char*>(__s)); } + //@} // 27.6.1.5 Template class basic_iostream + /** + * @brief Merging istream and ostream capabilities. + * + * This class multiply inherits from the input and output stream classes + * simply to provide a single interface. + */ template<typename _CharT, typename _Traits> class basic_iostream : public basic_istream<_CharT, _Traits>, @@ -275,16 +717,45 @@ namespace std typedef basic_istream<_CharT, _Traits> __istream_type; typedef basic_ostream<_CharT, _Traits> __ostream_type; + /** + * @brief Constructor does nothing. + * + * Both of the parent classes are initialized with the same + * streambuf pointer passed to this constructor. + */ explicit basic_iostream(basic_streambuf<_CharT, _Traits>* __sb) : __istream_type(__sb), __ostream_type(__sb) { } + /** + * @brief Destructor does nothing. + */ virtual ~basic_iostream() { } }; - // 27.6.1.4 Standard basic_istream manipulators + // [27.6.1.4] standard basic_istream manipulators + /** + * @brief Quick and easy way to eat whitespace + * + * This manipulator extracts whitespace characters, stopping when the + * next character is non-whitespace, or when the input sequence is empty. + * If the sequence is empty, @c eofbit is set in the stream, but not + * @c failbit. + * + * The current locale is used to distinguish whitespace characters. + * + * Example: + * @code + * MyClass mc; + * + * std::cin >> std::ws >> mc; + * @endcode + * will skip leading whitespace before calling operator>> on cin and your + * object. Note that the same effect can be achieved by creating a + * std::basic_istream::sentry inside your definition of operator>>. + */ template<typename _CharT, typename _Traits> basic_istream<_CharT, _Traits>& ws(basic_istream<_CharT, _Traits>& __is); diff --git a/contrib/libstdc++/include/std/std_limits.h b/contrib/libstdc++/include/std/std_limits.h index 5f70ddab8e39..9be69477958f 100644 --- a/contrib/libstdc++/include/std/std_limits.h +++ b/contrib/libstdc++/include/std/std_limits.h @@ -45,7 +45,6 @@ #pragma GCC system_header -#include <bits/cpu_limits.h> #include <bits/c++config.h> // @@ -64,13 +63,13 @@ // double (1) // long double (1) // -// GNU C++ undertstands (where supported by the host C-library) +// GNU C++ undertstands (where supported by the host C-library) // * integer // long long, unsigned long long (2) // // which brings us to 15 fundamental arithmetic data types in GNU C++. // -// +// // Since a numeric_limits<> is a bit tricky to get right, we rely on // an interface composed of macros which should be defined in config/os // or config/cpu when they differ from the generic (read arbitrary) @@ -80,813 +79,77 @@ // These values can be overridden in the target configuration file. // The default values are appropriate for many 32-bit targets. -#ifndef __glibcpp_char_bits -#define __glibcpp_char_bits 8 -#endif -#ifdef __CHAR_UNSIGNED__ -#define __glibcpp_plain_char_is_signed false -#else -#define __glibcpp_plain_char_is_signed true -#endif -#ifndef __glibcpp_short_bits -#define __glibcpp_short_bits 16 -#endif -#ifndef __glibcpp_int_bits -#define __glibcpp_int_bits 32 -#endif -#ifndef __glibcpp_long_bits -#define __glibcpp_long_bits 32 -#endif -#ifndef __glibcpp_wchar_t_bits -#define __glibcpp_wchar_t_bits 32 -#endif -#ifndef __glibcpp_wchar_t_is_signed -#define __glibcpp_wchar_t_is_signed true -#endif -#ifndef __glibcpp_long_long_bits -#define __glibcpp_long_long_bits 64 -#endif -#ifndef __glibcpp_float_bits -#define __glibcpp_float_bits 32 -#endif -#ifndef __glibcpp_double_bits -#define __glibcpp_double_bits 64 -#endif -#ifndef __glibcpp_long_double_bits -#define __glibcpp_long_double_bits 128 -#endif - -#ifndef __glibcpp_char_traps -#define __glibcpp_char_traps true -#endif -#ifndef __glibcpp_short_traps -#define __glibcpp_short_traps true -#endif -#ifndef __glibcpp_int_traps -#define __glibcpp_int_traps true -#endif -#ifndef __glibcpp_long_traps -#define __glibcpp_long_traps true -#endif -#ifndef __glibcpp_wchar_t_traps -#define __glibcpp_wchar_t_traps true -#endif -#ifndef __glibcpp_long_long_traps -#define __glibcpp_long_long_traps true -#endif - -// You should not need to define any macros below this point, unless -// you have a machine with non-standard bit-widths. - -// These values are the minimums and maximums for standard data types -// of common widths. - -#define __glibcpp_s8_max 127 -#define __glibcpp_s8_min (-__glibcpp_s8_max - 1) -#define __glibcpp_s8_digits 7 -#define __glibcpp_s8_digits10 2 -#define __glibcpp_u8_min 0U -#define __glibcpp_u8_max (__glibcpp_s8_max * 2 + 1) -#define __glibcpp_u8_digits 8 -#define __glibcpp_u8_digits10 2 -#define __glibcpp_s16_max 32767 -#define __glibcpp_s16_min (-__glibcpp_s16_max - 1) -#define __glibcpp_s16_digits 15 -#define __glibcpp_s16_digits10 4 -#define __glibcpp_u16_min 0U -#define __glibcpp_u16_max (__glibcpp_s16_max * 2 + 1) -#define __glibcpp_u16_digits 16 -#define __glibcpp_u16_digits10 4 -#define __glibcpp_s32_max 2147483647L -#define __glibcpp_s32_min (-__glibcpp_s32_max - 1) -#define __glibcpp_s32_digits 31 -#define __glibcpp_s32_digits10 9 -#define __glibcpp_u32_min 0UL -#define __glibcpp_u32_max (__glibcpp_s32_max * 2U + 1) -#define __glibcpp_u32_digits 32 -#define __glibcpp_u32_digits10 9 -#define __glibcpp_s64_max 9223372036854775807LL -#define __glibcpp_s64_min (-__glibcpp_s64_max - 1) -#define __glibcpp_s64_digits 63 -#define __glibcpp_s64_digits10 18 -#define __glibcpp_u64_min 0ULL -#define __glibcpp_u64_max (__glibcpp_s64_max * 2ULL + 1) -#define __glibcpp_u64_digits 64 -#define __glibcpp_u64_digits10 19 - -#define __glibcpp_f32_min 1.17549435e-38F -#define __glibcpp_f32_max 3.40282347e+38F -#define __glibcpp_f32_digits 24 -#define __glibcpp_f32_digits10 6 -#define __glibcpp_f32_radix 2 -#define __glibcpp_f32_epsilon 1.19209290e-07F -#define __glibcpp_f32_round_error 1.0F -#define __glibcpp_f32_min_exponent -125 -#define __glibcpp_f32_min_exponent10 -37 -#define __glibcpp_f32_max_exponent 128 -#define __glibcpp_f32_max_exponent10 38 -#define __glibcpp_f64_min 2.2250738585072014e-308 -#define __glibcpp_f64_max 1.7976931348623157e+308 -#define __glibcpp_f64_digits 53 -#define __glibcpp_f64_digits10 15 -#define __glibcpp_f64_radix 2 -#define __glibcpp_f64_epsilon 2.2204460492503131e-16 -#define __glibcpp_f64_round_error 1.0 -#define __glibcpp_f64_min_exponent -1021 -#define __glibcpp_f64_min_exponent10 -307 -#define __glibcpp_f64_max_exponent 1024 -#define __glibcpp_f64_max_exponent10 308 -#define __glibcpp_f80_min 3.36210314311209350626e-4932L -#define __glibcpp_f80_max 1.18973149535723176502e+4932L -#define __glibcpp_f80_digits 64 -#define __glibcpp_f80_digits10 18 -#define __glibcpp_f80_radix 2 -#define __glibcpp_f80_epsilon 1.08420217248550443401e-19L -#define __glibcpp_f80_round_error 1.0L -#define __glibcpp_f80_min_exponent -16381 -#define __glibcpp_f80_min_exponent10 -4931 -#define __glibcpp_f80_max_exponent 16384 -#define __glibcpp_f80_max_exponent10 4932 -#define __glibcpp_f96_min 1.68105157155604675313e-4932L -#define __glibcpp_f96_max 1.18973149535723176502e+4932L -#define __glibcpp_f96_digits 64 -#define __glibcpp_f96_digits10 18 -#define __glibcpp_f96_radix 2 -#define __glibcpp_f96_epsilon 1.08420217248550443401e-19L -#define __glibcpp_f96_round_error 1.0L -#define __glibcpp_f96_min_exponent -16382 -#define __glibcpp_f96_min_exponent10 -4931 -#define __glibcpp_f96_max_exponent 16384 -#define __glibcpp_f96_max_exponent10 4932 -#define __glibcpp_f128_min 3.362103143112093506262677817321752603E-4932L -#define __glibcpp_f128_max 1.189731495357231765085759326628007016E+4932L -#define __glibcpp_f128_digits 113 -#define __glibcpp_f128_digits10 33 -#define __glibcpp_f128_radix 2 -#define __glibcpp_f128_epsilon 1.925929944387235853055977942584927319E-34L -#define __glibcpp_f128_round_error 1.0L -#define __glibcpp_f128_min_exponent -16381 -#define __glibcpp_f128_min_exponent10 -4931 -#define __glibcpp_f128_max_exponent 16384 -#define __glibcpp_f128_max_exponent10 4932 - -// bool-specific hooks: -// __glibcpp_bool_digits __glibcpp_int_traps __glibcpp_long_traps - -#ifndef __glibcpp_bool_digits -#define __glibcpp_bool_digits 1 -#endif - -// char. - -#define __glibcpp_plain_char_traps true -#define __glibcpp_signed_char_traps true -#define __glibcpp_unsigned_char_traps true -#ifndef __glibcpp_char_is_modulo -#define __glibcpp_char_is_modulo true -#endif -#ifndef __glibcpp_signed_char_is_modulo -#define __glibcpp_signed_char_is_modulo true -#endif -#if __glibcpp_char_bits == 8 -#define __glibcpp_signed_char_min __glibcpp_s8_min -#define __glibcpp_signed_char_max __glibcpp_s8_max -#define __glibcpp_signed_char_digits __glibcpp_s8_digits -#define __glibcpp_signed_char_digits10 __glibcpp_s8_digits10 -#define __glibcpp_unsigned_char_min __glibcpp_u8_min -#define __glibcpp_unsigned_char_max __glibcpp_u8_max -#define __glibcpp_unsigned_char_digits __glibcpp_u8_digits -#define __glibcpp_unsigned_char_digits10 __glibcpp_u8_digits10 -#elif __glibcpp_char_bits == 16 -#define __glibcpp_signed_char_min __glibcpp_s16_min -#define __glibcpp_signed_char_max __glibcpp_s16_max -#define __glibcpp_signed_char_digits __glibcpp_s16_digits -#define __glibcpp_signed_char_digits10 __glibcpp_s16_digits10 -#define __glibcpp_unsigned_char_min __glibcpp_u16_min -#define __glibcpp_unsigned_char_max __glibcpp_u16_max -#define __glibcpp_unsigned_char_digits __glibcpp_u16_digits -#define __glibcpp_unsigned_char_digits10 __glibcpp_u16_digits10 -#elif __glibcpp_char_bits == 32 -#define __glibcpp_signed_char_min (signed char)__glibcpp_s32_min -#define __glibcpp_signed_char_max (signed char)__glibcpp_s32_max -#define __glibcpp_signed_char_digits __glibcpp_s32_digits -#define __glibcpp_signed_char_digits10 __glibcpp_s32_digits10 -#define __glibcpp_unsigned_char_min (unsigned char)__glibcpp_u32_min -#define __glibcpp_unsigned_char_max (unsigned char)__glibcpp_u32_max -#define __glibcpp_unsigned_char_digits __glibcpp_u32_digits -#define __glibcpp_unsigned_char_digits10 __glibcpp_u32_digits10 -#elif __glibcpp_char_bits == 64 -#define __glibcpp_signed_char_min (signed char)__glibcpp_s64_min -#define __glibcpp_signed_char_max (signed char)__glibcpp_s64_max -#define __glibcpp_signed_char_digits __glibcpp_s64_digits -#define __glibcpp_signed_char_digits10 __glibcpp_s64_digits10 -#define __glibcpp_unsigned_char_min (unsigned char)__glibcpp_u64_min -#define __glibcpp_unsigned_char_max (unsigned char)__glibcpp_u64_max -#define __glibcpp_unsigned_char_digits __glibcpp_u64_digits -#define __glibcpp_unsigned_char_digits10 __glibcpp_u64_digits10 -#else -// You must define these macros in the configuration file. -#endif - -#if __glibcpp_plain_char_is_signed -#define __glibcpp_char_min (char)__glibcpp_signed_char_min -#define __glibcpp_char_max (char)__glibcpp_signed_char_max -#define __glibcpp_char_digits __glibcpp_signed_char_digits -#define __glibcpp_char_digits10 __glibcpp_signed_char_digits10 -#else -#define __glibcpp_char_min (char)__glibcpp_unsigned_char_min -#define __glibcpp_char_max (char)__glibcpp_unsigned_char_max -#define __glibcpp_char_digits __glibcpp_unsigned_char_digits -#define __glibcpp_char_digits10 __glibcpp_unsigned_char_digits10 -#endif - -// short - -#define __glibcpp_signed_short_traps true -#define __glibcpp_unsigned_short_traps true -#ifndef __glibcpp_signed_short_is_modulo -#define __glibcpp_signed_short_is_modulo true -#endif -#if __glibcpp_short_bits == 8 -#define __glibcpp_signed_short_min __glibcpp_s8_min -#define __glibcpp_signed_short_max __glibcpp_s8_max -#define __glibcpp_signed_short_digits __glibcpp_s8_digits -#define __glibcpp_signed_short_digits10 __glibcpp_s8_digits10 -#define __glibcpp_unsigned_short_min __glibcpp_u8_min -#define __glibcpp_unsigned_short_max __glibcpp_u8_max -#define __glibcpp_unsigned_short_digits __glibcpp_u8_digits -#define __glibcpp_unsigned_short_digits10 __glibcpp_u8_digits10 -#elif __glibcpp_short_bits == 16 -#define __glibcpp_signed_short_min __glibcpp_s16_min -#define __glibcpp_signed_short_max __glibcpp_s16_max -#define __glibcpp_signed_short_digits __glibcpp_s16_digits -#define __glibcpp_signed_short_digits10 __glibcpp_s16_digits10 -#define __glibcpp_unsigned_short_min __glibcpp_u16_min -#define __glibcpp_unsigned_short_max __glibcpp_u16_max -#define __glibcpp_unsigned_short_digits __glibcpp_u16_digits -#define __glibcpp_unsigned_short_digits10 __glibcpp_u16_digits10 -#elif __glibcpp_short_bits == 32 -#define __glibcpp_signed_short_min (short)__glibcpp_s32_min -#define __glibcpp_signed_short_max (short)__glibcpp_s32_max -#define __glibcpp_signed_short_digits __glibcpp_s32_digits -#define __glibcpp_signed_short_digits10 __glibcpp_s32_digits10 -#define __glibcpp_unsigned_short_min (unsigned short)__glibcpp_u32_min -#define __glibcpp_unsigned_short_max (unsigned short)__glibcpp_u32_max -#define __glibcpp_unsigned_short_digits __glibcpp_u32_digits -#define __glibcpp_unsigned_short_digits10 __glibcpp_u32_digits10 -#elif __glibcpp_short_bits == 64 -#define __glibcpp_signed_short_min (short)__glibcpp_s64_min -#define __glibcpp_signed_short_max (short)__glibcpp_s64_max -#define __glibcpp_signed_short_digits __glibcpp_s64_digits -#define __glibcpp_signed_short_digits10 __glibcpp_s64_digits10 -#define __glibcpp_unsigned_short_min (unsigned short)__glibcpp_u64_min -#define __glibcpp_unsigned_short_max (unsigned short)__glibcpp_u64_max -#define __glibcpp_unsigned_short_digits __glibcpp_u64_digits -#define __glibcpp_unsigned_short_digits10 __glibcpp_u64_digits10 -#else -// You must define these macros in the configuration file. -#endif - -// int - -#define __glibcpp_signed_int_traps true -#define __glibcpp_unsigned_int_traps true -#ifndef __glibcpp_signed_int_is_modulo -#define __glibcpp_signed_int_is_modulo true -#endif -#if __glibcpp_int_bits == 8 -#define __glibcpp_signed_int_min __glibcpp_s8_min -#define __glibcpp_signed_int_max __glibcpp_s8_max -#define __glibcpp_signed_int_digits __glibcpp_s8_digits -#define __glibcpp_signed_int_digits10 __glibcpp_s8_digits10 -#define __glibcpp_unsigned_int_min __glibcpp_u8_min -#define __glibcpp_unsigned_int_max __glibcpp_u8_max -#define __glibcpp_unsigned_int_digits __glibcpp_u8_digits -#define __glibcpp_unsigned_int_digits10 __glibcpp_u8_digits10 -#elif __glibcpp_int_bits == 16 -#define __glibcpp_signed_int_min __glibcpp_s16_min -#define __glibcpp_signed_int_max __glibcpp_s16_max -#define __glibcpp_signed_int_digits __glibcpp_s16_digits -#define __glibcpp_signed_int_digits10 __glibcpp_s16_digits10 -#define __glibcpp_unsigned_int_min __glibcpp_u16_min -#define __glibcpp_unsigned_int_max __glibcpp_u16_max -#define __glibcpp_unsigned_int_digits __glibcpp_u16_digits -#define __glibcpp_unsigned_int_digits10 __glibcpp_u16_digits10 -#elif __glibcpp_int_bits == 32 -#define __glibcpp_signed_int_min (int)__glibcpp_s32_min -#define __glibcpp_signed_int_max (int)__glibcpp_s32_max -#define __glibcpp_signed_int_digits __glibcpp_s32_digits -#define __glibcpp_signed_int_digits10 __glibcpp_s32_digits10 -#define __glibcpp_unsigned_int_min (unsigned)__glibcpp_u32_min -#define __glibcpp_unsigned_int_max (unsigned)__glibcpp_u32_max -#define __glibcpp_unsigned_int_digits __glibcpp_u32_digits -#define __glibcpp_unsigned_int_digits10 __glibcpp_u32_digits10 -#elif __glibcpp_int_bits == 64 -#define __glibcpp_signed_int_min (int)__glibcpp_s64_min -#define __glibcpp_signed_int_max (int)__glibcpp_s64_max -#define __glibcpp_signed_int_digits __glibcpp_s64_digits -#define __glibcpp_signed_int_digits10 __glibcpp_s64_digits10 -#define __glibcpp_unsigned_int_min (unsigned)__glibcpp_u64_min -#define __glibcpp_unsigned_int_max (unsigned)__glibcpp_u64_max -#define __glibcpp_unsigned_int_digits __glibcpp_u64_digits -#define __glibcpp_unsigned_int_digits10 __glibcpp_u64_digits10 -#else -// You must define these macros in the configuration file. -#endif - -// long - -#define __glibcpp_signed_long_traps true -#define __glibcpp_unsigned_long_traps true -#ifndef __glibcpp_signed_long_is_modulo -#define __glibcpp_signed_long_is_modulo true -#endif -#if __glibcpp_long_bits == 8 -#define __glibcpp_signed_long_min __glibcpp_s8_min -#define __glibcpp_signed_long_max __glibcpp_s8_max -#define __glibcpp_signed_long_digits __glibcpp_s8_digits -#define __glibcpp_signed_long_digits10 __glibcpp_s8_digits10 -#define __glibcpp_unsigned_long_min __glibcpp_u8_min -#define __glibcpp_unsigned_long_max __glibcpp_u8_max -#define __glibcpp_unsigned_long_digits __glibcpp_u8_digits -#define __glibcpp_unsigned_long_digits10 __glibcpp_u8_digits10 -#elif __glibcpp_long_bits == 16 -#define __glibcpp_signed_long_min __glibcpp_s16_min -#define __glibcpp_signed_long_max __glibcpp_s16_max -#define __glibcpp_signed_long_digits __glibcpp_s16_digits -#define __glibcpp_signed_long_digits10 __glibcpp_s16_digits10 -#define __glibcpp_unsigned_long_min __glibcpp_u16_min -#define __glibcpp_unsigned_long_max __glibcpp_u16_max -#define __glibcpp_unsigned_long_digits __glibcpp_u16_digits -#define __glibcpp_unsigned_long_digits10 __glibcpp_u16_digits10 -#elif __glibcpp_long_bits == 32 -#define __glibcpp_signed_long_min __glibcpp_s32_min -#define __glibcpp_signed_long_max __glibcpp_s32_max -#define __glibcpp_signed_long_digits __glibcpp_s32_digits -#define __glibcpp_signed_long_digits10 __glibcpp_s32_digits10 -#define __glibcpp_unsigned_long_min __glibcpp_u32_min -#define __glibcpp_unsigned_long_max __glibcpp_u32_max -#define __glibcpp_unsigned_long_digits __glibcpp_u32_digits -#define __glibcpp_unsigned_long_digits10 __glibcpp_u32_digits10 -#elif __glibcpp_long_bits == 64 -#define __glibcpp_signed_long_min (long)__glibcpp_s64_min -#define __glibcpp_signed_long_max (long)__glibcpp_s64_max -#define __glibcpp_signed_long_digits __glibcpp_s64_digits -#define __glibcpp_signed_long_digits10 __glibcpp_s64_digits10 -#define __glibcpp_unsigned_long_min (unsigned long)__glibcpp_u64_min -#define __glibcpp_unsigned_long_max (unsigned long)__glibcpp_u64_max -#define __glibcpp_unsigned_long_digits __glibcpp_u64_digits -#define __glibcpp_unsigned_long_digits10 __glibcpp_u64_digits10 -#else -// You must define these macros in the configuration file. -#endif - -// long long - -#define __glibcpp_signed_long_long_traps true -#define __glibcpp_signed_long_long_traps true -#ifndef __glibcpp_signed_long_long_is_modulo -#define __glibcpp_signed_long_long_is_modulo true -#endif -#if __glibcpp_long_long_bits == 8 -#define __glibcpp_signed_long_long_min __glibcpp_s8_min -#define __glibcpp_signed_long_long_max __glibcpp_s8_max -#define __glibcpp_signed_long_long_digits __glibcpp_s8_digits -#define __glibcpp_signed_long_long_digits10 __glibcpp_s8_digits10 -#define __glibcpp_unsigned_long_long_min __glibcpp_u8_min -#define __glibcpp_unsigned_long_long_max __glibcpp_u8_max -#define __glibcpp_unsigned_long_long_digits __glibcpp_u8_digits -#define __glibcpp_unsigned_long_long_digits10 __glibcpp_u8_digits10 -#elif __glibcpp_long_long_bits == 16 -#define __glibcpp_signed_long_long_min __glibcpp_s16_min -#define __glibcpp_signed_long_long_max __glibcpp_s16_max -#define __glibcpp_signed_long_long_digits __glibcpp_s16_digits -#define __glibcpp_signed_long_long_digits10 __glibcpp_s16_digits10 -#define __glibcpp_unsigned_long_long_min __glibcpp_u16_min -#define __glibcpp_unsigned_long_long_max __glibcpp_u16_max -#define __glibcpp_unsigned_long_long_digits __glibcpp_u16_digits -#define __glibcpp_unsigned_long_long_digits10 __glibcpp_u16_digits10 -#elif __glibcpp_long_long_bits == 32 -#define __glibcpp_signed_long_long_min __glibcpp_s32_min -#define __glibcpp_signed_long_long_max __glibcpp_s32_max -#define __glibcpp_signed_long_long_digits __glibcpp_s32_digits -#define __glibcpp_signed_long_long_digits10 __glibcpp_s32_digits10 -#define __glibcpp_unsigned_long_long_min __glibcpp_u32_min -#define __glibcpp_unsigned_long_long_max __glibcpp_u32_max -#define __glibcpp_unsigned_long_long_digits __glibcpp_u32_digits -#define __glibcpp_unsigned_long_long_digits10 __glibcpp_u32_digits10 -#elif __glibcpp_long_long_bits == 64 -#define __glibcpp_signed_long_long_min __glibcpp_s64_min -#define __glibcpp_signed_long_long_max __glibcpp_s64_max -#define __glibcpp_signed_long_long_digits __glibcpp_s64_digits -#define __glibcpp_signed_long_long_digits10 __glibcpp_s64_digits10 -#define __glibcpp_signed_long_long_traps true -#define __glibcpp_unsigned_long_long_min __glibcpp_u64_min -#define __glibcpp_unsigned_long_long_max __glibcpp_u64_max -#define __glibcpp_unsigned_long_long_digits __glibcpp_u64_digits -#define __glibcpp_unsigned_long_long_digits10 __glibcpp_u64_digits10 -#define __glibcpp_unsigned_long_long_traps true -#else -// You must define these macros in the configuration file. -#endif - -// wchar_t - -#define __glibcpp_wchar_t_traps true -#ifndef __glibcpp_wchar_t_is_modulo -#define __glibcpp_wchar_t_is_modulo true -#endif -#if __glibcpp_wchar_t_is_signed -#if __glibcpp_wchar_t_bits == 8 -#define __glibcpp_wchar_t_min __glibcpp_s8_min -#define __glibcpp_wchar_t_max __glibcpp_s8_max -#define __glibcpp_wchar_t_digits __glibcpp_s8_digits -#define __glibcpp_wchar_t_digits10 __glibcpp_s8_digits10 -#elif __glibcpp_wchar_t_bits == 16 -#define __glibcpp_wchar_t_min __glibcpp_s16_min -#define __glibcpp_wchar_t_max __glibcpp_s16_max -#define __glibcpp_wchar_t_digits __glibcpp_s16_digits -#define __glibcpp_wchar_t_digits10 __glibcpp_s16_digits10 -#elif __glibcpp_wchar_t_bits == 32 -#define __glibcpp_wchar_t_min (wchar_t)__glibcpp_s32_min -#define __glibcpp_wchar_t_max (wchar_t)__glibcpp_s32_max -#define __glibcpp_wchar_t_digits __glibcpp_s32_digits -#define __glibcpp_wchar_t_digits10 __glibcpp_s32_digits10 -#elif __glibcpp_wchar_t_bits == 64 -#define __glibcpp_wchar_t_min (wchar_t)__glibcpp_s64_min -#define __glibcpp_wchar_t_max (wchar_t)__glibcpp_s64_max -#define __glibcpp_wchar_t_digits __glibcpp_s64_digits -#define __glibcpp_wchar_t_digits10 __glibcpp_s64_digits10 -#else -// You must define these macros in the configuration file. -#endif -#else -#if __glibcpp_wchar_t_bits == 8 -#define __glibcpp_wchar_t_min __glibcpp_u8_min -#define __glibcpp_wchar_t_max __glibcpp_u8_max -#define __glibcpp_wchar_t_digits __glibcpp_u8_digits -#define __glibcpp_wchar_t_digits10 __glibcpp_u8_digits10 -#elif __glibcpp_wchar_t_bits == 16 -#define __glibcpp_wchar_t_min __glibcpp_u16_min -#define __glibcpp_wchar_t_max __glibcpp_u16_max -#define __glibcpp_wchar_t_digits __glibcpp_u16_digits -#define __glibcpp_wchar_t_digits10 __glibcpp_u16_digits10 -#elif __glibcpp_wchar_t_bits == 32 -#define __glibcpp_wchar_t_min (wchar_t)__glibcpp_u32_min -#define __glibcpp_wchar_t_max (wchar_t)__glibcpp_u32_max -#define __glibcpp_wchar_t_digits __glibcpp_u32_digits -#define __glibcpp_wchar_t_digits10 __glibcpp_u32_digits10 -#elif __glibcpp_wchar_t_bits == 64 -#define __glibcpp_wchar_t_min (wchar_t)__glibcpp_u64_min -#define __glibcpp_wchar_t_max (wchar_t)__glibcpp_u64_max -#define __glibcpp_wchar_t_digits __glibcpp_u64_digits -#define __glibcpp_wchar_t_digits10 __glibcpp_u64_digits10 -#else -// You must define these macros in the configuration file. -#endif +// GCC only intrinsicly supports modulo integral types. The only remaining +// integral exceptional values is division by zero. Only targets that do not +// signal division by zero in some "hard to ignore" way should use false. +#ifndef __glibcpp_integral_traps +# define __glibcpp_integral_traps true #endif // float // -#if __glibcpp_float_bits == 32 -#define __glibcpp_float_min __glibcpp_f32_min -#define __glibcpp_float_max __glibcpp_f32_max -#define __glibcpp_float_digits __glibcpp_f32_digits -#define __glibcpp_float_digits10 __glibcpp_f32_digits10 -#define __glibcpp_float_radix __glibcpp_f32_radix -#define __glibcpp_float_epsilon __glibcpp_f32_epsilon -#define __glibcpp_float_round_error __glibcpp_f32_round_error -#define __glibcpp_float_min_exponent __glibcpp_f32_min_exponent -#define __glibcpp_float_min_exponent10 __glibcpp_f32_min_exponent10 -#define __glibcpp_float_max_exponent __glibcpp_f32_max_exponent -#define __glibcpp_float_max_exponent10 __glibcpp_f32_max_exponent10 -#elif __glibcpp_float_bits == 64 -#define __glibcpp_float_min __glibcpp_f64_min -#define __glibcpp_float_max __glibcpp_f64_max -#define __glibcpp_float_digits __glibcpp_f64_digits -#define __glibcpp_float_digits10 __glibcpp_f64_digits10 -#define __glibcpp_float_radix __glibcpp_f64_radix -#define __glibcpp_float_epsilon __glibcpp_f64_epsilon -#define __glibcpp_float_round_error __glibcpp_f64_round_error -#define __glibcpp_float_min_exponent __glibcpp_f64_min_exponent -#define __glibcpp_float_min_exponent10 __glibcpp_f64_min_exponent10 -#define __glibcpp_float_max_exponent __glibcpp_f64_max_exponent -#define __glibcpp_float_max_exponent10 __glibcpp_f64_max_exponent10 -#elif __glibcpp_float_bits == 80 -#define __glibcpp_float_min __glibcpp_f80_min -#define __glibcpp_float_max __glibcpp_f80_max -#define __glibcpp_float_digits __glibcpp_f80_digits -#define __glibcpp_float_digits10 __glibcpp_f80_digits10 -#define __glibcpp_float_radix __glibcpp_f80_radix -#define __glibcpp_float_epsilon __glibcpp_f80_epsilon -#define __glibcpp_float_round_error __glibcpp_f80_round_error -#define __glibcpp_float_min_exponent __glibcpp_f80_min_exponent -#define __glibcpp_float_min_exponent10 __glibcpp_f80_min_exponent10 -#define __glibcpp_float_max_exponent __glibcpp_f80_max_exponent -#define __glibcpp_float_max_exponent10 __glibcpp_f80_max_exponent10 -#else -// You must define these macros in the configuration file. -#endif - -// FIXME: These are just stubs and inkorrect - -#ifndef __glibcpp_float_has_infinity -#define __glibcpp_float_has_infinity false -#endif - -#ifndef __glibcpp_float_has_quiet_NaN -#define __glibcpp_float_has_quiet_NaN false -#endif - -#ifndef __glibcpp_float_has_signaling_NaN -#define __glibcpp_float_has_signaling_NaN false -#endif - -#ifndef __glibcpp_float_has_denorm -#define __glibcpp_float_has_denorm denorm_absent -#endif +// Default values. Should be overriden in configuration files if necessary. #ifndef __glibcpp_float_has_denorm_loss -#define __glibcpp_float_has_denorm_loss false -#endif - -#ifndef __glibcpp_float_infinity -#define __glibcpp_float_infinity 0.0F -#endif - -#ifndef __glibcpp_float_quiet_NaN -#define __glibcpp_float_quiet_NaN 0.0F +# define __glibcpp_float_has_denorm_loss false #endif - -#ifndef __glibcpp_float_signaling_NaN -#define __glibcpp_float_signaling_NaN 0.0F -#endif - -#ifndef __glibcpp_float_denorm_min -#define __glibcpp_float_denorm_min 0.0F -#endif - -#ifndef __glibcpp_float_is_iec559 -#define __glibcpp_float_is_iec559 false -#endif - -#ifndef __glibcpp_float_is_bounded -#define __glibcpp_float_is_bounded true -#endif - -#ifndef __glibcpp_float_is_modulo -#define __glibcpp_float_is_modulo false -#endif - #ifndef __glibcpp_float_traps -#define __glibcpp_float_traps false +# define __glibcpp_float_traps false #endif - #ifndef __glibcpp_float_tinyness_before -#define __glibcpp_float_tinyness_before false -#endif - -#ifndef __glibcpp_float_round_style -#define __glibcpp_float_round_style round_toward_zero +# define __glibcpp_float_tinyness_before false #endif // double -#if __glibcpp_double_bits == 32 -#define __glibcpp_double_min __glibcpp_f32_min -#define __glibcpp_double_max __glibcpp_f32_max -#define __glibcpp_double_digits __glibcpp_f32_digits -#define __glibcpp_double_digits10 __glibcpp_f32_digits10 -#define __glibcpp_double_radix __glibcpp_f32_radix -#define __glibcpp_double_epsilon __glibcpp_f32_epsilon -#define __glibcpp_double_round_error __glibcpp_f32_round_error -#define __glibcpp_double_min_exponent __glibcpp_f32_min_exponent -#define __glibcpp_double_min_exponent10 __glibcpp_f32_min_exponent10 -#define __glibcpp_double_max_exponent __glibcpp_f32_max_exponent -#define __glibcpp_double_max_exponent10 __glibcpp_f32_max_exponent10 -#elif __glibcpp_double_bits == 64 -#define __glibcpp_double_min __glibcpp_f64_min -#define __glibcpp_double_max __glibcpp_f64_max -#define __glibcpp_double_digits __glibcpp_f64_digits -#define __glibcpp_double_digits10 __glibcpp_f64_digits10 -#define __glibcpp_double_radix __glibcpp_f64_radix -#define __glibcpp_double_epsilon __glibcpp_f64_epsilon -#define __glibcpp_double_round_error __glibcpp_f64_round_error -#define __glibcpp_double_min_exponent __glibcpp_f64_min_exponent -#define __glibcpp_double_min_exponent10 __glibcpp_f64_min_exponent10 -#define __glibcpp_double_max_exponent __glibcpp_f64_max_exponent -#define __glibcpp_double_max_exponent10 __glibcpp_f64_max_exponent10 -#elif __glibcpp_double_bits == 80 -#define __glibcpp_double_min __glibcpp_f80_min -#define __glibcpp_double_max __glibcpp_f80_max -#define __glibcpp_double_digits __glibcpp_f80_digits -#define __glibcpp_double_digits10 __glibcpp_f80_digits10 -#define __glibcpp_double_radix __glibcpp_f80_radix -#define __glibcpp_double_epsilon __glibcpp_f80_epsilon -#define __glibcpp_double_round_error __glibcpp_f80_round_error -#define __glibcpp_double_min_exponent __glibcpp_f80_min_exponent -#define __glibcpp_double_min_exponent10 __glibcpp_f80_min_exponent10 -#define __glibcpp_double_max_exponent __glibcpp_f80_max_exponent -#define __glibcpp_double_max_exponent10 __glibcpp_f80_max_exponent10 -#else -// You must define these macros in the configuration file. -#endif - -// FIXME: These are just stubs and inkorrect - -#ifndef __glibcpp_double_has_infinity -#define __glibcpp_double_has_infinity false -#endif - -#ifndef __glibcpp_double_has_quiet_NaN -#define __glibcpp_double_has_quiet_NaN false -#endif - -#ifndef __glibcpp_double_has_signaling_NaN -#define __glibcpp_double_has_signaling_NaN false -#endif - -#ifndef __glibcpp_double_has_denorm -#define __glibcpp_double_has_denorm denorm_absent -#endif +// Default values. Should be overriden in configuration files if necessary. #ifndef __glibcpp_double_has_denorm_loss -#define __glibcpp_double_has_denorm_loss false -#endif - -#ifndef __glibcpp_double_infinity -#define __glibcpp_double_infinity 0.0 -#endif - -#ifndef __glibcpp_double_quiet_NaN -#define __glibcpp_double_quiet_NaN 0.0 -#endif - -#ifndef __glibcpp_double_signaling_NaN -#define __glibcpp_double_signaling_NaN 0.0 -#endif - -#ifndef __glibcpp_double_denorm_min -#define __glibcpp_double_denorm_min 0.0 -#endif - -#ifndef __glibcpp_double_is_iec559 -#define __glibcpp_double_is_iec559 false +# define __glibcpp_double_has_denorm_loss false #endif - -#ifndef __glibcpp_double_is_bounded -#define __glibcpp_double_is_bounded true -#endif - -#ifndef __glibcpp_double_is_modulo -#define __glibcpp_double_is_modulo false -#endif - #ifndef __glibcpp_double_traps -#define __glibcpp_double_traps false +# define __glibcpp_double_traps false #endif - #ifndef __glibcpp_double_tinyness_before -#define __glibcpp_double_tinyness_before false -#endif - -#ifndef __glibcpp_double_round_style -#define __glibcpp_double_round_style round_toward_zero +# define __glibcpp_double_tinyness_before false #endif // long double -#if __glibcpp_long_double_bits == 32 -#define __glibcpp_long_double_min __glibcpp_f32_min -#define __glibcpp_long_double_max __glibcpp_f32_max -#define __glibcpp_long_double_digits __glibcpp_f32_digits -#define __glibcpp_long_double_digits10 __glibcpp_f32_digits10 -#define __glibcpp_long_double_radix __glibcpp_f32_radix -#define __glibcpp_long_double_epsilon __glibcpp_f32_epsilon -#define __glibcpp_long_double_round_error __glibcpp_f32_round_error -#define __glibcpp_long_double_min_exponent __glibcpp_f32_min_exponent -#define __glibcpp_long_double_min_exponent10 __glibcpp_f32_min_exponent10 -#define __glibcpp_long_double_max_exponent __glibcpp_f32_max_exponent -#define __glibcpp_long_double_max_exponent10 __glibcpp_f32_max_exponent10 -#elif __glibcpp_long_double_bits == 64 -#define __glibcpp_long_double_min __glibcpp_f64_min -#define __glibcpp_long_double_max __glibcpp_f64_max -#define __glibcpp_long_double_digits __glibcpp_f64_digits -#define __glibcpp_long_double_digits10 __glibcpp_f64_digits10 -#define __glibcpp_long_double_radix __glibcpp_f64_radix -#define __glibcpp_long_double_epsilon __glibcpp_f64_epsilon -#define __glibcpp_long_double_round_error __glibcpp_f64_round_error -#define __glibcpp_long_double_min_exponent __glibcpp_f64_min_exponent -#define __glibcpp_long_double_min_exponent10 __glibcpp_f64_min_exponent10 -#define __glibcpp_long_double_max_exponent __glibcpp_f64_max_exponent -#define __glibcpp_long_double_max_exponent10 __glibcpp_f64_max_exponent10 -#elif __glibcpp_long_double_bits == 80 -#define __glibcpp_long_double_min __glibcpp_f80_min -#define __glibcpp_long_double_max __glibcpp_f80_max -#define __glibcpp_long_double_digits __glibcpp_f80_digits -#define __glibcpp_long_double_digits10 __glibcpp_f80_digits10 -#define __glibcpp_long_double_radix __glibcpp_f80_radix -#define __glibcpp_long_double_epsilon __glibcpp_f80_epsilon -#define __glibcpp_long_double_round_error __glibcpp_f80_round_error -#define __glibcpp_long_double_min_exponent __glibcpp_f80_min_exponent -#define __glibcpp_long_double_min_exponent10 __glibcpp_f80_min_exponent10 -#define __glibcpp_long_double_max_exponent __glibcpp_f80_max_exponent -#define __glibcpp_long_double_max_exponent10 __glibcpp_f80_max_exponent10 -#elif __glibcpp_long_double_bits == 96 -#define __glibcpp_long_double_min __glibcpp_f96_min -#define __glibcpp_long_double_max __glibcpp_f96_max -#define __glibcpp_long_double_digits __glibcpp_f96_digits -#define __glibcpp_long_double_digits10 __glibcpp_f96_digits10 -#define __glibcpp_long_double_radix __glibcpp_f96_radix -#define __glibcpp_long_double_epsilon __glibcpp_f96_epsilon -#define __glibcpp_long_double_round_error __glibcpp_f96_round_error -#define __glibcpp_long_double_min_exponent __glibcpp_f96_min_exponent -#define __glibcpp_long_double_min_exponent10 __glibcpp_f96_min_exponent10 -#define __glibcpp_long_double_max_exponent __glibcpp_f96_max_exponent -#define __glibcpp_long_double_max_exponent10 __glibcpp_f96_max_exponent10 -#elif __glibcpp_long_double_bits == 128 -#define __glibcpp_long_double_min __glibcpp_f128_min -#define __glibcpp_long_double_max __glibcpp_f128_max -#define __glibcpp_long_double_digits __glibcpp_f128_digits -#define __glibcpp_long_double_digits10 __glibcpp_f128_digits10 -#define __glibcpp_long_double_radix __glibcpp_f128_radix -#define __glibcpp_long_double_epsilon __glibcpp_f128_epsilon -#define __glibcpp_long_double_round_error __glibcpp_f128_round_error -#define __glibcpp_long_double_min_exponent __glibcpp_f128_min_exponent -#define __glibcpp_long_double_min_exponent10 __glibcpp_f128_min_exponent10 -#define __glibcpp_long_double_max_exponent __glibcpp_f128_max_exponent -#define __glibcpp_long_double_max_exponent10 __glibcpp_f128_max_exponent10 -#else -// You must define these macros in the configuration file. -#endif - -// FIXME: These are just stubs and inkorrect - -#ifndef __glibcpp_long_double_has_infinity -#define __glibcpp_long_double_has_infinity false -#endif - -#ifndef __glibcpp_long_double_has_quiet_NaN -#define __glibcpp_long_double_has_quiet_NaN false -#endif - -#ifndef __glibcpp_long_double_has_signaling_NaN -#define __glibcpp_long_double_has_signaling_NaN false -#endif - -#ifndef __glibcpp_long_double_has_denorm -#define __glibcpp_long_double_has_denorm denorm_absent -#endif +// Default values. Should be overriden in configuration files if necessary. #ifndef __glibcpp_long_double_has_denorm_loss -#define __glibcpp_long_double_has_denorm_loss false -#endif - -#ifndef __glibcpp_long_double_infinity -#define __glibcpp_long_double_infinity 0.0L -#endif - -#ifndef __glibcpp_long_double_quiet_NaN -#define __glibcpp_long_double_quiet_NaN 0.0L +# define __glibcpp_long_double_has_denorm_loss false #endif - -#ifndef __glibcpp_long_double_signaling_NaN -#define __glibcpp_long_double_signaling_NaN 0.0L +#ifndef __glibcpp_long_double_traps +# define __glibcpp_long_double_traps false #endif - -#ifndef __glibcpp_long_double_denorm_min -#define __glibcpp_long_double_denorm_min 0.0L +#ifndef __glibcpp_long_double_tinyness_before +# define __glibcpp_long_double_tinyness_before false #endif -#ifndef __glibcpp_long_double_is_iec559 -#define __glibcpp_long_double_is_iec559 false -#endif +// You should not need to define any macros below this point. -#ifndef __glibcpp_long_double_is_bounded -#define __glibcpp_long_double_is_bounded true -#endif +#define __glibcpp_signed(T) ((T)(-1) < 0) -#ifndef __glibcpp_long_double_is_modulo -#define __glibcpp_long_double_is_modulo false -#endif +#define __glibcpp_min(T) \ + (__glibcpp_signed (T) ? (T)1 << __glibcpp_digits (T) : (T)0) -#ifndef __glibcpp_long_double_traps -#define __glibcpp_long_double_traps false -#endif +#define __glibcpp_max(T) \ + (__glibcpp_signed (T) ? ((T)1 << __glibcpp_digits (T)) - 1 : ~(T)0) -#ifndef __glibcpp_long_double_tinyness_before -#define __glibcpp_long_double_tinyness_before false -#endif +#define __glibcpp_digits(T) \ + (sizeof(T) * __CHAR_BIT__ - __glibcpp_signed (T)) -#ifndef __glibcpp_long_double_round_style -#define __glibcpp_long_double_round_style round_toward_zero -#endif +// The fraction 643/2136 approximates log10(2) to 7 significant digits. +#define __glibcpp_digits10(T) \ + (__glibcpp_digits (T) * 643 / 2136) namespace std { - enum float_round_style + enum float_round_style { round_indeterminate = -1, round_toward_zero = 0, @@ -895,7 +158,7 @@ namespace std round_toward_neg_infinity = 3 }; - enum float_denorm_style + enum float_denorm_style { denorm_indeterminate = -1, denorm_absent = 0, @@ -920,7 +183,7 @@ namespace std static const int min_exponent10 = 0; static const int max_exponent = 0; static const int max_exponent10 = 0; - + static const bool has_infinity = false; static const bool has_quiet_NaN = false; static const bool has_signaling_NaN = false; @@ -936,8 +199,8 @@ namespace std static const float_round_style round_style = round_toward_zero; }; - template<typename _Tp> - struct numeric_limits : public __numeric_limits_base + template<typename _Tp> + struct numeric_limits : public __numeric_limits_base { static _Tp min() throw() { return static_cast<_Tp>(0); } static _Tp max() throw() { return static_cast<_Tp>(0); } @@ -950,7 +213,7 @@ namespace std }; // Now there follow 15 explicit specializations. Yes, 15. Make sure - // you get the count right. + // you get the count right. template<> struct numeric_limits<bool> { @@ -958,11 +221,10 @@ namespace std static bool min() throw() { return false; } - static bool max() throw() { return true; } - static const int digits = __glibcpp_bool_digits; + static const int digits = 1; static const int digits10 = 0; static const bool is_signed = false; static const bool is_integer = true; @@ -1000,34 +262,31 @@ namespace std // It is not clear what it means for a boolean type to trap. // This is a DR on the LWG issue list. Here, I use integer // promotion semantics. - static const bool traps = __glibcpp_signed_int_traps - || __glibcpp_signed_long_traps; + static const bool traps = __glibcpp_integral_traps; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; -#undef __glibcpp_bool_digits - template<> struct numeric_limits<char> { static const bool is_specialized = true; static char min() throw() - { return __glibcpp_char_min; } + { return __glibcpp_min(char); } static char max() throw() - { return __glibcpp_char_max; } + { return __glibcpp_max(char); } - static const int digits = __glibcpp_char_digits; - static const int digits10 = __glibcpp_char_digits10; - static const bool is_signed = __glibcpp_plain_char_is_signed; + static const int digits = __glibcpp_digits (char); + static const int digits10 = __glibcpp_digits10 (char); + static const bool is_signed = __glibcpp_signed (char); static const bool is_integer = true; static const bool is_exact = true; static const int radix = 2; static char epsilon() throw() - { return char(); } + { return 0; } static char round_error() throw() - { return char(); } + { return 0; } static const int min_exponent = 0; static const int min_exponent10 = 0; @@ -1051,35 +310,25 @@ namespace std static const bool is_iec559 = false; static const bool is_bounded = true; - static const bool is_modulo = __glibcpp_char_is_modulo; + static const bool is_modulo = true; - static const bool traps = __glibcpp_char_traps; + static const bool traps = __glibcpp_integral_traps; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; -#undef __glibcpp_char_min -#undef __glibcpp_char_max -#undef __glibcpp_char_digits -#undef __glibcpp_char_digits10 -#undef __glibcpp_char_is_signed -#undef __glibcpp_char_is_modulo -#undef __glibcpp_char_traps - - - template<> struct numeric_limits<signed char> { static const bool is_specialized = true; static signed char min() throw() - { return __glibcpp_signed_char_min; } + { return -__SCHAR_MAX__ - 1; } static signed char max() throw() - { return __glibcpp_signed_char_max; } + { return __SCHAR_MAX__; } - static const int digits = __glibcpp_signed_char_digits; - static const int digits10 = __glibcpp_signed_char_digits10; + static const int digits = __glibcpp_digits (signed char); + static const int digits10 = __glibcpp_digits10 (signed char); static const bool is_signed = true; static const bool is_integer = true; static const bool is_exact = true; @@ -1111,20 +360,13 @@ namespace std static const bool is_iec559 = false; static const bool is_bounded = true; - static const bool is_modulo = __glibcpp_signed_char_is_modulo; + static const bool is_modulo = true; - static const bool traps = __glibcpp_signed_char_traps; + static const bool traps = __glibcpp_integral_traps; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; -#undef __glibcpp_signed_char_min -#undef __glibcpp_signed_char_max -#undef __glibcpp_signed_char_digits -#undef __glibcpp_signed_char_digits10 -#undef __glibcpp_signed_char_is_modulo -#undef __glibcpp_signed_char_traps - template<> struct numeric_limits<unsigned char> { @@ -1133,10 +375,10 @@ namespace std static unsigned char min() throw() { return 0; } static unsigned char max() throw() - { return __glibcpp_unsigned_char_max; } + { return __SCHAR_MAX__ * 2U + 1; } - static const int digits = __glibcpp_unsigned_char_digits; - static const int digits10 = __glibcpp_unsigned_char_digits10; + static const int digits = __glibcpp_digits (unsigned char); + static const int digits10 = __glibcpp_digits10 (unsigned char); static const bool is_signed = false; static const bool is_integer = true; static const bool is_exact = true; @@ -1170,29 +412,24 @@ namespace std static const bool is_bounded = true; static const bool is_modulo = true; - static const bool traps = __glibcpp_unsigned_char_traps; + static const bool traps = __glibcpp_integral_traps; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; -#undef __glibcpp_unsigned_char_max -#undef __glibcpp_unsigned_char_digits -#undef __glibcpp_unsigned_char_digits10 -#undef __glibcpp_unsigned_char_traps - template<> struct numeric_limits<wchar_t> { static const bool is_specialized = true; static wchar_t min() throw() - { return __glibcpp_wchar_t_min; } + { return __glibcpp_min (wchar_t); } static wchar_t max() throw() - { return __glibcpp_wchar_t_max; } + { return __glibcpp_max (wchar_t); } - static const int digits = __glibcpp_wchar_t_digits; - static const int digits10 = __glibcpp_wchar_t_digits10; - static const bool is_signed = __glibcpp_wchar_t_is_signed; + static const int digits = __glibcpp_digits (wchar_t); + static const int digits10 = __glibcpp_digits10 (wchar_t); + static const bool is_signed = __glibcpp_signed (wchar_t); static const bool is_integer = true; static const bool is_exact = true; static const int radix = 2; @@ -1223,33 +460,25 @@ namespace std static const bool is_iec559 = false; static const bool is_bounded = true; - static const bool is_modulo = __glibcpp_wchar_t_is_modulo; + static const bool is_modulo = true; - static const bool traps = __glibcpp_wchar_t_traps; + static const bool traps = __glibcpp_integral_traps; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; -#undef __glibcpp_wchar_t_min -#undef __glibcpp_wchar_t_max -#undef __glibcpp_wchar_t_digits -#undef __glibcpp_wchar_t_digits10 -#undef __glibcpp_wchar_t_is_signed -#undef __glibcpp_wchar_t_is_modulo -#undef __glibcpp_wchar_t_traps - template<> struct numeric_limits<short> { static const bool is_specialized = true; static short min() throw() - { return __glibcpp_signed_short_min; } + { return -__SHRT_MAX__ - 1; } static short max() throw() - { return __glibcpp_signed_short_max; } + { return __SHRT_MAX__; } - static const int digits = __glibcpp_signed_short_digits; - static const int digits10 = __glibcpp_signed_short_digits10; + static const int digits = __glibcpp_digits (short); + static const int digits10 = __glibcpp_digits10 (short); static const bool is_signed = true; static const bool is_integer = true; static const bool is_exact = true; @@ -1279,22 +508,15 @@ namespace std static short denorm_min() throw() { return short(); } - static const bool is_iec559 = true; + static const bool is_iec559 = false; static const bool is_bounded = true; - static const bool is_modulo = __glibcpp_signed_short_is_modulo; + static const bool is_modulo = true; - static const bool traps = __glibcpp_signed_short_traps; + static const bool traps = __glibcpp_integral_traps; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; -#undef __glibcpp_signed_short_min -#undef __glibcpp_signed_short_max -#undef __glibcpp_signed_short_digits -#undef __glibcpp_signed_short_digits10 -#undef __glibcpp_signed_short_is_modulo -#undef __glibcpp_signed_short_traps - template<> struct numeric_limits<unsigned short> { @@ -1303,10 +525,10 @@ namespace std static unsigned short min() throw() { return 0; } static unsigned short max() throw() - { return __glibcpp_unsigned_short_max; } + { return __SHRT_MAX__ * 2U + 1; } - static const int digits = __glibcpp_unsigned_short_digits; - static const int digits10 = __glibcpp_unsigned_short_digits10; + static const int digits = __glibcpp_digits (unsigned short); + static const int digits10 = __glibcpp_digits10 (unsigned short); static const bool is_signed = false; static const bool is_integer = true; static const bool is_exact = true; @@ -1336,32 +558,27 @@ namespace std static unsigned short denorm_min() throw() { return static_cast<unsigned short>(0); } - static const bool is_iec559 = true; + static const bool is_iec559 = false; static const bool is_bounded = true; static const bool is_modulo = true; - static const bool traps = __glibcpp_unsigned_short_traps; + static const bool traps = __glibcpp_integral_traps; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; -#undef __glibcpp_unsigned_short_max -#undef __glibcpp_unsigned_short_digits -#undef __glibcpp_unsigned_short_digits10 -#undef __glibcpp_unsigned_short_traps - template<> struct numeric_limits<int> { static const bool is_specialized = true; static int min() throw() - { return __glibcpp_signed_int_min; } + { return -__INT_MAX__ - 1; } static int max() throw() - { return __glibcpp_signed_int_max; } + { return __INT_MAX__; } - static const int digits = __glibcpp_signed_int_digits; - static const int digits10 = __glibcpp_signed_int_digits10; + static const int digits = __glibcpp_digits (int); + static const int digits10 = __glibcpp_digits10 (int); static const bool is_signed = true; static const bool is_integer = true; static const bool is_exact = true; @@ -1391,22 +608,15 @@ namespace std static int denorm_min() throw() { return static_cast<int>(0); } - static const bool is_iec559 = true; + static const bool is_iec559 = false; static const bool is_bounded = true; - static const bool is_modulo = __glibcpp_signed_int_is_modulo; + static const bool is_modulo = true; - static const bool traps = __glibcpp_signed_int_traps; + static const bool traps = __glibcpp_integral_traps; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; -#undef __glibcpp_signed_int_min -#undef __glibcpp_signed_int_max -#undef __glibcpp_signed_int_digits -#undef __glibcpp_signed_int_digits10 -#undef __glibcpp_signed_int_is_modulo -#undef __glibcpp_signed_int_traps - template<> struct numeric_limits<unsigned int> { @@ -1414,11 +624,11 @@ namespace std static unsigned int min() throw() { return 0; } - static unsigned int max() throw() - { return __glibcpp_unsigned_int_max; } + static unsigned int max() throw() + { return __INT_MAX__ * 2U + 1; } - static const int digits = __glibcpp_unsigned_int_digits; - static const int digits10 = __glibcpp_unsigned_int_digits10; + static const int digits = __glibcpp_digits (unsigned int); + static const int digits10 = __glibcpp_digits10 (unsigned int); static const bool is_signed = false; static const bool is_integer = true; static const bool is_exact = true; @@ -1448,32 +658,27 @@ namespace std static unsigned int denorm_min() throw() { return static_cast<unsigned int>(0); } - static const bool is_iec559 = true; + static const bool is_iec559 = false; static const bool is_bounded = true; static const bool is_modulo = true; - static const bool traps = __glibcpp_unsigned_int_traps; + static const bool traps = __glibcpp_integral_traps; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; -#undef __glibcpp_unsigned_int_max -#undef __glibcpp_unsigned_int_digits -#undef __glibcpp_unsigned_int_digits10 -#undef __glibcpp_unsigned_int_traps - template<> struct numeric_limits<long> { static const bool is_specialized = true; static long min() throw() - { return __glibcpp_signed_long_min; } + { return -__LONG_MAX__ - 1; } static long max() throw() - { return __glibcpp_signed_long_max; } + { return __LONG_MAX__; } - static const int digits = __glibcpp_signed_long_digits; - static const int digits10 = __glibcpp_signed_long_digits10; + static const int digits = __glibcpp_digits (long); + static const int digits10 = __glibcpp_digits10 (long); static const bool is_signed = true; static const bool is_integer = true; static const bool is_exact = true; @@ -1503,22 +708,15 @@ namespace std static long denorm_min() throw() { return static_cast<long>(0); } - static const bool is_iec559 = true; + static const bool is_iec559 = false; static const bool is_bounded = true; - static const bool is_modulo = __glibcpp_signed_long_is_modulo; + static const bool is_modulo = true; - static const bool traps = __glibcpp_signed_long_traps; + static const bool traps = __glibcpp_integral_traps; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; -#undef __glibcpp_signed_long_min -#undef __glibcpp_signed_long_max -#undef __glibcpp_signed_long_digits -#undef __glibcpp_signed_long_digits10 -#undef __glibcpp_signed_long_is_modulo -#undef __glibcpp_signed_long_traps - template<> struct numeric_limits<unsigned long> { @@ -1527,10 +725,10 @@ namespace std static unsigned long min() throw() { return 0; } static unsigned long max() throw() - { return __glibcpp_unsigned_long_max; } + { return __LONG_MAX__ * 2UL + 1; } - static const int digits = __glibcpp_unsigned_long_digits; - static const int digits10 = __glibcpp_unsigned_long_digits10; + static const int digits = __glibcpp_digits (unsigned long); + static const int digits10 = __glibcpp_digits10 (unsigned long); static const bool is_signed = false; static const bool is_integer = true; static const bool is_exact = true; @@ -1560,32 +758,27 @@ namespace std static unsigned long denorm_min() throw() { return static_cast<unsigned long>(0); } - static const bool is_iec559 = true; + static const bool is_iec559 = false; static const bool is_bounded = true; static const bool is_modulo = true; - static const bool traps = __glibcpp_unsigned_long_traps; + static const bool traps = __glibcpp_integral_traps; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; -#undef __glibcpp_unsigned_long_max -#undef __glibcpp_unsigned_long_digits -#undef __glibcpp_unsigned_long_digits10 -#undef __glibcpp_unsigned_long_traps - template<> struct numeric_limits<long long> { static const bool is_specialized = true; - + static long long min() throw() - { return __glibcpp_signed_long_long_min; } + { return -__LONG_LONG_MAX__ - 1; } static long long max() throw() - { return __glibcpp_signed_long_long_max; } - - static const int digits = __glibcpp_signed_long_long_digits; - static const int digits10 = __glibcpp_signed_long_long_digits10; + { return __LONG_LONG_MAX__; } + + static const int digits = __glibcpp_digits (long long); + static const int digits10 = __glibcpp_digits10 (long long); static const bool is_signed = true; static const bool is_integer = true; static const bool is_exact = true; @@ -1594,18 +787,18 @@ namespace std { return 0; } static long long round_error() throw() { return 0; } - + static const int min_exponent = 0; static const int min_exponent10 = 0; static const int max_exponent = 0; static const int max_exponent10 = 0; - + static const bool has_infinity = false; static const bool has_quiet_NaN = false; static const bool has_signaling_NaN = false; static const float_denorm_style has_denorm = denorm_absent; static const bool has_denorm_loss = false; - + static long long infinity() throw() { return static_cast<long long>(0); } static long long quiet_NaN() throw() @@ -1614,23 +807,16 @@ namespace std { return static_cast<long long>(0); } static long long denorm_min() throw() { return static_cast<long long>(0); } - - static const bool is_iec559 = true; + + static const bool is_iec559 = false; static const bool is_bounded = true; - static const bool is_modulo = __glibcpp_signed_long_long_is_modulo; + static const bool is_modulo = true; - static const bool traps = __glibcpp_signed_long_long_traps; + static const bool traps = __glibcpp_integral_traps; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; -#undef __glibcpp_signed_long_long_min -#undef __glibcpp_signed_long_long_max -#undef __glibcpp_signed_long_long_digits -#undef __glibcpp_signed_long_long_digits10 -#undef __glibcpp_signed_long_long_is_modulo -#undef __glibcpp_signed_long_long_traps - template<> struct numeric_limits<unsigned long long> { @@ -1639,10 +825,10 @@ namespace std static unsigned long long min() throw() { return 0; } static unsigned long long max() throw() - { return __glibcpp_unsigned_long_long_max; } + { return __LONG_LONG_MAX__ * 2ULL + 1; } - static const int digits = __glibcpp_unsigned_long_long_digits; - static const int digits10 = __glibcpp_unsigned_long_long_digits10; + static const int digits = __glibcpp_digits (unsigned long long); + static const int digits10 = __glibcpp_digits10 (unsigned long long); static const bool is_signed = false; static const bool is_integer = true; static const bool is_exact = true; @@ -1672,95 +858,72 @@ namespace std static unsigned long long denorm_min() throw() { return static_cast<unsigned long long>(0); } - static const bool is_iec559 = true; + static const bool is_iec559 = false; static const bool is_bounded = true; static const bool is_modulo = true; - static const bool traps = true; + static const bool traps = __glibcpp_integral_traps; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; -#undef __glibcpp_unsigned_long_long_max -#undef __glibcpp_unsigned_long_long_digits -#undef __glibcpp_unsigned_long_long_digits10 -#undef __glibcpp_unsigned_long_long_traps - template<> struct numeric_limits<float> { static const bool is_specialized = true; static float min() throw() - { return __glibcpp_float_min; } + { return __FLT_MIN__; } static float max() throw() - { return __glibcpp_float_max; } + { return __FLT_MAX__; } - static const int digits = __glibcpp_float_digits; - static const int digits10 = __glibcpp_float_digits10; + static const int digits = __FLT_MANT_DIG__; + static const int digits10 = __FLT_DIG__; static const bool is_signed = true; static const bool is_integer = false; static const bool is_exact = false; - static const int radix = __glibcpp_float_radix; + static const int radix = __FLT_RADIX__; static float epsilon() throw() - { return __glibcpp_float_epsilon; } + { return __FLT_EPSILON__; } static float round_error() throw() - { return __glibcpp_float_round_error; } + { return 0.5F; } - static const int min_exponent = __glibcpp_float_min_exponent; - static const int min_exponent10 = __glibcpp_float_min_exponent10; - static const int max_exponent = __glibcpp_float_max_exponent; - static const int max_exponent10 = __glibcpp_float_max_exponent10; + static const int min_exponent = __FLT_MIN_EXP__; + static const int min_exponent10 = __FLT_MIN_10_EXP__; + static const int max_exponent = __FLT_MAX_EXP__; + static const int max_exponent10 = __FLT_MAX_10_EXP__; - static const bool has_infinity = __glibcpp_float_has_infinity; - static const bool has_quiet_NaN = __glibcpp_float_has_quiet_NaN; - static const bool has_signaling_NaN = __glibcpp_float_has_signaling_NaN; - static const float_denorm_style has_denorm = __glibcpp_float_has_denorm; + static const bool has_infinity + = __builtin_huge_valf () / 2 == __builtin_huge_valf (); + static const bool has_quiet_NaN + = __builtin_nanf ("") != __builtin_nanf (""); + static const bool has_signaling_NaN = has_quiet_NaN; + static const float_denorm_style has_denorm + = __FLT_DENORM_MIN__ ? denorm_present : denorm_absent; static const bool has_denorm_loss = __glibcpp_float_has_denorm_loss; static float infinity() throw() - { return __glibcpp_float_infinity; } + { return __builtin_huge_valf (); } static float quiet_NaN() throw() - { return __glibcpp_float_quiet_NaN; } + { return __builtin_nanf (""); } static float signaling_NaN() throw() - { return __glibcpp_float_signaling_NaN; } + { return __builtin_nansf (""); } static float denorm_min() throw() - { return __glibcpp_float_denorm_min; } + { return __FLT_DENORM_MIN__; } - static const bool is_iec559 = __glibcpp_float_is_iec559; - static const bool is_bounded = __glibcpp_float_is_bounded; - static const bool is_modulo = __glibcpp_float_is_modulo; + static const bool is_iec559 + = has_infinity && has_quiet_NaN && has_denorm == denorm_present; + static const bool is_bounded = true; + static const bool is_modulo = false; static const bool traps = __glibcpp_float_traps; static const bool tinyness_before = __glibcpp_float_tinyness_before; - static const float_round_style round_style = __glibcpp_float_round_style; + static const float_round_style round_style = round_to_nearest; }; -#undef __glibcpp_float_min -#undef __glibcpp_float_max -#undef __glibcpp_float_digits -#undef __glibcpp_float_digits10 -#undef __glibcpp_float_radix -#undef __glibcpp_float_round_error -#undef __glibcpp_float_min_exponent -#undef __glibcpp_float_min_exponent10 -#undef __glibcpp_float_max_exponent -#undef __glibcpp_float_max_exponent10 -#undef __glibcpp_float_has_infinity -#undef __glibcpp_float_has_quiet_NaN -#undef __glibcpp_float_has_signaling_NaN -#undef __glibcpp_float_has_denorm #undef __glibcpp_float_has_denorm_loss -#undef __glibcpp_float_infinity -#undef __glibcpp_float_quiet_NaN -#undef __glibcpp_float_signaling_NaN -#undef __glibcpp_float_denorm_min -#undef __glibcpp_float_is_iec559 -#undef __glibcpp_float_is_bounded -#undef __glibcpp_float_is_modulo #undef __glibcpp_float_traps #undef __glibcpp_float_tinyness_before -#undef __glibcpp_float_round_style template<> struct numeric_limits<double> @@ -1768,159 +931,123 @@ namespace std static const bool is_specialized = true; static double min() throw() - { return __glibcpp_double_min; } + { return __DBL_MIN__; } static double max() throw() - { return __glibcpp_double_max; } + { return __DBL_MAX__; } - static const int digits = __glibcpp_double_digits; - static const int digits10 = __glibcpp_double_digits10; + static const int digits = __DBL_MANT_DIG__; + static const int digits10 = __DBL_DIG__; static const bool is_signed = true; static const bool is_integer = false; static const bool is_exact = false; - static const int radix = __glibcpp_double_radix; + static const int radix = __FLT_RADIX__; static double epsilon() throw() - { return __glibcpp_double_epsilon; } + { return __DBL_EPSILON__; } static double round_error() throw() - { return __glibcpp_double_round_error; } + { return 0.5; } - static const int min_exponent = __glibcpp_double_min_exponent; - static const int min_exponent10 = __glibcpp_double_min_exponent10; - static const int max_exponent = __glibcpp_double_max_exponent; - static const int max_exponent10 = __glibcpp_double_max_exponent10; + static const int min_exponent = __DBL_MIN_EXP__; + static const int min_exponent10 = __DBL_MIN_10_EXP__; + static const int max_exponent = __DBL_MAX_EXP__; + static const int max_exponent10 = __DBL_MAX_10_EXP__; - static const bool has_infinity = __glibcpp_double_has_infinity; - static const bool has_quiet_NaN = __glibcpp_double_has_quiet_NaN; - static const bool has_signaling_NaN = __glibcpp_double_has_signaling_NaN; - static const float_denorm_style has_denorm = - __glibcpp_double_has_denorm; + static const bool has_infinity + = __builtin_huge_val () / 2 == __builtin_huge_val (); + static const bool has_quiet_NaN + = __builtin_nan ("") != __builtin_nan (""); + static const bool has_signaling_NaN = has_quiet_NaN; + static const float_denorm_style has_denorm + = __DBL_DENORM_MIN__ ? denorm_present : denorm_absent; static const bool has_denorm_loss = __glibcpp_double_has_denorm_loss; static double infinity() throw() - { return __glibcpp_double_infinity; } + { return __builtin_huge_val(); } static double quiet_NaN() throw() - { return __glibcpp_double_quiet_NaN; } + { return __builtin_nan (""); } static double signaling_NaN() throw() - { return __glibcpp_double_signaling_NaN; } + { return __builtin_nans (""); } static double denorm_min() throw() - { return __glibcpp_double_denorm_min; } + { return __DBL_DENORM_MIN__; } - static const bool is_iec559 = __glibcpp_double_is_iec559; - static const bool is_bounded = __glibcpp_double_is_bounded; - static const bool is_modulo = __glibcpp_double_is_modulo; + static const bool is_iec559 + = has_infinity && has_quiet_NaN && has_denorm == denorm_present; + static const bool is_bounded = true; + static const bool is_modulo = false; static const bool traps = __glibcpp_double_traps; static const bool tinyness_before = __glibcpp_double_tinyness_before; - static const float_round_style round_style = - __glibcpp_double_round_style; + static const float_round_style round_style = round_to_nearest; }; -#undef __glibcpp_double_min -#undef __glibcpp_double_max -#undef __glibcpp_double_digits -#undef __glibcpp_double_digits10 -#undef __glibcpp_double_radix -#undef __glibcpp_double_round_error -#undef __glibcpp_double_min_exponent -#undef __glibcpp_double_min_exponent10 -#undef __glibcpp_double_max_exponent -#undef __glibcpp_double_max_exponent10 -#undef __glibcpp_double_has_infinity -#undef __glibcpp_double_has_quiet_NaN -#undef __glibcpp_double_has_signaling_NaN -#undef __glibcpp_double_has_denorm #undef __glibcpp_double_has_denorm_loss -#undef __glibcpp_double_infinity -#undef __glibcpp_double_quiet_NaN -#undef __glibcpp_double_signaling_NaN -#undef __glibcpp_double_denorm_min -#undef __glibcpp_double_is_iec559 -#undef __glibcpp_double_is_bounded -#undef __glibcpp_double_is_modulo #undef __glibcpp_double_traps #undef __glibcpp_double_tinyness_before -#undef __glibcpp_double_round_style - - + template<> struct numeric_limits<long double> { static const bool is_specialized = true; static long double min() throw() - { return __glibcpp_long_double_min; } + { return __LDBL_MIN__; } static long double max() throw() - { return __glibcpp_long_double_max; } + { return __LDBL_MAX__; } - static const int digits = __glibcpp_long_double_digits; - static const int digits10 = __glibcpp_long_double_digits10; + static const int digits = __LDBL_MANT_DIG__; + static const int digits10 = __LDBL_DIG__; static const bool is_signed = true; static const bool is_integer = false; static const bool is_exact = false; - static const int radix = __glibcpp_long_double_radix; + static const int radix = __FLT_RADIX__; static long double epsilon() throw() - { return __glibcpp_long_double_epsilon; } + { return __LDBL_EPSILON__; } static long double round_error() throw() - { return __glibcpp_long_double_round_error; } + { return 0.5L; } - static const int min_exponent = __glibcpp_long_double_min_exponent; - static const int min_exponent10 = __glibcpp_long_double_min_exponent10; - static const int max_exponent = __glibcpp_long_double_max_exponent; - static const int max_exponent10 = __glibcpp_long_double_max_exponent10; + static const int min_exponent = __LDBL_MIN_EXP__; + static const int min_exponent10 = __LDBL_MIN_10_EXP__; + static const int max_exponent = __LDBL_MAX_EXP__; + static const int max_exponent10 = __LDBL_MAX_10_EXP__; - static const bool has_infinity = __glibcpp_long_double_has_infinity; - static const bool has_quiet_NaN = __glibcpp_long_double_has_quiet_NaN; - static const bool has_signaling_NaN = - __glibcpp_long_double_has_signaling_NaN; - static const float_denorm_style has_denorm = - __glibcpp_long_double_has_denorm; - static const bool has_denorm_loss = - __glibcpp_long_double_has_denorm_loss; + static const bool has_infinity + = __builtin_huge_vall () / 2 == __builtin_huge_vall (); + static const bool has_quiet_NaN + = __builtin_nanl ("") != __builtin_nanl (""); + static const bool has_signaling_NaN = has_quiet_NaN; + static const float_denorm_style has_denorm + = __LDBL_DENORM_MIN__ ? denorm_present : denorm_absent; + static const bool has_denorm_loss + = __glibcpp_long_double_has_denorm_loss; static long double infinity() throw() - { return __glibcpp_long_double_infinity; } + { return __builtin_huge_vall (); } static long double quiet_NaN() throw() - { return __glibcpp_long_double_quiet_NaN; } + { return __builtin_nanl (""); } static long double signaling_NaN() throw() - { return __glibcpp_long_double_signaling_NaN; } + { return __builtin_nansl (""); } static long double denorm_min() throw() - { return __glibcpp_long_double_denorm_min; } + { return __LDBL_DENORM_MIN__; } - static const bool is_iec559 = __glibcpp_long_double_is_iec559; - static const bool is_bounded = __glibcpp_long_double_is_bounded; - static const bool is_modulo = __glibcpp_long_double_is_modulo; + static const bool is_iec559 + = has_infinity && has_quiet_NaN && has_denorm == denorm_present; + static const bool is_bounded = true; + static const bool is_modulo = false; - static const bool traps = __glibcpp_long_double_traps; + static const bool traps = __glibcpp_long_double_traps; static const bool tinyness_before = __glibcpp_long_double_tinyness_before; - static const float_round_style round_style = - __glibcpp_long_double_round_style; + static const float_round_style round_style = round_to_nearest; }; -#undef __glibcpp_long_double_min -#undef __glibcpp_long_double_max -#undef __glibcpp_long_double_digits -#undef __glibcpp_long_double_digits10 -#undef __glibcpp_long_double_radix -#undef __glibcpp_long_double_round_error -#undef __glibcpp_long_double_min_exponent -#undef __glibcpp_long_double_min_exponent10 -#undef __glibcpp_long_double_max_exponent -#undef __glibcpp_long_double_max_exponent10 -#undef __glibcpp_long_double_has_infinity -#undef __glibcpp_long_double_has_quiet_NaN -#undef __glibcpp_long_double_has_signaling_NaN -#undef __glibcpp_long_double_has_denorm #undef __glibcpp_long_double_has_denorm_loss -#undef __glibcpp_long_double_infinity -#undef __glibcpp_long_double_quiet_NaN -#undef __glibcpp_long_double_signaling_NaN -#undef __glibcpp_long_double_denorm_min -#undef __glibcpp_long_double_is_iec559 -#undef __glibcpp_long_double_is_bounded -#undef __glibcpp_long_double_is_modulo #undef __glibcpp_long_double_traps #undef __glibcpp_long_double_tinyness_before -#undef __glibcpp_long_double_round_style - + } // namespace std +#undef __glibcpp_signed +#undef __glibcpp_min +#undef __glibcpp_max +#undef __glibcpp_digits +#undef __glibcpp_digits10 + #endif // _CPP_NUMERIC_LIMITS diff --git a/contrib/libstdc++/include/std/std_list.h b/contrib/libstdc++/include/std/std_list.h index f32553be1f44..84523ad8e4fa 100644 --- a/contrib/libstdc++/include/std/std_list.h +++ b/contrib/libstdc++/include/std/std_list.h @@ -70,8 +70,9 @@ #include <bits/stl_uninitialized.h> #include <bits/stl_list.h> +#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT +# include <bits/list.tcc> +#endif + #endif /* _CPP_LIST */ -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/std/std_locale.h b/contrib/libstdc++/include/std/std_locale.h index 9c46b96bc2f1..29602560766c 100644 --- a/contrib/libstdc++/include/std/std_locale.h +++ b/contrib/libstdc++/include/std/std_locale.h @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2002 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2002, 2003 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -42,11 +42,8 @@ #pragma GCC system_header #include <bits/localefwd.h> +#include <bits/locale_classes.h> #include <bits/locale_facets.h> #include <bits/locale_facets.tcc> #endif - -// Local Variables: -// mode:c++ -// End: diff --git a/contrib/libstdc++/include/std/std_memory.h b/contrib/libstdc++/include/std/std_memory.h index 5850eb2a0075..47c3ede8995d 100644 --- a/contrib/libstdc++/include/std/std_memory.h +++ b/contrib/libstdc++/include/std/std_memory.h @@ -58,314 +58,301 @@ #include <bits/stl_uninitialized.h> #include <bits/stl_raw_storage_iter.h> -// Since this entire file is within namespace std, there's no reason to -// waste two spaces along the left column. Thus the leading indentation is -// slightly violated from here on. namespace std { -/** - * @if maint - * This is a helper function. The unused second parameter exists to - * permit the real get_temporary_buffer to use template parameter deduction. - * - * XXX This should perhaps use the pool. - * @endif -*/ -template <typename _Tp> -pair<_Tp*, ptrdiff_t> -__get_temporary_buffer(ptrdiff_t __len, _Tp*) -{ - if (__len > ptrdiff_t(INT_MAX / sizeof(_Tp))) - __len = INT_MAX / sizeof(_Tp); - - while (__len > 0) { - _Tp* __tmp = (_Tp*) std::malloc((std::size_t)__len * sizeof(_Tp)); - if (__tmp != 0) - return pair<_Tp*, ptrdiff_t>(__tmp, __len); - __len /= 2; - } - - return pair<_Tp*, ptrdiff_t>((_Tp*)0, 0); -} - -/** - * @brief This is a mostly-useless wrapper around malloc(). - * @param len The number of objects of type Tp. - * @return See full description. - * - * Reinventing the wheel, but this time with prettier spokes! - * - * This function tries to obtain storage for @c len adjacent Tp objects. - * The objects themselves are not constructed, of course. A pair<> is - * returned containing "the buffer s address and capacity (in the units of - * sizeof(Tp)), or a pair of 0 values if no storage can be obtained." - * Note that the capacity obtained may be less than that requested if the - * memory is unavailable; you should compare len with the .second return - * value. -*/ -template<typename _Tp> - inline pair<_Tp*,ptrdiff_t> - get_temporary_buffer(ptrdiff_t __len) - { - return __get_temporary_buffer(__len, (_Tp*) 0); - } - -/** - * @brief The companion to get_temporary_buffer(). - * @param p A buffer previously allocated by get_temporary_buffer. - * @return None. - * - * Frees the memory pointed to by p. - */ -template<typename _Tp> - void - return_temporary_buffer(_Tp* __p) - { - std::free(__p); - } - - -/** - * A wrapper class to provide auto_ptr with reference semantics. For - * example, an auto_ptr can be assigned (or constructed from) the result of - * a function which returns an auto_ptr by value. - * - * All the auto_ptr_ref stuff should happen behind the scenes. -*/ -template<typename _Tp1> - struct auto_ptr_ref -{ - _Tp1* _M_ptr; - - explicit - auto_ptr_ref(_Tp1* __p) - : _M_ptr(__p) {} -}; - - -/** - * @brief A simple smart pointer providing strict ownership semantics. - * - * The Standard says: - * <pre> - * An @c auto_ptr owns the object it holds a pointer to. Copying an - * @c auto_ptr copies the pointer and transfers ownership to the destination. - * If more than one @c auto_ptr owns the same object at the same time the - * behavior of the program is undefined. - * - * The uses of @c auto_ptr include providing temporary exception-safety for - * dynamically allocated memory, passing ownership of dynamically allocated - * memory to a function, and returning dynamically allocated memory from a - * function. @c auto_ptr does not meet the CopyConstructible and Assignable - * requirements for Standard Library <a href="tables.html#65">container</a> - * elements and thus instantiating a Standard Library container with an - * @c auto_ptr results in undefined behavior. - * </pre> - * Quoted from [20.4.5]/3. - * - * Good examples of what can and cannot be done with auto_ptr can be found - * in the libstdc++ testsuite. - * - * @if maint - * _GLIBCPP_RESOLVE_LIB_DEFECTS - * 127. auto_ptr<> conversion issues - * These resolutions have all been incorporated. - * @endif -*/ -template<typename _Tp> - class auto_ptr -{ -private: - _Tp* _M_ptr; - -public: - /// The pointed-to type. - typedef _Tp element_type; - - /** - * @brief An %auto_ptr is usually constructed from a raw pointer. - * @param p A pointer (defaults to NULL). - * - * This object now @e owns the object pointed to by @a p. - */ - explicit - auto_ptr(element_type* __p = 0) throw() - : _M_ptr(__p) { } - - /** - * @brief An %auto_ptr can be constructed from another %auto_ptr. - * @param a Another %auto_ptr of the same type. - * - * This object now @e owns the object previously owned by @a a, which has - * given up ownsership. - */ - auto_ptr(auto_ptr& __a) throw() - : _M_ptr(__a.release()) { } - /** - * @brief An %auto_ptr can be constructed from another %auto_ptr. - * @param a Another %auto_ptr of a different but related type. - * - * A pointer-to-Tp1 must be convertible to a pointer-to-Tp/element_type. - * - * This object now @e owns the object previously owned by @a a, which has - * given up ownsership. - */ - template<typename _Tp1> - auto_ptr(auto_ptr<_Tp1>& __a) throw() - : _M_ptr(__a.release()) { } - - /** - * @brief %auto_ptr assignment operator. - * @param a Another %auto_ptr of the same type. + * @if maint + * This is a helper function. The unused second parameter exists to + * permit the real get_temporary_buffer to use template parameter deduction. * - * This object now @e owns the object previously owned by @a a, which has - * given up ownsership. The object that this one @e used to own and - * track has been deleted. - */ - auto_ptr& - operator=(auto_ptr& __a) throw() + * XXX This should perhaps use the pool. + * @endif + */ + template<typename _Tp> + pair<_Tp*, ptrdiff_t> + __get_temporary_buffer(ptrdiff_t __len, _Tp*) { - reset(__a.release()); - return *this; + if (__len > ptrdiff_t(INT_MAX / sizeof(_Tp))) + __len = INT_MAX / sizeof(_Tp); + + while (__len > 0) + { + _Tp* __tmp = (_Tp*) std::malloc((std::size_t)__len * sizeof(_Tp)); + if (__tmp != 0) + return pair<_Tp*, ptrdiff_t>(__tmp, __len); + __len /= 2; + } + return pair<_Tp*, ptrdiff_t>((_Tp*)0, 0); } /** - * @brief %auto_ptr assignment operator. - * @param a Another %auto_ptr of a different but related type. + * @brief This is a mostly-useless wrapper around malloc(). + * @param len The number of objects of type Tp. + * @return See full description. * - * A pointer-to-Tp1 must be convertible to a pointer-to-Tp/element_type. + * Reinventing the wheel, but this time with prettier spokes! * - * This object now @e owns the object previously owned by @a a, which has - * given up ownsership. The object that this one @e used to own and - * track has been deleted. - */ - template <typename _Tp1> - auto_ptr& - operator=(auto_ptr<_Tp1>& __a) throw() - { - reset(__a.release()); - return *this; - } + * This function tries to obtain storage for @c len adjacent Tp objects. + * The objects themselves are not constructed, of course. A pair<> is + * returned containing "the buffer s address and capacity (in the units of + * sizeof(Tp)), or a pair of 0 values if no storage can be obtained." + * Note that the capacity obtained may be less than that requested if the + * memory is unavailable; you should compare len with the .second return + * value. + */ + template<typename _Tp> + inline pair<_Tp*,ptrdiff_t> + get_temporary_buffer(ptrdiff_t __len) + { return __get_temporary_buffer(__len, (_Tp*) 0); } /** - * When the %auto_ptr goes out of scope, the object it owns is deleted. - * If it no longer owns anything (i.e., @c get() is @c NULL), then this - * has no effect. + * @brief The companion to get_temporary_buffer(). + * @param p A buffer previously allocated by get_temporary_buffer. + * @return None. * - * @if maint - * The C++ standard says there is supposed to be an empty throw - * specification here, but omitting it is standard conforming. Its - * presence can be detected only if _Tp::~_Tp() throws, but this is - * prohibited. [17.4.3.6]/2 - * @end maint - */ - ~auto_ptr() { delete _M_ptr; } + * Frees the memory pointed to by p. + */ + template<typename _Tp> + void + return_temporary_buffer(_Tp* __p) + { std::free(__p); } /** - * @brief Smart pointer dereferencing. + * A wrapper class to provide auto_ptr with reference semantics. For + * example, an auto_ptr can be assigned (or constructed from) the result of + * a function which returns an auto_ptr by value. * - * If this %auto_ptr no longer owns anything, then this operation will - * crash. (For a smart pointer, "no longer owns anything" is the same as - * being a null pointer, and you know what happens when you dereference - * one of those...) - */ - element_type& - operator*() const throw() { return *_M_ptr; } + * All the auto_ptr_ref stuff should happen behind the scenes. + */ + template<typename _Tp1> + struct auto_ptr_ref + { + _Tp1* _M_ptr; + + explicit + auto_ptr_ref(_Tp1* __p): _M_ptr(__p) { } + }; - /** - * @brief Smart pointer dereferencing. - * - * This returns the pointer itself, which the language then will - * automatically cause to be dereferenced. - */ - element_type* - operator->() const throw() { return _M_ptr; } /** - * @brief Bypassing the smart pointer. - * @return The raw pointer being managed. + * @brief A simple smart pointer providing strict ownership semantics. * - * You can get a copy of the pointer that this object owns, for - * situations such as passing to a function which only accepts a raw - * pointer. + * The Standard says: + * <pre> + * An @c auto_ptr owns the object it holds a pointer to. Copying an + * @c auto_ptr copies the pointer and transfers ownership to the destination. + * If more than one @c auto_ptr owns the same object at the same time the + * behavior of the program is undefined. * - * @note This %auto_ptr still owns the memory. - */ - element_type* - get() const throw() { return _M_ptr; } - - /** - * @brief Bypassing the smart pointer. - * @return The raw pointer being managed. + * The uses of @c auto_ptr include providing temporary exception-safety for + * dynamically allocated memory, passing ownership of dynamically allocated + * memory to a function, and returning dynamically allocated memory from a + * function. @c auto_ptr does not meet the CopyConstructible and Assignable + * requirements for Standard Library <a href="tables.html#65">container</a> + * elements and thus instantiating a Standard Library container with an + * @c auto_ptr results in undefined behavior. + * </pre> + * Quoted from [20.4.5]/3. * - * You can get a copy of the pointer that this object owns, for - * situations such as passing to a function which only accepts a raw - * pointer. + * Good examples of what can and cannot be done with auto_ptr can be found + * in the libstdc++ testsuite. * - * @note This %auto_ptr no longer owns the memory. When this object - * goes out of scope, nothing will happen. - */ - element_type* - release() throw() + * @if maint + * _GLIBCPP_RESOLVE_LIB_DEFECTS + * 127. auto_ptr<> conversion issues + * These resolutions have all been incorporated. + * @endif + */ + template<typename _Tp> + class auto_ptr { - element_type* __tmp = _M_ptr; - _M_ptr = 0; - return __tmp; - } + private: + _Tp* _M_ptr; + + public: + /// The pointed-to type. + typedef _Tp element_type; + + /** + * @brief An %auto_ptr is usually constructed from a raw pointer. + * @param p A pointer (defaults to NULL). + * + * This object now @e owns the object pointed to by @a p. + */ + explicit + auto_ptr(element_type* __p = 0) throw() : _M_ptr(__p) { } - /** - * @brief Forcibly deletes the managed object. - * @param p A pointer (defaults to NULL). - * - * This object now @e owns the object pointed to by @a p. The previous - * object has been deleted. - */ - void - reset(element_type* __p = 0) throw() - { - if (__p != _M_ptr) - { - delete _M_ptr; - _M_ptr = __p; - } - } + /** + * @brief An %auto_ptr can be constructed from another %auto_ptr. + * @param a Another %auto_ptr of the same type. + * + * This object now @e owns the object previously owned by @a a, + * which has given up ownsership. + */ + auto_ptr(auto_ptr& __a) throw() : _M_ptr(__a.release()) { } - /** @{ - * @brief Automatic conversions - * - * These operations convert an %auto_ptr into and from an auto_ptr_ref - * automatically as needed. This allows constructs such as - * @code - * auto_ptr<Derived> func_returning_auto_ptr(.....); - * ... - * auto_ptr<Base> ptr = func_returning_auto_ptr(.....); - * @endcode - */ - auto_ptr(auto_ptr_ref<element_type> __ref) throw() - : _M_ptr(__ref._M_ptr) {} + /** + * @brief An %auto_ptr can be constructed from another %auto_ptr. + * @param a Another %auto_ptr of a different but related type. + * + * A pointer-to-Tp1 must be convertible to a pointer-to-Tp/element_type. + * + * This object now @e owns the object previously owned by @a a, + * which has given up ownsership. + */ + template<typename _Tp1> + auto_ptr(auto_ptr<_Tp1>& __a) throw() : _M_ptr(__a.release()) { } - auto_ptr& - operator=(auto_ptr_ref<element_type> __ref) throw() - { - if (__ref._M_ptr != this->get()) - { - delete _M_ptr; - _M_ptr = __ref._M_ptr; - } - return *this; - } + /** + * @brief %auto_ptr assignment operator. + * @param a Another %auto_ptr of the same type. + * + * This object now @e owns the object previously owned by @a a, + * which has given up ownsership. The object that this one @e + * used to own and track has been deleted. + */ + auto_ptr& + operator=(auto_ptr& __a) throw() + { + reset(__a.release()); + return *this; + } - template<typename _Tp1> - operator auto_ptr_ref<_Tp1>() throw() - { return auto_ptr_ref<_Tp1>(this->release()); } + /** + * @brief %auto_ptr assignment operator. + * @param a Another %auto_ptr of a different but related type. + * + * A pointer-to-Tp1 must be convertible to a pointer-to-Tp/element_type. + * + * This object now @e owns the object previously owned by @a a, + * which has given up ownsership. The object that this one @e + * used to own and track has been deleted. + */ + template<typename _Tp1> + auto_ptr& + operator=(auto_ptr<_Tp1>& __a) throw() + { + reset(__a.release()); + return *this; + } - template<typename _Tp1> - operator auto_ptr<_Tp1>() throw() - { return auto_ptr<_Tp1>(this->release()); } - /** @} */ -}; + /** + * When the %auto_ptr goes out of scope, the object it owns is deleted. + * If it no longer owns anything (i.e., @c get() is @c NULL), then this + * has no effect. + * + * @if maint + * The C++ standard says there is supposed to be an empty throw + * specification here, but omitting it is standard conforming. Its + * presence can be detected only if _Tp::~_Tp() throws, but this is + * prohibited. [17.4.3.6]/2 + * @end maint + */ + ~auto_ptr() { delete _M_ptr; } + + /** + * @brief Smart pointer dereferencing. + * + * If this %auto_ptr no longer owns anything, then this + * operation will crash. (For a smart pointer, "no longer owns + * anything" is the same as being a null pointer, and you know + * what happens when you dereference one of those...) + */ + element_type& + operator*() const throw() { return *_M_ptr; } + + /** + * @brief Smart pointer dereferencing. + * + * This returns the pointer itself, which the language then will + * automatically cause to be dereferenced. + */ + element_type* + operator->() const throw() { return _M_ptr; } + + /** + * @brief Bypassing the smart pointer. + * @return The raw pointer being managed. + * + * You can get a copy of the pointer that this object owns, for + * situations such as passing to a function which only accepts a raw + * pointer. + * + * @note This %auto_ptr still owns the memory. + */ + element_type* + get() const throw() { return _M_ptr; } + + /** + * @brief Bypassing the smart pointer. + * @return The raw pointer being managed. + * + * You can get a copy of the pointer that this object owns, for + * situations such as passing to a function which only accepts a raw + * pointer. + * + * @note This %auto_ptr no longer owns the memory. When this object + * goes out of scope, nothing will happen. + */ + element_type* + release() throw() + { + element_type* __tmp = _M_ptr; + _M_ptr = 0; + return __tmp; + } + + /** + * @brief Forcibly deletes the managed object. + * @param p A pointer (defaults to NULL). + * + * This object now @e owns the object pointed to by @a p. The previous + * object has been deleted. + */ + void + reset(element_type* __p = 0) throw() + { + if (__p != _M_ptr) + { + delete _M_ptr; + _M_ptr = __p; + } + } + + /** @{ + * @brief Automatic conversions + * + * These operations convert an %auto_ptr into and from an auto_ptr_ref + * automatically as needed. This allows constructs such as + * @code + * auto_ptr<Derived> func_returning_auto_ptr(.....); + * ... + * auto_ptr<Base> ptr = func_returning_auto_ptr(.....); + * @endcode + */ + auto_ptr(auto_ptr_ref<element_type> __ref) throw() + : _M_ptr(__ref._M_ptr) { } + + auto_ptr& + operator=(auto_ptr_ref<element_type> __ref) throw() + { + if (__ref._M_ptr != this->get()) + { + delete _M_ptr; + _M_ptr = __ref._M_ptr; + } + return *this; + } + + template<typename _Tp1> + operator auto_ptr_ref<_Tp1>() throw() + { return auto_ptr_ref<_Tp1>(this->release()); } + template<typename _Tp1> + operator auto_ptr<_Tp1>() throw() + { return auto_ptr<_Tp1>(this->release()); } + /** @} */ + }; } // namespace std -#endif /* _CPP_MEMORY */ +#endif diff --git a/contrib/libstdc++/include/std/std_ostream.h b/contrib/libstdc++/include/std/std_ostream.h index eff4bb5119f3..82f8a2864bc6 100644 --- a/contrib/libstdc++/include/std/std_ostream.h +++ b/contrib/libstdc++/include/std/std_ostream.h @@ -46,7 +46,14 @@ namespace std { - // 27.6.2.1 Template class basic_ostream + // [27.6.2.1] Template class basic_ostream + /** + * @brief Controlling output. + * + * This is the base class for all output streams. It provides text + * formatting of all builtin types, and communicates with any class + * derived from basic_streambuf to do the actual output. + */ template<typename _CharT, typename _Traits> class basic_ostream : virtual public basic_ios<_CharT, _Traits> { @@ -66,20 +73,60 @@ namespace std typedef num_put<_CharT, __ostreambuf_iter> __numput_type; typedef ctype<_CharT> __ctype_type; - // 27.6.2.2 Constructor/destructor: + template<typename _CharT2, typename _Traits2> + friend basic_ostream<_CharT2, _Traits2>& + operator<<(basic_ostream<_CharT2, _Traits2>&, _CharT2); + + template<typename _Traits2> + friend basic_ostream<char, _Traits2>& + operator<<(basic_ostream<char, _Traits2>&, char); + + template<typename _CharT2, typename _Traits2> + friend basic_ostream<_CharT2, _Traits2>& + operator<<(basic_ostream<_CharT2, _Traits2>&, const _CharT2*); + + template<typename _Traits2> + friend basic_ostream<char, _Traits2>& + operator<<(basic_ostream<char, _Traits2>&, const char*); + + template<typename _CharT2, typename _Traits2> + friend basic_ostream<_CharT2, _Traits2>& + operator<<(basic_ostream<_CharT2, _Traits2>&, const char*); + + // [27.6.2.2] constructor/destructor + /** + * @brief Base constructor. + * + * This ctor is almost never called by the user directly, rather from + * derived classes' initialization lists, which pass a pointer to + * their own stream buffer. + */ explicit basic_ostream(__streambuf_type* __sb) { this->init(__sb); } + /** + * @brief Base destructor. + * + * This does very little apart from providing a virtual base dtor. + */ virtual ~basic_ostream() { } - // 27.6.2.3 Prefix/suffix: + // [27.6.2.3] prefix/suffix class sentry; friend class sentry; - // 27.6.2.5 Formatted output: - // 27.6.2.5.3 basic_ostream::operator<< + // [27.6.2.5] formatted output + // [27.6.2.5.3] basic_ostream::operator<< + //@{ + /** + * @brief Interface for manipulators. + * + * Manuipulators such as @c std::endl and @c std::hex use these + * functions in constructs like "std::cout << std::endl". For more + * information, see the iomanip header. + */ __ostream_type& operator<<(__ostream_type& (*__pf)(__ostream_type&)); @@ -88,8 +135,35 @@ namespace std __ostream_type& operator<<(ios_base& (*__pf) (ios_base&)); + //@} - // 27.6.2.5.2 Arithmetic Inserters + // [27.6.2.5.2] arithmetic inserters + /** + * @name Arithmetic Inserters + * + * All the @c operator<< functions (aka <em>formatted output + * functions</em>) have some common behavior. Each starts by + * constructing a temporary object of type std::basic_ostream::sentry. + * This can have several effects, concluding with the setting of a + * status flag; see the sentry documentation for more. + * + * If the sentry status is good, the function tries to generate + * whatever data is appropriate for the type of the argument. + * + * If an exception is thrown during insertion, ios_base::badbit + * will be turned on in the stream's error state without causing an + * ios_base::failure to be thrown. The original exception will then + * be rethrown. + */ + //@{ + /** + * @brief Basic arithmetic inserters + * @param A variable of builtin type. + * @return @c *this if successful + * + * These functions use the stream's current locale (specifically, the + * @c num_get facet) to perform numeric formatting. + */ __ostream_type& operator<<(long __n); @@ -150,31 +224,140 @@ namespace std __ostream_type& operator<<(const void* __p); + /** + * @brief Extracting from another streambuf. + * @param sb A pointer to a streambuf + * + * This function behaves like one of the basic arithmetic extractors, + * in that it also constructs a sentry onject and has the same error + * handling behavior. + * + * If @a sb is NULL, the stream will set failbit in its error state. + * + * Characters are extracted from @a sb and inserted into @c *this + * until one of the following occurs: + * + * - the input stream reaches end-of-file, + * - insertion into the output sequence fails (in this case, the + * character that would have been inserted is not extracted), or + * - an exception occurs while getting a character from @a sb, which + * sets failbit in the error state + * + * If the function inserts no characters, failbit is set. + */ __ostream_type& operator<<(__streambuf_type* __sb); + //@} - // Unformatted output: + // [27.6.2.6] unformatted output functions + /** + * @name Unformatted Output Functions + * + * All the unformatted output functions have some common behavior. + * Each starts by constructing a temporary object of type + * std::basic_ostream::sentry. This has several effects, concluding + * with the setting of a status flag; see the sentry documentation + * for more. + * + * If the sentry status is good, the function tries to generate + * whatever data is appropriate for the type of the argument. + * + * If an exception is thrown during insertion, ios_base::badbit + * will be turned on in the stream's error state. If badbit is on in + * the stream's exceptions mask, the exception will be rethrown + * without completing its actions. + */ + //@{ + /** + * @brief Simple insertion. + * @param c The character to insert. + * @return *this + * + * Tries to insert @a c. + * + * @note This function is not overloaded on signed char and + * unsigned char. + */ __ostream_type& put(char_type __c); + /** + * @brief Character string insertion. + * @param s The array to insert. + * @param n Maximum number of characters to insert. + * @return *this + * + * Characters are copied from @a s and inserted into the stream until + * one of the following happens: + * + * - @a n characters are inserted + * - inserting into the output sequence fails (in this case, badbit + * will be set in the stream's error state) + * + * @note This function is not overloaded on signed char and + * unsigned char. + */ __ostream_type& write(const char_type* __s, streamsize __n); + //@} + /** + * @brief Synchronizing the stream buffer. + * @return *this + * + * If @c rdbuf() is a null pointer, changes nothing. + * + * Otherwise, calls @c rdbuf()->pubsync(), and if that returns -1, + * sets badbit. + */ __ostream_type& flush(); - // Seeks: + // [27.6.2.4] seek members + /** + * @brief Getting the current write position. + * @return A file position object. + * + * If @c fail() is not false, returns @c pos_type(-1) to indicate + * failure. Otherwise returns @c rdbuf()->pubseekoff(0,cur,out). + */ pos_type tellp(); + /** + * @brief Changing the current write position. + * @param pos A file position object. + * @return *this + * + * If @c fail() is not true, calls @c rdbuf()->pubseekpos(pos). If + * that function fails, sets failbit. + */ __ostream_type& seekp(pos_type); - __ostream_type& + /** + * @brief Changing the current write position. + * @param off A file offset object. + * @param dir The direction in which to seek. + * @return *this + * + * If @c fail() is not true, calls @c rdbuf()->pubseekoff(off,dir). + * If that function fails, sets failbit. + */ + __ostream_type& seekp(off_type, ios_base::seekdir); }; - // 27.6.2.3 Class basic_ostream::sentry + /** + * @brief Performs setup work for output streams. + * + * Objects of this class are created before all of the standard + * inserters are run. It is responsible for "exception-safe prefix and + * suffix operations." Additional actions may be added by the + * implementation, and we list them in + * http://gcc.gnu.org/onlinedocs/libstdc++/17_intro/howto.html#5 + * under [27.6] notes. + */ template <typename _CharT, typename _Traits> class basic_ostream<_CharT, _Traits>::sentry { @@ -183,9 +366,27 @@ namespace std basic_ostream<_CharT,_Traits>& _M_os; public: + /** + * @brief The constructor performs preparatory work. + * @param os The output stream to guard. + * + * If the stream state is good (@a os.good() is true), then if the + * stream is tied to another output stream, @c is.tie()->flush() + * is called to synchronize the output sequences. + * + * If the stream state is still good, then the sentry state becomes + * true ("okay"). + */ explicit sentry(basic_ostream<_CharT,_Traits>& __os); + /** + * @brief Possibly flushes the stream. + * + * If @c ios_base::unitbuf is set in @c os.flags(), and + * @c std::uncaught_exception() is true, the sentry destructor calls + * @c flush() on the output stream. + */ ~sentry() { // XXX MT @@ -197,10 +398,34 @@ namespace std } } + /** + * @brief Quick status checking. + * @return The sentry state. + * + * For ease of use, sentries may be converted to booleans. The + * return value is that of the sentry state (true == okay). + */ operator bool() { return _M_ok; } }; + // [27.6.2.5.4] character insertion templates + //@{ + /** + * @brief Character inserters + * @param out An output stream. + * @param c A character. + * @return out + * + * Behaves like one of the formatted arithmetic inserters described in + * std::basic_ostream. After constructing a sentry object with good + * status, this function inserts a single character and any required + * padding (as determined by [22.2.2.2.2]). @c out.width(0) is then + * called. + * + * If @a c is of type @c char and the character type of the stream is not + * @c char, the character is widened before insertion. + */ template<typename _CharT, typename _Traits> basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c); @@ -225,7 +450,22 @@ namespace std basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c) { return (__out << static_cast<char>(__c)); } + //@} + //@{ + /** + * @brief String inserters + * @param out An output stream. + * @param s A character string. + * @return out + * @pre @a s must be a non-NULL pointer + * + * Behaves like one of the formatted arithmetic inserters described in + * std::basic_ostream. After constructing a sentry object with good + * status, this function inserts @c traits::length(s) characters starting + * at @a s, widened if necessary, followed by any required padding (as + * determined by [22.2.2.2.2]). @c out.width(0) is then called. + */ template<typename _CharT, typename _Traits> basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s); @@ -249,18 +489,38 @@ namespace std basic_ostream<char, _Traits> & operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s) { return (__out << reinterpret_cast<const char*>(__s)); } + //@} - // 27.6.2.7 Standard basic_ostream manipulators + // [27.6.2.7] standard basic_ostream manipulators + /** + * @brief Write a newline and flush the stream. + * + * This manipulator is often mistakenly used when a simple newline is + * desired, leading to poor buffering performance. See + * http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#2 for more + * on this subject. + */ template<typename _CharT, typename _Traits> basic_ostream<_CharT, _Traits>& endl(basic_ostream<_CharT, _Traits>& __os) { return flush(__os.put(__os.widen('\n'))); } + /** + * @brief Write a null character into the output sequence. + * + * "Null character" is @c CharT() by definition. For CharT of @c char, + * this correctly writes the ASCII @c NUL character string terminator. + */ template<typename _CharT, typename _Traits> basic_ostream<_CharT, _Traits>& ends(basic_ostream<_CharT, _Traits>& __os) { return __os.put(_CharT()); } + /** + * @brief Flushes the output stream. + * + * This manipulator simply calls the stream's @c flush() member function. + */ template<typename _CharT, typename _Traits> basic_ostream<_CharT, _Traits>& flush(basic_ostream<_CharT, _Traits>& __os) diff --git a/contrib/libstdc++/include/std/std_queue.h b/contrib/libstdc++/include/std/std_queue.h index 6be35516d659..60636e6f0dd8 100644 --- a/contrib/libstdc++/include/std/std_queue.h +++ b/contrib/libstdc++/include/std/std_queue.h @@ -74,8 +74,9 @@ #include <bits/stl_function.h> #include <bits/stl_queue.h> -#endif /* _CPP_QUEUE */ +#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT +# include <bits/deque.tcc> +# include <bits/vector.tcc> +#endif -// Local Variables: -// mode:C++ -// End: +#endif /* _CPP_QUEUE */ diff --git a/contrib/libstdc++/include/std/std_sstream.h b/contrib/libstdc++/include/std/std_sstream.h index 6ee750531485..0940e60f52e7 100644 --- a/contrib/libstdc++/include/std/std_sstream.h +++ b/contrib/libstdc++/include/std/std_sstream.h @@ -1,6 +1,6 @@ // String based streams -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2002 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2002, 2003 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -46,6 +46,18 @@ namespace std { + // [27.7.1] template class basic_stringbuf + /** + * @brief The actual work of input and output (for std::string). + * + * This class associates either or both of its input and output sequences + * with a sequence of characters, which can be initialized from, or made + * available as, a @c std::basic_string. (Paraphrased from [27.7.1]/1.) + * + * For this class, open modes (of type @c ios_base::openmode) have + * @c in set if the input sequence can be read, and @c out set if the + * output sequence can be written. + */ template<typename _CharT, typename _Traits, typename _Alloc> class basic_stringbuf : public basic_streambuf<_CharT, _Traits> { @@ -61,22 +73,48 @@ namespace std typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; - // Non-standard Types: + //@{ + /** + * @if maint + * @doctodo + * @endif + */ typedef basic_streambuf<char_type, traits_type> __streambuf_type; typedef basic_string<char_type, _Traits, _Alloc> __string_type; typedef typename __string_type::size_type __size_type; + //@} protected: // Data Members: + /** + * @if maint + * @doctodo + * @endif + */ __string_type _M_string; public: // Constructors: + /** + * @brief Starts with an empty string buffer. + * @param mode Whether the buffer can read, or write, or both. + * + * The default constructor initializes the parent class using its + * own default ctor. + */ explicit basic_stringbuf(ios_base::openmode __mode = ios_base::in | ios_base::out) : __streambuf_type(), _M_string() { _M_stringbuf_init(__mode); } + /** + * @brief Starts with an existing string buffer. + * @param str A string to copy as a starting buffer. + * @param mode Whether the buffer can read, or write, or both. + * + * This constructor initializes the parent class using its + * own default ctor. + */ explicit basic_stringbuf(const __string_type& __str, ios_base::openmode __mode = ios_base::in | ios_base::out) @@ -84,6 +122,14 @@ namespace std { _M_stringbuf_init(__mode); } // Get and set: + /** + * @brief Copying out the string buffer. + * @return A copy of one of the underlying sequences. + * + * "If the buffer is only created in input mode, the underlying + * character sequence is equal to the input sequence; otherwise, it + * is equal to the output sequence." [27.7.1.2]/1 + */ __string_type str() const { @@ -94,7 +140,7 @@ namespace std // _M_string, and may not be the correct size of the // current stringbuf internal buffer. __size_type __len = _M_string.size(); - if (_M_out_cur > _M_out_beg) + if (_M_out_end > _M_out_beg) __len = max(__size_type(_M_out_end - _M_out_beg), __len); return __string_type(_M_out_beg, _M_out_beg + __len); } @@ -102,6 +148,13 @@ namespace std return _M_string; } + /** + * @brief Setting a new buffer. + * @param s The string to use as a new sequence. + * + * Deallocates any previous stored sequence, then copies @a s to + * use as a new one. + */ void str(const __string_type& __s) { @@ -112,6 +165,11 @@ namespace std protected: // Common initialization code for both ctors goes here. + /** + * @if maint + * @doctodo + * @endif + */ void _M_stringbuf_init(ios_base::openmode __mode) { @@ -135,6 +193,7 @@ namespace std } // Overridden virtual functions: + // [documentation is inherited] virtual int_type underflow() { @@ -144,12 +203,25 @@ namespace std return traits_type::eof(); } + // [documentation is inherited] virtual int_type pbackfail(int_type __c = traits_type::eof()); + // [documentation is inherited] virtual int_type overflow(int_type __c = traits_type::eof()); + /** + * @brief Manipulates the buffer. + * @param s Pointer to a buffer area. + * @param n Size of @a s. + * @return @c this + * + * If no buffer has already been created, and both @a s and @a n are + * non-zero, then @c s is used as a buffer; see + * http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#2 + * for more. + */ virtual __streambuf_type* setbuf(char_type* __s, streamsize __n) { @@ -161,10 +233,12 @@ namespace std return this; } + // [documentation is inherited] virtual pos_type seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode = ios_base::in | ios_base::out); + // [documentation is inherited] virtual pos_type seekpos(pos_type __sp, ios_base::openmode __mode = ios_base::in | ios_base::out); @@ -175,6 +249,11 @@ namespace std // Assumes: contents of _M_string and internal buffer match exactly. // __i == _M_in_cur - _M_in_beg // __o == _M_out_cur - _M_out_beg + /** + * @if maint + * @doctodo + * @endif + */ virtual int _M_really_sync(__size_type __i, __size_type __o) { @@ -196,7 +275,15 @@ namespace std }; - // 27.7.2 Template class basic_istringstream + // [27.7.2] Template class basic_istringstream + /** + * @brief Controlling input for std::string. + * + * This class supports reading from objects of type std::basic_string, + * using the inherited functions from std::basic_istream. To control + * the associated sequence, an instance of std::basic_stringbuf is used, + * which this page refers to as @c sb. + */ template<typename _CharT, typename _Traits, typename _Alloc> class basic_istringstream : public basic_istream<_CharT, _Traits> { @@ -218,40 +305,104 @@ namespace std typedef basic_istream<char_type, traits_type> __istream_type; private: + /** + * @if maint + * @doctodo + * @endif + */ __stringbuf_type _M_stringbuf; public: // Constructors: + /** + * @brief Default constructor starts with an empty string buffer. + * @param mode Whether the buffer can read, or write, or both. + * + * @c ios_base::in is automatically included in @a mode. + * + * Initializes @c sb using @c mode|in, and passes @c &sb to the base + * class initializer. Does not allocate any buffer. + * + * @if maint + * That's a lie. We initialize the base class with NULL, because the + * string class does its own memory management. + * @endif + */ explicit basic_istringstream(ios_base::openmode __mode = ios_base::in) : __istream_type(NULL), _M_stringbuf(__mode | ios_base::in) { this->init(&_M_stringbuf); } + /** + * @brief Starts with an existing string buffer. + * @param str A string to copy as a starting buffer. + * @param mode Whether the buffer can read, or write, or both. + * + * @c ios_base::in is automatically included in @a mode. + * + * Initializes @c sb using @a str and @c mode|in, and passes @c &sb + * to the base class initializer. + * + * @if maint + * That's a lie. We initialize the base class with NULL, because the + * string class does its own memory management. + * @endif + */ explicit basic_istringstream(const __string_type& __str, ios_base::openmode __mode = ios_base::in) : __istream_type(NULL), _M_stringbuf(__str, __mode | ios_base::in) { this->init(&_M_stringbuf); } + /** + * @brief The destructor does nothing. + * + * The buffer is deallocated by the stringbuf object, not the + * formatting stream. + */ ~basic_istringstream() { } // Members: + /** + * @brief Accessing the underlying buffer. + * @return The current basic_stringbuf buffer. + * + * This hides both signatures of std::basic_ios::rdbuf(). + */ __stringbuf_type* rdbuf() const { return const_cast<__stringbuf_type*>(&_M_stringbuf); } + /** + * @brief Copying out the string buffer. + * @return @c rdbuf()->str() + */ __string_type str() const { return _M_stringbuf.str(); } + /** + * @brief Setting a new buffer. + * @param s The string to use as a new sequence. + * + * Calls @c rdbuf()->str(s). + */ void str(const __string_type& __s) { _M_stringbuf.str(__s); } }; - // 27.7.3 Template class basic_ostringstream + // [27.7.3] Template class basic_ostringstream + /** + * @brief Controlling output for std::string. + * + * This class supports writing to objects of type std::basic_string, + * using the inherited functions from std::basic_ostream. To control + * the associated sequence, an instance of std::basic_stringbuf is used, + * which this page refers to as @c sb. + */ template <typename _CharT, typename _Traits, typename _Alloc> class basic_ostringstream : public basic_ostream<_CharT, _Traits> { @@ -273,40 +424,104 @@ namespace std typedef basic_ostream<char_type, traits_type> __ostream_type; private: + /** + * @if maint + * @doctodo + * @endif + */ __stringbuf_type _M_stringbuf; public: - // Constructors/destructor: + // Constructors/destructor: + /** + * @brief Default constructor starts with an empty string buffer. + * @param mode Whether the buffer can read, or write, or both. + * + * @c ios_base::out is automatically included in @a mode. + * + * Initializes @c sb using @c mode|out, and passes @c &sb to the base + * class initializer. Does not allocate any buffer. + * + * @if maint + * That's a lie. We initialize the base class with NULL, because the + * string class does its own memory management. + * @endif + */ explicit basic_ostringstream(ios_base::openmode __mode = ios_base::out) : __ostream_type(NULL), _M_stringbuf(__mode | ios_base::out) { this->init(&_M_stringbuf); } + /** + * @brief Starts with an existing string buffer. + * @param str A string to copy as a starting buffer. + * @param mode Whether the buffer can read, or write, or both. + * + * @c ios_base::out is automatically included in @a mode. + * + * Initializes @c sb using @a str and @c mode|out, and passes @c &sb + * to the base class initializer. + * + * @if maint + * That's a lie. We initialize the base class with NULL, because the + * string class does its own memory management. + * @endif + */ explicit basic_ostringstream(const __string_type& __str, ios_base::openmode __mode = ios_base::out) : __ostream_type(NULL), _M_stringbuf(__str, __mode | ios_base::out) { this->init(&_M_stringbuf); } + /** + * @brief The destructor does nothing. + * + * The buffer is deallocated by the stringbuf object, not the + * formatting stream. + */ ~basic_ostringstream() { } // Members: + /** + * @brief Accessing the underlying buffer. + * @return The current basic_stringbuf buffer. + * + * This hides both signatures of std::basic_ios::rdbuf(). + */ __stringbuf_type* rdbuf() const { return const_cast<__stringbuf_type*>(&_M_stringbuf); } + /** + * @brief Copying out the string buffer. + * @return @c rdbuf()->str() + */ __string_type str() const { return _M_stringbuf.str(); } + /** + * @brief Setting a new buffer. + * @param s The string to use as a new sequence. + * + * Calls @c rdbuf()->str(s). + */ void str(const __string_type& __s) { _M_stringbuf.str(__s); } }; - // 27.7.4 Template class basic_stringstream + // [27.7.4] Template class basic_stringstream + /** + * @brief Controlling input and output for std::string. + * + * This class supports reading from and writing to objects of type + * std::basic_string, using the inherited functions from + * std::basic_iostream. To control the associated sequence, an instance + * of std::basic_stringbuf is used, which this page refers to as @c sb. + */ template <typename _CharT, typename _Traits, typename _Alloc> class basic_stringstream : public basic_iostream<_CharT, _Traits> { @@ -328,33 +543,85 @@ namespace std typedef basic_iostream<char_type, traits_type> __iostream_type; private: + /** + * @if maint + * @doctodo + * @endif + */ __stringbuf_type _M_stringbuf; public: // Constructors/destructors + /** + * @brief Default constructor starts with an empty string buffer. + * @param mode Whether the buffer can read, or write, or both. + * + * Initializes @c sb using @c mode, and passes @c &sb to the base + * class initializer. Does not allocate any buffer. + * + * @if maint + * That's a lie. We initialize the base class with NULL, because the + * string class does its own memory management. + * @endif + */ explicit basic_stringstream(ios_base::openmode __m = ios_base::out | ios_base::in) : __iostream_type(NULL), _M_stringbuf(__m) { this->init(&_M_stringbuf); } + /** + * @brief Starts with an existing string buffer. + * @param str A string to copy as a starting buffer. + * @param mode Whether the buffer can read, or write, or both. + * + * Initializes @c sb using @a str and @c mode, and passes @c &sb + * to the base class initializer. + * + * @if maint + * That's a lie. We initialize the base class with NULL, because the + * string class does its own memory management. + * @endif + */ explicit basic_stringstream(const __string_type& __str, ios_base::openmode __m = ios_base::out | ios_base::in) : __iostream_type(NULL), _M_stringbuf(__str, __m) { this->init(&_M_stringbuf); } + /** + * @brief The destructor does nothing. + * + * The buffer is deallocated by the stringbuf object, not the + * formatting stream. + */ ~basic_stringstream() { } // Members: + /** + * @brief Accessing the underlying buffer. + * @return The current basic_stringbuf buffer. + * + * This hides both signatures of std::basic_ios::rdbuf(). + */ __stringbuf_type* rdbuf() const { return const_cast<__stringbuf_type*>(&_M_stringbuf); } + /** + * @brief Copying out the string buffer. + * @return @c rdbuf()->str() + */ __string_type str() const { return _M_stringbuf.str(); } + /** + * @brief Setting a new buffer. + * @param s The string to use as a new sequence. + * + * Calls @c rdbuf()->str(s). + */ void str(const __string_type& __s) { _M_stringbuf.str(__s); } diff --git a/contrib/libstdc++/include/std/std_stack.h b/contrib/libstdc++/include/std/std_stack.h index e517c42b6ab6..ddae7e78fc68 100644 --- a/contrib/libstdc++/include/std/std_stack.h +++ b/contrib/libstdc++/include/std/std_stack.h @@ -70,8 +70,8 @@ #include <bits/stl_deque.h> #include <bits/stl_stack.h> -#endif /* _CPP_STACK */ +#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT +# include <bits/deque.tcc> +#endif -// Local Variables: -// mode:C++ -// End: +#endif /* _CPP_STACK */ diff --git a/contrib/libstdc++/include/std/std_streambuf.h b/contrib/libstdc++/include/std/std_streambuf.h index db36ed3d75dc..a1958c1a8e7c 100644 --- a/contrib/libstdc++/include/std/std_streambuf.h +++ b/contrib/libstdc++/include/std/std_streambuf.h @@ -50,28 +50,104 @@ namespace std { + /** + * @if maint + * Does stuff. + * @endif + */ template<typename _CharT, typename _Traits> streamsize __copy_streambufs(basic_ios<_CharT, _Traits>& _ios, basic_streambuf<_CharT, _Traits>* __sbin, basic_streambuf<_CharT, _Traits>* __sbout); - // 27.5.2 Template class basic_streambuf<_CharT, _Traits> + /** + * @brief The actual work of input and output (interface). + * + * This is a base class. Derived stream buffers each control a + * pair of character sequences: one for input, and one for output. + * + * Section [27.5.1] of the standard describes the requirements and + * behavior of stream buffer classes. That section (three paragraphs) + * is reproduced here, for simplicity and accuracy. + * + * -# Stream buffers can impose various constraints on the sequences + * they control. Some constraints are: + * - The controlled input sequence can be not readable. + * - The controlled output sequence can be not writable. + * - The controlled sequences can be associated with the contents of + * other representations for character sequences, such as external + * files. + * - The controlled sequences can support operations @e directly to or + * from associated sequences. + * - The controlled sequences can impose limitations on how the + * program can read characters from a sequence, write characters to + * a sequence, put characters back into an input sequence, or alter + * the stream position. + * . + * -# Each sequence is characterized by three pointers which, if non-null, + * all point into the same @c charT array object. The array object + * represents, at any moment, a (sub)sequence of characters from the + * sequence. Operations performed on a sequence alter the values + * stored in these pointers, perform reads and writes directly to or + * from associated sequences, and alter "the stream position" and + * conversion state as needed to maintain this subsequence relationship. + * The three pointers are: + * - the <em>beginning pointer</em>, or lowest element address in the + * array (called @e xbeg here); + * - the <em>next pointer</em>, or next element address that is a + * current candidate for reading or writing (called @e xnext here); + * - the <em>end pointer</em>, or first element address beyond the + * end of the array (called @e xend here). + * . + * -# The following semantic constraints shall always apply for any set + * of three pointers for a sequence, using the pointer names given + * immediately above: + * - If @e xnext is not a null pointer, then @e xbeg and @e xend shall + * also be non-null pointers into the same @c charT array, as + * described above; otherwise, @e xbeg and @e xend shall also be null. + * - If @e xnext is not a null pointer and @e xnext < @e xend for an + * output sequence, then a <em>write position</em> is available. + * In this case, @e *xnext shall be assignable as the next element + * to write (to put, or to store a character value, into the sequence). + * - If @e xnext is not a null pointer and @e xbeg < @e xnext for an + * input sequence, then a <em>putback position</em> is available. + * In this case, @e xnext[-1] shall have a defined value and is the + * next (preceding) element to store a character that is put back + * into the input sequence. + * - If @e xnext is not a null pointer and @e xnext< @e xend for an + * input sequence, then a <em>read position</em> is available. + * In this case, @e *xnext shall have a defined value and is the + * next element to read (to get, or to obtain a character value, + * from the sequence). + */ template<typename _CharT, typename _Traits> class basic_streambuf { public: - // Types: + //@{ + /** + * These are standard types. They permit a standardized way of + * referring to names of (or names dependant on) the template + * parameters, which are specific to the implementation. + */ typedef _CharT char_type; typedef _Traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; + //@} - // Non-standard Types: + //@{ + /** + * @if maint + * These are non-standard types. + * @endif + */ typedef ctype<char_type> __ctype_type; typedef basic_streambuf<char_type, traits_type> __streambuf_type; typedef typename traits_type::state_type __state_type; + //@} friend class basic_ios<char_type, traits_type>; friend class basic_istream<char_type, traits_type>; @@ -84,56 +160,100 @@ namespace std __streambuf_type* __sbin,__streambuf_type* __sbout); protected: - // Pointer to the beginning of internally-allocated - // space. Filebuf manually allocates/deallocates this, whereas - // stringstreams attempt to use the built-in intelligence of the - // string class. If you are managing memory, set this. If not, - // leave it NULL. + /** + * @if maint + * Pointer to the beginning of internally-allocated space. Filebuf + * manually allocates/deallocates this, whereas stringstreams attempt + * to use the built-in intelligence of the string class. If you are + * managing memory, set this. If not, leave it NULL. + * @endif + */ char_type* _M_buf; - // Actual size of allocated internal buffer, in bytes. + /** + * @if maint + * Actual size of allocated internal buffer, in bytes. + * @endif + */ size_t _M_buf_size; - // Optimal or preferred size of internal buffer, in bytes. + /** + * @if maint + * Optimal or preferred size of internal buffer, in bytes. + * @endif + */ size_t _M_buf_size_opt; - // True iff _M_in_* and _M_out_* buffers should always point to - // the same place. True for fstreams, false for sstreams. + /** + * @if maint + * True iff _M_in_* and _M_out_* buffers should always point to + * the same place. True for fstreams, false for sstreams. + * @endif + */ bool _M_buf_unified; - // This is based on _IO_FILE, just reordered to be more - // consistent, and is intended to be the most minimal abstraction - // for an internal buffer. - // get == input == read - // put == output == write + //@{ + /** + * @if maint + * This is based on _IO_FILE, just reordered to be more consistent, + * and is intended to be the most minimal abstraction for an + * internal buffer. + * - get == input == read + * - put == output == write + * @endif + */ char_type* _M_in_beg; // Start of get area. char_type* _M_in_cur; // Current read area. char_type* _M_in_end; // End of get area. char_type* _M_out_beg; // Start of put area. char_type* _M_out_cur; // Current put area. char_type* _M_out_end; // End of put area. + //@} - // Place to stash in || out || in | out settings for current streambuf. + /** + * @if maint + * Place to stash in || out || in | out settings for current streambuf. + * @endif + */ ios_base::openmode _M_mode; - // Current locale setting. + /** + * @if maint + * Current locale setting. + * @endif + */ locale _M_buf_locale; - // True iff locale is initialized. + /** + * @if maint + * True iff locale is initialized. + * @endif + */ bool _M_buf_locale_init; - // Necessary bits for putback buffer management. Only used in - // the basic_filebuf class, as necessary for the standard - // requirements. The only basic_streambuf member function that - // needs access to these data members is in_avail... - // NB: pbacks of over one character are not currently supported. + //@{ + /** + * @if maint + * Necessary bits for putback buffer management. Only used in + * the basic_filebuf class, as necessary for the standard + * requirements. The only basic_streambuf member function that + * needs access to these data members is in_avail... + * + * @note pbacks of over one character are not currently supported. + * @endif + */ static const size_t _S_pback_size = 1; char_type _M_pback[_S_pback_size]; char_type* _M_pback_cur_save; char_type* _M_pback_end_save; bool _M_pback_init; + //@} - // Yet unused. + /** + * @if maint + * Yet unused. + * @endif + */ fpos<__state_type> _M_pos; // Initializes pback buffers, and moves normal buffers to safety. @@ -158,7 +278,7 @@ namespace std // Assumptions: // The pback buffer has only moved forward. void - _M_pback_destroy() + _M_pback_destroy() throw() { if (_M_pback_init) { @@ -236,6 +356,7 @@ namespace std } public: + /// Destructor deallocates no buffer space. virtual ~basic_streambuf() { @@ -245,7 +366,14 @@ namespace std _M_mode = ios_base::openmode(0); } - // Locales: + // [27.5.2.2.1] locales + /** + * @brief Entry point for imbue(). + * @param loc The new locale. + * @return The previous locale. + * + * Calls the derived imbue(loc). + */ locale pubimbue(const locale &__loc) { @@ -254,11 +382,27 @@ namespace std return __tmp; } + /** + * @brief Locale access. + * @return The current locale in effect. + * + * If pubimbue(loc) has been called, then the most recent @c loc + * is returned. Otherwise the global locale in effect at the time + * of construction is returned. + */ locale getloc() const { return _M_buf_locale; } - // Buffer and positioning: + // [27.5.2.2.2] buffer management and positioning + //@{ + /** + * @brief Entry points for derived buffer functions. + * + * The public versions of @c pubfoo dispatch to the protected + * derived @c foo member functions, passing the arguments (if any) + * and returning the result unchanged. + */ __streambuf_type* pubsetbuf(char_type* __s, streamsize __n) { return this->setbuf(__s, __n); } @@ -275,9 +419,17 @@ namespace std int pubsync() { return this->sync(); } + //@} - // Get and put areas: - // Get area: + // [27.5.2.2.3] get area + /** + * @brief Looking ahead into the stream. + * @return The number of characters available. + * + * If a read position is available, returns the number of characters + * available for reading before the buffer must be refilled. + * Otherwise returns the derived @c showmanyc(). + */ streamsize in_avail() { @@ -298,6 +450,13 @@ namespace std return __ret; } + /** + * @brief Getting the next character. + * @return The next character, or eof. + * + * Calls @c sbumpc(), and if that function returns + * @c traits::eof(), so does this function. Otherwise, @c sgetc(). + */ int_type snextc() { @@ -306,9 +465,25 @@ namespace std ? __eof : this->sgetc()); } + /** + * @brief Getting the next character. + * @return The next character, or eof. + * + * If the input read position is available, returns that character + * and increments the read pointer, otherwise calls and returns + * @c uflow(). + */ int_type sbumpc(); + /** + * @brief Getting the next character. + * @return The next character, or eof. + * + * If the input read position is available, returns that character, + * otherwise calls and returns @c underflow(). Does not move the + * read position after fetching the character. + */ int_type sgetc() { @@ -320,26 +495,84 @@ namespace std return __ret; } + /** + * @brief Entry point for xsgetn. + * @param s A buffer area. + * @param n A count. + * + * Returns xsgetn(s,n). The effect is to fill @a s[0] through + * @a s[n-1] with characters from the input sequence, if possible. + */ streamsize sgetn(char_type* __s, streamsize __n) { return this->xsgetn(__s, __n); } - // Putback: + // [27.5.2.2.4] putback + /** + * @brief Pushing characters back into the input stream. + * @param c The character to push back. + * @return The previous character, if possible. + * + * Similar to sungetc(), but @a c is pushed onto the stream instead + * of "the previous character". If successful, the next character + * fetched from the input stream will be @a c. + */ int_type sputbackc(char_type __c); + /** + * @brief Moving backwards in the input stream. + * @return The previous character, if possible. + * + * If a putback position is available, this function decrements the + * input pointer and returns that character. Otherwise, calls and + * returns pbackfail(). The effect is to "unget" the last character + * "gotten". + */ int_type sungetc(); - // Put area: + // [27.5.2.2.5] put area + /** + * @brief Entry point for all single-character output functions. + * @param c A character to output. + * @return @a c, if possible. + * + * One of two public output functions. + * + * If a write position is available for the output sequence (i.e., + * the buffer is not full), stores @a c in that position, increments + * the position, and returns @c traits::to_int_type(c). If a write + * position is not available, returns @c overflow(c). + */ int_type sputc(char_type __c); + /** + * @brief Entry point for all single-character output functions. + * @param s A buffer read area. + * @param n A count. + * + * One of two public output functions. + * + * + * Returns xsputn(s,n). The effect is to write @a s[0] through + * @a s[n-1] to the output sequence, if possible. + */ streamsize sputn(const char_type* __s, streamsize __n) { return this->xsputn(__s, __n); } protected: + /** + * @brief Base constructor. + * + * Only called from derived constructors, and sets up all the + * buffer data to zero, including the pointers described in the + * basic_streambuf class description. Note that, as a result, + * - the class starts with no read nor write positions available, + * - this is not an error + */ basic_streambuf() : _M_buf(NULL), _M_buf_size(0), _M_buf_size_opt(BUFSIZ), _M_buf_unified(false), _M_in_beg(0), _M_in_cur(0), _M_in_end(0), @@ -349,7 +582,18 @@ namespace std _M_pback_init(false) { } - // Get area: + // [27.5.2.3.1] get area access + //@{ + /** + * @brief Access to the get area. + * + * These functions are only available to other protected functions, + * including derived classes. + * + * - eback() returns the beginning pointer for the input sequence + * - gptr() returns the next pointer for the input sequence + * - egptr() returns the end pointer for the input sequence + */ char_type* eback() const { return _M_in_beg; } @@ -358,10 +602,25 @@ namespace std char_type* egptr() const { return _M_in_end; } + //@} + /** + * @brief Moving the read position. + * @param n The delta by which to move. + * + * This just advances the read position without returning any data. + */ void gbump(int __n) { _M_in_cur += __n; } + /** + * @brief Setting the three read area pointers. + * @param gbeg A pointer. + * @param gnext A pointer. + * @param gend A pointer. + * @post @a gbeg == @c eback(), @a gnext == @c gptr(), and + * @a gend == @c egptr() + */ void setg(char_type* __gbeg, char_type* __gnext, char_type* __gend) { @@ -372,7 +631,18 @@ namespace std _M_mode = _M_mode | ios_base::in; } - // Put area: + // [27.5.2.3.2] put area access + //@{ + /** + * @brief Access to the put area. + * + * These functions are only available to other protected functions, + * including derived classes. + * + * - pbase() returns the beginning pointer for the output sequence + * - pptr() returns the next pointer for the output sequence + * - epptr() returns the end pointer for the output sequence + */ char_type* pbase() const { return _M_out_beg; } @@ -381,10 +651,24 @@ namespace std char_type* epptr() const { return _M_out_end; } + //@} + /** + * @brief Moving the write position. + * @param n The delta by which to move. + * + * This just advances the write position without returning any data. + */ void pbump(int __n) { _M_out_cur += __n; } + /** + * @brief Setting the three write area pointers. + * @param pbeg A pointer. + * @param pend A pointer. + * @post @a pbeg == @c pbase(), @a pbeg == @c pptr(), and + * @a pend == @c epptr() + */ void setp(char_type* __pbeg, char_type* __pend) { @@ -394,8 +678,19 @@ namespace std _M_mode = _M_mode | ios_base::out; } - // Virtual functions: - // Locales: + // [27.5.2.4] virtual functions + // [27.5.2.4.1] locales + /** + * @brief Changes translations. + * @param loc A new locale. + * + * Translations done during I/O which depend on the current locale + * are changed by this call. The standard adds, "Between invocations + * of this function a class derived from streambuf can safely cache + * results of calls to locale functions and to members of facets + * so obtained." This function simply stores the new locale for use + * by derived classes. + */ virtual void imbue(const locale& __loc) { @@ -403,35 +698,126 @@ namespace std _M_buf_locale = __loc; } - // Buffer management and positioning: + // [27.5.2.4.2] buffer management and positioning + /** + * @brief Maniuplates the buffer. + * + * Each derived class provides its own appropriate behavior. See + * the next-to-last paragraph of + * http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#2 for + * more on this function. + * + * @note Base class version does nothing, returns @c this. + */ virtual basic_streambuf<char_type,_Traits>* setbuf(char_type*, streamsize) { return this; } + /** + * @brief Alters the stream positions. + * + * Each derived class provides its own appropriate behavior. + * @note Base class version does nothing, returns a @c pos_type + * that represents an invalid stream position. + */ virtual pos_type seekoff(off_type, ios_base::seekdir, ios_base::openmode /*__mode*/ = ios_base::in | ios_base::out) { return pos_type(off_type(-1)); } + /** + * @brief Alters the stream positions. + * + * Each derived class provides its own appropriate behavior. + * @note Base class version does nothing, returns a @c pos_type + * that represents an invalid stream position. + */ virtual pos_type seekpos(pos_type, ios_base::openmode /*__mode*/ = ios_base::in | ios_base::out) { return pos_type(off_type(-1)); } + /** + * @brief Synchronizes the buffer arrays with the controlled sequences. + * @return -1 on failure. + * + * Each derived class provides its own appropriate behavior, + * including the definition of "failure". + * @note Base class version does nothing, returns zero. + */ virtual int sync() { return 0; } - // Get area: + // [27.5.2.4.3] get area + /** + * @brief Investigating the data available. + * @return An estimate of the number of characters available in the + * input sequence, or -1. + * + * "If it returns a positive value, then successive calls to + * @c underflow() will not return @c traits::eof() until at least that + * number of characters have been supplied. If @c showmanyc() + * returns -1, then calls to @c underflow() or @c uflow() will fail." + * [27.5.2.4.3]/1 + * + * @note Base class version does nothing, returns zero. + * @note The standard adds that "the intention is not only that the + * calls [to underflow or uflow] will not return @c eof() but + * that they will return "immediately". + * @note The standard adds that "the morphemes of @c showmanyc are + * "es-how-many-see", not "show-manic". + */ virtual streamsize showmanyc() { return 0; } + /** + * @brief Multiple character extraction. + * @param s A buffer area. + * @param n Maximum number of characters to assign. + * @return The number of characters assigned. + * + * Fills @a s[0] through @a s[n-1] with characters from the input + * sequence, as if by @c sbumpc(). Stops when either @a n characters + * have been copied, or when @c traits::eof() would be copied. + * + * It is expected that derived classes provide a more efficient + * implementation by overriding this definition. + */ virtual streamsize xsgetn(char_type* __s, streamsize __n); + /** + * @brief Fetches more data from the controlled sequence. + * @return The first character from the <em>pending sequence</em>. + * + * Informally, this function is called when the input buffer is + * exhausted (or does not exist, as buffering need not actually be + * done). If a buffer exists, it is "refilled". In either case, the + * next available character is returned, or @c traits::eof() to + * indicate a null pending sequence. + * + * For a formal definiton of the pending sequence, see a good text + * such as Langer & Kreft, or [27.5.2.4.3]/7-14. + * + * A functioning input streambuf can be created by overriding only + * this function (no buffer area will be used). For an example, see + * http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#6 + * + * @note Base class version does nothing, returns eof(). + */ virtual int_type underflow() { return traits_type::eof(); } + /** + * @brief Fetches more data from the controlled sequence. + * @return The first character from the <em>pending sequence</em>. + * + * Informally, this function does the same thing as @c underflow(), + * and in fact is required to call that function. It also returns + * the new character, like @c underflow() does. However, this + * function also moves the read position forward by one. + */ virtual int_type uflow() { @@ -448,21 +834,78 @@ namespace std return __ret; } - // Putback: + // [27.5.2.4.4] putback + /** + * @brief Tries to back up the input sequence. + * @param c The character to be inserted back into the sequence. + * @return eof() on failure, "some other value" on success + * @post The constraints of @c gptr(), @c eback(), and @c pptr() + * are the same as for @c underflow(). + * + * @note Base class version does nothing, returns eof(). + */ virtual int_type pbackfail(int_type /* __c */ = traits_type::eof()) { return traits_type::eof(); } // Put area: + /** + * @brief Multiple character insertion. + * @param s A buffer area. + * @param n Maximum number of characters to write. + * @return The number of characters written. + * + * Writes @a s[0] through @a s[n-1] to the output sequence, as if + * by @c sputc(). Stops when either @a n characters have been + * copied, or when @c sputc() would return @c traits::eof(). + * + * It is expected that derived classes provide a more efficient + * implementation by overriding this definition. + */ virtual streamsize xsputn(const char_type* __s, streamsize __n); + /** + * @brief Consumes data from the buffer; writes to the + * controlled sequence. + * @param c An additional character to consume. + * @return eof() to indicate failure, something else (usually + * @a c, or not_eof()) + * + * Informally, this function is called when the output buffer is full + * (or does not exist, as buffering need not actually be done). If a + * buffer exists, it is "consumed", with "some effect" on the + * controlled sequence. (Typically, the buffer is written out to the + * sequence verbatim.) In either case, the character @a c is also + * written out, if @a c is not @c eof(). + * + * For a formal definiton of this function, see a good text + * such as Langer & Kreft, or [27.5.2.4.5]/3-7. + * + * A functioning output streambuf can be created by overriding only + * this function (no buffer area will be used). + * + * @note Base class version does nothing, returns eof(). + */ virtual int_type overflow(int_type /* __c */ = traits_type::eof()) { return traits_type::eof(); } #ifdef _GLIBCPP_DEPRECATED + // Annex D.6 public: + /** + * @brief Tosses a character. + * + * Advances the read pointer, ignoring the character that would have + * been read. + * + * See http://gcc.gnu.org/ml/libstdc++/2002-05/msg00168.html + * + * @note This function has been deprecated by the standard. You + * must define @c _GLIBCPP_DEPRECATED to make this visible; see + * c++config.h. + */ void stossc() { diff --git a/contrib/libstdc++/include/std/std_valarray.h b/contrib/libstdc++/include/std/std_valarray.h index 3957d7f4b26f..b4de5dfec370 100644 --- a/contrib/libstdc++/include/std/std_valarray.h +++ b/contrib/libstdc++/include/std/std_valarray.h @@ -45,48 +45,47 @@ #include <cmath> #include <cstdlib> #include <numeric> -#include <functional> #include <algorithm> namespace std { - template<class _Clos, typename _Tp> class _Expr; + template<class _Clos, typename _Tp> + class _Expr; - template<typename _Tp1, typename _Tp2> class _ValArray; + template<typename _Tp1, typename _Tp2> + class _ValArray; - template<template<class> class _Oper, - template<class, class> class _Meta, class _Dom> struct _UnClos; + template<class _Oper, template<class, class> class _Meta, class _Dom> + struct _UnClos; - template<template<class> class _Oper, + template<class _Oper, template<class, class> class _Meta1, template<class, class> class _Meta2, - class _Dom1, class _Dom2> class _BinClos; + class _Dom1, class _Dom2> + class _BinClos; - template<template<class, class> class _Meta, class _Dom> class _SClos; + template<template<class, class> class _Meta, class _Dom> + class _SClos; - template<template<class, class> class _Meta, class _Dom> class _GClos; + template<template<class, class> class _Meta, class _Dom> + class _GClos; - template<template<class, class> class _Meta, class _Dom> class _IClos; + template<template<class, class> class _Meta, class _Dom> + class _IClos; - template<template<class, class> class _Meta, class _Dom> class _ValFunClos; - - template<template<class, class> class _Meta, class _Dom> class _RefFunClos; - - template<class _Tp> struct _Unary_plus; - template<class _Tp> struct _Bitwise_and; - template<class _Tp> struct _Bitwise_or; - template<class _Tp> struct _Bitwise_xor; - template<class _Tp> struct _Bitwise_not; - template<class _Tp> struct _Shift_left; - template<class _Tp> struct _Shift_right; + template<template<class, class> class _Meta, class _Dom> + class _ValFunClos; - template<class _Tp> class valarray; // An array of type _Tp - class slice; // BLAS-like slice out of an array - template<class _Tp> class slice_array; - class gslice; // generalized slice out of an array - template<class _Tp> class gslice_array; - template<class _Tp> class mask_array; // masked array - template<class _Tp> class indirect_array; // indirected array + template<template<class, class> class _Meta, class _Dom> + class _RefFunClos; + + template<class _Tp> class valarray; // An array of type _Tp + class slice; // BLAS-like slice out of an array + template<class _Tp> class slice_array; + class gslice; // generalized slice out of an array + template<class _Tp> class gslice_array; + template<class _Tp> class mask_array; // masked array + template<class _Tp> class indirect_array; // indirected array } // namespace std @@ -95,12 +94,19 @@ namespace std namespace std { - template<class _Tp> class valarray - { - public: + template<class _Tp> + class valarray + { + template<class _Op> + struct _UnaryOp + { + typedef typename __fun<_Op, _Tp>::result_type __rt; + typedef _Expr<_UnClos<_Op, _ValArray, _Tp>, __rt> _Rt; + }; + public: typedef _Tp value_type; - - // _lib.valarray.cons_ construct/destroy: + + // _lib.valarray.cons_ construct/destroy: valarray(); explicit valarray(size_t); valarray(const _Tp&, size_t); @@ -111,8 +117,8 @@ namespace std valarray(const mask_array<_Tp>&); valarray(const indirect_array<_Tp>&); template<class _Dom> - valarray(const _Expr<_Dom,_Tp>& __e); - ~valarray(); + valarray(const _Expr<_Dom,_Tp>& __e); + ~valarray(); // _lib.valarray.assign_ assignment: valarray<_Tp>& operator=(const valarray<_Tp>&); @@ -123,7 +129,7 @@ namespace std valarray<_Tp>& operator=(const indirect_array<_Tp>&); template<class _Dom> valarray<_Tp>& - operator= (const _Expr<_Dom,_Tp>&); + operator= (const _Expr<_Dom,_Tp>&); // _lib.valarray.access_ element access: // XXX: LWG to be resolved. @@ -137,67 +143,67 @@ namespace std valarray<_Tp> operator[](const valarray<bool>&) const; mask_array<_Tp> operator[](const valarray<bool>&); _Expr<_IClos<_ValArray, _Tp>, _Tp> - operator[](const valarray<size_t>&) const; + operator[](const valarray<size_t>&) const; indirect_array<_Tp> operator[](const valarray<size_t>&); // _lib.valarray.unary_ unary operators: - _Expr<_UnClos<_Unary_plus,_ValArray,_Tp>,_Tp> operator+ () const; - _Expr<_UnClos<negate,_ValArray,_Tp>,_Tp> operator- () const; - _Expr<_UnClos<_Bitwise_not,_ValArray,_Tp>,_Tp> operator~ () const; - _Expr<_UnClos<logical_not,_ValArray,_Tp>,bool> operator! () const; - + typename _UnaryOp<__unary_plus>::_Rt operator+() const; + typename _UnaryOp<__negate>::_Rt operator-() const; + typename _UnaryOp<__bitwise_not>::_Rt operator~() const; + typename _UnaryOp<__logical_not>::_Rt operator!() const; + // _lib.valarray.cassign_ computed assignment: - valarray<_Tp>& operator*= (const _Tp&); - valarray<_Tp>& operator/= (const _Tp&); - valarray<_Tp>& operator%= (const _Tp&); - valarray<_Tp>& operator+= (const _Tp&); - valarray<_Tp>& operator-= (const _Tp&); - valarray<_Tp>& operator^= (const _Tp&); - valarray<_Tp>& operator&= (const _Tp&); - valarray<_Tp>& operator|= (const _Tp&); + valarray<_Tp>& operator*=(const _Tp&); + valarray<_Tp>& operator/=(const _Tp&); + valarray<_Tp>& operator%=(const _Tp&); + valarray<_Tp>& operator+=(const _Tp&); + valarray<_Tp>& operator-=(const _Tp&); + valarray<_Tp>& operator^=(const _Tp&); + valarray<_Tp>& operator&=(const _Tp&); + valarray<_Tp>& operator|=(const _Tp&); valarray<_Tp>& operator<<=(const _Tp&); valarray<_Tp>& operator>>=(const _Tp&); - valarray<_Tp>& operator*= (const valarray<_Tp>&); - valarray<_Tp>& operator/= (const valarray<_Tp>&); - valarray<_Tp>& operator%= (const valarray<_Tp>&); - valarray<_Tp>& operator+= (const valarray<_Tp>&); - valarray<_Tp>& operator-= (const valarray<_Tp>&); - valarray<_Tp>& operator^= (const valarray<_Tp>&); - valarray<_Tp>& operator|= (const valarray<_Tp>&); - valarray<_Tp>& operator&= (const valarray<_Tp>&); + valarray<_Tp>& operator*=(const valarray<_Tp>&); + valarray<_Tp>& operator/=(const valarray<_Tp>&); + valarray<_Tp>& operator%=(const valarray<_Tp>&); + valarray<_Tp>& operator+=(const valarray<_Tp>&); + valarray<_Tp>& operator-=(const valarray<_Tp>&); + valarray<_Tp>& operator^=(const valarray<_Tp>&); + valarray<_Tp>& operator|=(const valarray<_Tp>&); + valarray<_Tp>& operator&=(const valarray<_Tp>&); valarray<_Tp>& operator<<=(const valarray<_Tp>&); valarray<_Tp>& operator>>=(const valarray<_Tp>&); template<class _Dom> - valarray<_Tp>& operator*= (const _Expr<_Dom,_Tp>&); + valarray<_Tp>& operator*=(const _Expr<_Dom,_Tp>&); template<class _Dom> - valarray<_Tp>& operator/= (const _Expr<_Dom,_Tp>&); + valarray<_Tp>& operator/=(const _Expr<_Dom,_Tp>&); template<class _Dom> - valarray<_Tp>& operator%= (const _Expr<_Dom,_Tp>&); + valarray<_Tp>& operator%=(const _Expr<_Dom,_Tp>&); template<class _Dom> - valarray<_Tp>& operator+= (const _Expr<_Dom,_Tp>&); + valarray<_Tp>& operator+=(const _Expr<_Dom,_Tp>&); template<class _Dom> - valarray<_Tp>& operator-= (const _Expr<_Dom,_Tp>&); + valarray<_Tp>& operator-=(const _Expr<_Dom,_Tp>&); template<class _Dom> - valarray<_Tp>& operator^= (const _Expr<_Dom,_Tp>&); + valarray<_Tp>& operator^=(const _Expr<_Dom,_Tp>&); template<class _Dom> - valarray<_Tp>& operator|= (const _Expr<_Dom,_Tp>&); + valarray<_Tp>& operator|=(const _Expr<_Dom,_Tp>&); template<class _Dom> - valarray<_Tp>& operator&= (const _Expr<_Dom,_Tp>&); + valarray<_Tp>& operator&=(const _Expr<_Dom,_Tp>&); template<class _Dom> - valarray<_Tp>& operator<<=(const _Expr<_Dom,_Tp>&); + valarray<_Tp>& operator<<=(const _Expr<_Dom,_Tp>&); template<class _Dom> - valarray<_Tp>& operator>>=(const _Expr<_Dom,_Tp>&); + valarray<_Tp>& operator>>=(const _Expr<_Dom,_Tp>&); + - // _lib.valarray.members_ member functions: size_t size() const; _Tp sum() const; _Tp min() const; _Tp max() const; -// // FIXME: Extension -// _Tp product () const; + // // FIXME: Extension + // _Tp product () const; valarray<_Tp> shift (int) const; valarray<_Tp> cshift(int) const; @@ -205,56 +211,25 @@ namespace std _Expr<_RefFunClos<_ValArray,_Tp>,_Tp> apply(_Tp func(const _Tp&)) const; void resize(size_t __size, _Tp __c = _Tp()); - private: + private: size_t _M_size; _Tp* __restrict__ _M_data; - + friend class _Array<_Tp>; - }; - - - template<typename _Tp> struct _Unary_plus : unary_function<_Tp,_Tp> { - _Tp operator() (const _Tp& __t) const { return __t; } - }; - - template<typename _Tp> struct _Bitwise_and : binary_function<_Tp,_Tp,_Tp> { - _Tp operator() (_Tp __x, _Tp __y) const { return __x & __y; } - }; - - template<typename _Tp> struct _Bitwise_or : binary_function<_Tp,_Tp,_Tp> { - _Tp operator() (_Tp __x, _Tp __y) const { return __x | __y; } - }; - - template<typename _Tp> struct _Bitwise_xor : binary_function<_Tp,_Tp,_Tp> { - _Tp operator() (_Tp __x, _Tp __y) const { return __x ^ __y; } - }; - - template<typename _Tp> struct _Bitwise_not : unary_function<_Tp,_Tp> { - _Tp operator() (_Tp __t) const { return ~__t; } - }; - - template<typename _Tp> struct _Shift_left : unary_function<_Tp,_Tp> { - _Tp operator() (_Tp __x, _Tp __y) const { return __x << __y; } - }; - - template<typename _Tp> struct _Shift_right : unary_function<_Tp,_Tp> { - _Tp operator() (_Tp __x, _Tp __y) const { return __x >> __y; } - }; - + }; template<typename _Tp> - inline const _Tp& - valarray<_Tp>::operator[] (size_t __i) const - { return _M_data[__i]; } + inline const _Tp& + valarray<_Tp>::operator[](size_t __i) const + { return _M_data[__i]; } template<typename _Tp> - inline _Tp& - valarray<_Tp>::operator[] (size_t __i) - { return _M_data[__i]; } + inline _Tp& + valarray<_Tp>::operator[](size_t __i) + { return _M_data[__i]; } } // std:: -#include <bits/slice.h> #include <bits/slice_array.h> #include <bits/gslice.h> #include <bits/gslice_array.h> @@ -264,214 +239,227 @@ namespace std namespace std { template<typename _Tp> - inline valarray<_Tp>::valarray () : _M_size (0), _M_data (0) {} + inline + valarray<_Tp>::valarray() : _M_size(0), _M_data(0) {} template<typename _Tp> - inline valarray<_Tp>::valarray (size_t __n) - : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n)) - { __valarray_default_construct(_M_data, _M_data + __n); } + inline + valarray<_Tp>::valarray(size_t __n) + : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n)) + { __valarray_default_construct(_M_data, _M_data + __n); } template<typename _Tp> - inline valarray<_Tp>::valarray (const _Tp& __t, size_t __n) - : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n)) - { __valarray_fill_construct (_M_data, _M_data + __n, __t); } + inline + valarray<_Tp>::valarray(const _Tp& __t, size_t __n) + : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n)) + { __valarray_fill_construct(_M_data, _M_data + __n, __t); } template<typename _Tp> - inline valarray<_Tp>::valarray (const _Tp* __restrict__ __p, size_t __n) - : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n)) - { __valarray_copy_construct (__p, __p + __n, _M_data); } + inline + valarray<_Tp>::valarray(const _Tp* __restrict__ __p, size_t __n) + : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n)) + { __valarray_copy_construct(__p, __p + __n, _M_data); } template<typename _Tp> - inline valarray<_Tp>::valarray (const valarray<_Tp>& __v) - : _M_size(__v._M_size), _M_data(__valarray_get_storage<_Tp>(__v._M_size)) - { __valarray_copy_construct (__v._M_data, __v._M_data + _M_size, _M_data); } + inline + valarray<_Tp>::valarray(const valarray<_Tp>& __v) + : _M_size(__v._M_size), _M_data(__valarray_get_storage<_Tp>(__v._M_size)) + { __valarray_copy_construct(__v._M_data, __v._M_data + _M_size, _M_data); } template<typename _Tp> - inline valarray<_Tp>::valarray (const slice_array<_Tp>& __sa) - : _M_size(__sa._M_sz), _M_data(__valarray_get_storage<_Tp>(__sa._M_sz)) - { - __valarray_copy - (__sa._M_array, __sa._M_sz, __sa._M_stride, _Array<_Tp>(_M_data)); - } + inline + valarray<_Tp>::valarray(const slice_array<_Tp>& __sa) + : _M_size(__sa._M_sz), _M_data(__valarray_get_storage<_Tp>(__sa._M_sz)) + { + __valarray_copy + (__sa._M_array, __sa._M_sz, __sa._M_stride, _Array<_Tp>(_M_data)); + } template<typename _Tp> - inline valarray<_Tp>::valarray (const gslice_array<_Tp>& __ga) - : _M_size(__ga._M_index.size()), - _M_data(__valarray_get_storage<_Tp>(_M_size)) - { - __valarray_copy - (__ga._M_array, _Array<size_t>(__ga._M_index), - _Array<_Tp>(_M_data), _M_size); - } + inline + valarray<_Tp>::valarray(const gslice_array<_Tp>& __ga) + : _M_size(__ga._M_index.size()), + _M_data(__valarray_get_storage<_Tp>(_M_size)) + { + __valarray_copy + (__ga._M_array, _Array<size_t>(__ga._M_index), + _Array<_Tp>(_M_data), _M_size); + } template<typename _Tp> - inline valarray<_Tp>::valarray (const mask_array<_Tp>& __ma) - : _M_size(__ma._M_sz), _M_data(__valarray_get_storage<_Tp>(__ma._M_sz)) - { - __valarray_copy - (__ma._M_array, __ma._M_mask, _Array<_Tp>(_M_data), _M_size); - } + inline + valarray<_Tp>::valarray(const mask_array<_Tp>& __ma) + : _M_size(__ma._M_sz), _M_data(__valarray_get_storage<_Tp>(__ma._M_sz)) + { + __valarray_copy + (__ma._M_array, __ma._M_mask, _Array<_Tp>(_M_data), _M_size); + } template<typename _Tp> - inline valarray<_Tp>::valarray (const indirect_array<_Tp>& __ia) - : _M_size(__ia._M_sz), _M_data(__valarray_get_storage<_Tp>(__ia._M_sz)) - { - __valarray_copy - (__ia._M_array, __ia._M_index, _Array<_Tp>(_M_data), _M_size); - } + inline + valarray<_Tp>::valarray(const indirect_array<_Tp>& __ia) + : _M_size(__ia._M_sz), _M_data(__valarray_get_storage<_Tp>(__ia._M_sz)) + { + __valarray_copy + (__ia._M_array, __ia._M_index, _Array<_Tp>(_M_data), _M_size); + } template<typename _Tp> template<class _Dom> - inline valarray<_Tp>::valarray (const _Expr<_Dom, _Tp>& __e) - : _M_size(__e.size ()), _M_data(__valarray_get_storage<_Tp>(_M_size)) - { __valarray_copy (__e, _M_size, _Array<_Tp>(_M_data)); } + inline + valarray<_Tp>::valarray(const _Expr<_Dom, _Tp>& __e) + : _M_size(__e.size()), _M_data(__valarray_get_storage<_Tp>(_M_size)) + { __valarray_copy(__e, _M_size, _Array<_Tp>(_M_data)); } template<typename _Tp> - inline valarray<_Tp>::~valarray () - { + inline + valarray<_Tp>::~valarray() + { __valarray_destroy_elements(_M_data, _M_data + _M_size); __valarray_release_memory(_M_data); - } + } template<typename _Tp> - inline valarray<_Tp>& - valarray<_Tp>::operator= (const valarray<_Tp>& __v) - { + inline valarray<_Tp>& + valarray<_Tp>::operator=(const valarray<_Tp>& __v) + { __valarray_copy(__v._M_data, _M_size, _M_data); return *this; - } + } template<typename _Tp> - inline valarray<_Tp>& - valarray<_Tp>::operator= (const _Tp& __t) - { - __valarray_fill (_M_data, _M_size, __t); + inline valarray<_Tp>& + valarray<_Tp>::operator=(const _Tp& __t) + { + __valarray_fill(_M_data, _M_size, __t); return *this; - } + } template<typename _Tp> - inline valarray<_Tp>& - valarray<_Tp>::operator= (const slice_array<_Tp>& __sa) - { - __valarray_copy (__sa._M_array, __sa._M_sz, - __sa._M_stride, _Array<_Tp>(_M_data)); + inline valarray<_Tp>& + valarray<_Tp>::operator=(const slice_array<_Tp>& __sa) + { + __valarray_copy(__sa._M_array, __sa._M_sz, + __sa._M_stride, _Array<_Tp>(_M_data)); return *this; - } + } template<typename _Tp> - inline valarray<_Tp>& - valarray<_Tp>::operator= (const gslice_array<_Tp>& __ga) - { - __valarray_copy (__ga._M_array, _Array<size_t>(__ga._M_index), - _Array<_Tp>(_M_data), _M_size); + inline valarray<_Tp>& + valarray<_Tp>::operator=(const gslice_array<_Tp>& __ga) + { + __valarray_copy(__ga._M_array, _Array<size_t>(__ga._M_index), + _Array<_Tp>(_M_data), _M_size); return *this; - } + } template<typename _Tp> - inline valarray<_Tp>& - valarray<_Tp>::operator= (const mask_array<_Tp>& __ma) - { - __valarray_copy (__ma._M_array, __ma._M_mask, - _Array<_Tp>(_M_data), _M_size); + inline valarray<_Tp>& + valarray<_Tp>::operator=(const mask_array<_Tp>& __ma) + { + __valarray_copy(__ma._M_array, __ma._M_mask, + _Array<_Tp>(_M_data), _M_size); return *this; - } + } template<typename _Tp> - inline valarray<_Tp>& - valarray<_Tp>::operator= (const indirect_array<_Tp>& __ia) - { - __valarray_copy (__ia._M_array, __ia._M_index, - _Array<_Tp>(_M_data), _M_size); + inline valarray<_Tp>& + valarray<_Tp>::operator=(const indirect_array<_Tp>& __ia) + { + __valarray_copy(__ia._M_array, __ia._M_index, + _Array<_Tp>(_M_data), _M_size); return *this; - } + } template<typename _Tp> template<class _Dom> - inline valarray<_Tp>& - valarray<_Tp>::operator= (const _Expr<_Dom, _Tp>& __e) - { - __valarray_copy (__e, _M_size, _Array<_Tp>(_M_data)); - return *this; - } + inline valarray<_Tp>& + valarray<_Tp>::operator=(const _Expr<_Dom, _Tp>& __e) + { + __valarray_copy(__e, _M_size, _Array<_Tp>(_M_data)); + return *this; + } template<typename _Tp> - inline _Expr<_SClos<_ValArray,_Tp>, _Tp> - valarray<_Tp>::operator[] (slice __s) const - { + inline _Expr<_SClos<_ValArray,_Tp>, _Tp> + valarray<_Tp>::operator[](slice __s) const + { typedef _SClos<_ValArray,_Tp> _Closure; - return _Expr<_Closure, _Tp> (_Closure (_Array<_Tp>(_M_data), __s)); - } + return _Expr<_Closure, _Tp>(_Closure (_Array<_Tp>(_M_data), __s)); + } template<typename _Tp> - inline slice_array<_Tp> - valarray<_Tp>::operator[] (slice __s) - { - return slice_array<_Tp> (_Array<_Tp>(_M_data), __s); - } + inline slice_array<_Tp> + valarray<_Tp>::operator[](slice __s) + { + return slice_array<_Tp>(_Array<_Tp>(_M_data), __s); + } template<typename _Tp> - inline _Expr<_GClos<_ValArray,_Tp>, _Tp> - valarray<_Tp>::operator[] (const gslice& __gs) const - { + inline _Expr<_GClos<_ValArray,_Tp>, _Tp> + valarray<_Tp>::operator[](const gslice& __gs) const + { typedef _GClos<_ValArray,_Tp> _Closure; return _Expr<_Closure, _Tp> - (_Closure (_Array<_Tp>(_M_data), __gs._M_index->_M_index)); - } + (_Closure(_Array<_Tp>(_M_data), __gs._M_index->_M_index)); + } template<typename _Tp> - inline gslice_array<_Tp> - valarray<_Tp>::operator[] (const gslice& __gs) - { + inline gslice_array<_Tp> + valarray<_Tp>::operator[](const gslice& __gs) + { return gslice_array<_Tp> - (_Array<_Tp>(_M_data), __gs._M_index->_M_index); - } + (_Array<_Tp>(_M_data), __gs._M_index->_M_index); + } template<typename _Tp> - inline valarray<_Tp> - valarray<_Tp>::operator[] (const valarray<bool>& __m) const - { - size_t __s (0); - size_t __e (__m.size ()); + inline valarray<_Tp> + valarray<_Tp>::operator[](const valarray<bool>& __m) const + { + size_t __s = 0; + size_t __e = __m.size(); for (size_t __i=0; __i<__e; ++__i) - if (__m[__i]) ++__s; - return valarray<_Tp> (mask_array<_Tp> (_Array<_Tp>(_M_data), __s, - _Array<bool> (__m))); - } + if (__m[__i]) ++__s; + return valarray<_Tp>(mask_array<_Tp>(_Array<_Tp>(_M_data), __s, + _Array<bool> (__m))); + } template<typename _Tp> - inline mask_array<_Tp> - valarray<_Tp>::operator[] (const valarray<bool>& __m) - { - size_t __s (0); - size_t __e (__m.size ()); + inline mask_array<_Tp> + valarray<_Tp>::operator[](const valarray<bool>& __m) + { + size_t __s = 0; + size_t __e = __m.size(); for (size_t __i=0; __i<__e; ++__i) - if (__m[__i]) ++__s; - return mask_array<_Tp> (_Array<_Tp>(_M_data), __s, _Array<bool> (__m)); - } + if (__m[__i]) ++__s; + return mask_array<_Tp>(_Array<_Tp>(_M_data), __s, _Array<bool>(__m)); + } template<typename _Tp> - inline _Expr<_IClos<_ValArray,_Tp>, _Tp> - valarray<_Tp>::operator[] (const valarray<size_t>& __i) const - { + inline _Expr<_IClos<_ValArray,_Tp>, _Tp> + valarray<_Tp>::operator[](const valarray<size_t>& __i) const + { typedef _IClos<_ValArray,_Tp> _Closure; - return _Expr<_Closure, _Tp> (_Closure (*this, __i)); - } + return _Expr<_Closure, _Tp>(_Closure(*this, __i)); + } template<typename _Tp> - inline indirect_array<_Tp> - valarray<_Tp>::operator[] (const valarray<size_t>& __i) - { - return indirect_array<_Tp> (_Array<_Tp>(_M_data), __i.size(), - _Array<size_t> (__i)); - } + inline indirect_array<_Tp> + valarray<_Tp>::operator[](const valarray<size_t>& __i) + { + return indirect_array<_Tp>(_Array<_Tp>(_M_data), __i.size(), + _Array<size_t>(__i)); + } template<class _Tp> - inline size_t valarray<_Tp>::size () const { return _M_size; } + inline size_t + valarray<_Tp>::size() const + { return _M_size; } template<class _Tp> - inline _Tp - valarray<_Tp>::sum () const - { + inline _Tp + valarray<_Tp>::sum() const + { return __valarray_sum(_M_data, _M_data + _M_size); - } + } // template<typename _Tp> // inline _Tp @@ -530,209 +518,172 @@ namespace std } template <class _Tp> - inline void - valarray<_Tp>::resize (size_t __n, _Tp __c) - { - // This complication is so to make valarray<valarray<T> > work - // even though it is not required by the standard. Nobody should - // be saying valarray<valarray<T> > anyway. See the specs. - __valarray_destroy_elements(_M_data, _M_data + _M_size); - if (_M_size != __n) - { - __valarray_release_memory(_M_data); - _M_size = __n; - _M_data = __valarray_get_storage<_Tp>(__n); - } - __valarray_fill_construct(_M_data, _M_data + __n, __c); - } + inline void + valarray<_Tp>::resize (size_t __n, _Tp __c) + { + // This complication is so to make valarray<valarray<T> > work + // even though it is not required by the standard. Nobody should + // be saying valarray<valarray<T> > anyway. See the specs. + __valarray_destroy_elements(_M_data, _M_data + _M_size); + if (_M_size != __n) + { + __valarray_release_memory(_M_data); + _M_size = __n; + _M_data = __valarray_get_storage<_Tp>(__n); + } + __valarray_fill_construct(_M_data, _M_data + __n, __c); + } template<typename _Tp> - inline _Tp - valarray<_Tp>::min() const - { + inline _Tp + valarray<_Tp>::min() const + { return *min_element (_M_data, _M_data+_M_size); - } + } template<typename _Tp> - inline _Tp - valarray<_Tp>::max() const - { + inline _Tp + valarray<_Tp>::max() const + { return *max_element (_M_data, _M_data+_M_size); - } + } template<class _Tp> - inline _Expr<_ValFunClos<_ValArray,_Tp>,_Tp> - valarray<_Tp>::apply (_Tp func (_Tp)) const - { + inline _Expr<_ValFunClos<_ValArray,_Tp>,_Tp> + valarray<_Tp>::apply(_Tp func(_Tp)) const + { typedef _ValFunClos<_ValArray,_Tp> _Closure; - return _Expr<_Closure,_Tp> (_Closure (*this, func)); - } + return _Expr<_Closure,_Tp>(_Closure(*this, func)); + } template<class _Tp> - inline _Expr<_RefFunClos<_ValArray,_Tp>,_Tp> - valarray<_Tp>::apply (_Tp func (const _Tp &)) const - { + inline _Expr<_RefFunClos<_ValArray,_Tp>,_Tp> + valarray<_Tp>::apply(_Tp func(const _Tp &)) const + { typedef _RefFunClos<_ValArray,_Tp> _Closure; - return _Expr<_Closure,_Tp> (_Closure (*this, func)); - } + return _Expr<_Closure,_Tp>(_Closure(*this, func)); + } #define _DEFINE_VALARRAY_UNARY_OPERATOR(_Op, _Name) \ template<typename _Tp> \ - inline _Expr<_UnClos<_Name,_ValArray,_Tp>, _Tp> \ + inline typename valarray<_Tp>::template _UnaryOp<_Name>::_Rt \ valarray<_Tp>::operator _Op() const \ { \ - typedef _UnClos<_Name,_ValArray,_Tp> _Closure; \ - return _Expr<_Closure, _Tp> (_Closure (*this)); \ + typedef _UnClos<_Name,_ValArray,_Tp> _Closure; \ + typedef typename __fun<_Name, _Tp>::result_type _Rt; \ + return _Expr<_Closure, _Rt>(_Closure(*this)); \ } - _DEFINE_VALARRAY_UNARY_OPERATOR(+, _Unary_plus) - _DEFINE_VALARRAY_UNARY_OPERATOR(-, negate) - _DEFINE_VALARRAY_UNARY_OPERATOR(~, _Bitwise_not) + _DEFINE_VALARRAY_UNARY_OPERATOR(+, __unary_plus) + _DEFINE_VALARRAY_UNARY_OPERATOR(-, __negate) + _DEFINE_VALARRAY_UNARY_OPERATOR(~, __bitwise_not) + _DEFINE_VALARRAY_UNARY_OPERATOR (!, __logical_not) #undef _DEFINE_VALARRAY_UNARY_OPERATOR - - template<typename _Tp> - inline _Expr<_UnClos<logical_not,_ValArray,_Tp>, bool> - valarray<_Tp>::operator!() const - { - typedef _UnClos<logical_not,_ValArray,_Tp> _Closure; - return _Expr<_Closure, bool> (_Closure (*this)); - } #define _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(_Op, _Name) \ template<class _Tp> \ - inline valarray<_Tp> & \ - valarray<_Tp>::operator _Op##= (const _Tp &__t) \ - { \ - _Array_augmented_##_Name (_Array<_Tp>(_M_data), _M_size, __t); \ + inline valarray<_Tp>& \ + valarray<_Tp>::operator _Op##=(const _Tp &__t) \ + { \ + _Array_augmented_##_Name(_Array<_Tp>(_M_data), _M_size, __t); \ return *this; \ - } \ + } \ \ template<class _Tp> \ - inline valarray<_Tp> & \ - valarray<_Tp>::operator _Op##= (const valarray<_Tp> &__v) \ - { \ - _Array_augmented_##_Name (_Array<_Tp>(_M_data), _M_size, \ - _Array<_Tp>(__v._M_data)); \ + inline valarray<_Tp>& \ + valarray<_Tp>::operator _Op##=(const valarray<_Tp> &__v) \ + { \ + _Array_augmented_##_Name(_Array<_Tp>(_M_data), _M_size, \ + _Array<_Tp>(__v._M_data)); \ return *this; \ - } + } -_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(+, plus) -_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(-, minus) -_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(*, multiplies) -_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(/, divides) -_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(%, modulus) -_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(^, xor) -_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(&, and) -_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(|, or) -_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(<<, shift_left) -_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(>>, shift_right) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(+, __plus) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(-, __minus) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(*, __multiplies) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(/, __divides) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(%, __modulus) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(^, __bitwise_xor) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(&, __bitwise_and) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(|, __bitwise_or) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(<<, __shift_left) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(>>, __shift_right) #undef _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT - -} // std:: - - -namespace std -{ - #define _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(_Op, _Name) \ template<class _Tp> template<class _Dom> \ - inline valarray<_Tp> & \ - valarray<_Tp>::operator _Op##= (const _Expr<_Dom,_Tp> &__e) \ - { \ - _Array_augmented_##_Name (_Array<_Tp>(_M_data), __e, _M_size); \ + inline valarray<_Tp>& \ + valarray<_Tp>::operator _Op##=(const _Expr<_Dom,_Tp>& __e) \ + { \ + _Array_augmented_##_Name(_Array<_Tp>(_M_data), __e, _M_size); \ return *this; \ - } + } -_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(+, plus) -_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(-, minus) -_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(*, multiplies) -_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(/, divides) -_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(%, modulus) -_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(^, xor) -_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(&, and) -_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(|, or) -_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(<<, shift_left) -_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(>>, shift_right) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(+, __plus) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(-, __minus) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(*, __multiplies) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(/, __divides) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(%, __modulus) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(^, __bitwise_xor) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(&, __bitwise_and) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(|, __bitwise_or) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(<<, __shift_left) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(>>, __shift_right) #undef _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT #define _DEFINE_BINARY_OPERATOR(_Op, _Name) \ template<typename _Tp> \ - inline _Expr<_BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp>, _Tp> \ - operator _Op (const valarray<_Tp> &__v, const valarray<_Tp> &__w) \ - { \ + inline _Expr<_BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp>, \ + typename __fun<_Name, _Tp>::result_type> \ + operator _Op(const valarray<_Tp>& __v, const valarray<_Tp>& __w) \ + { \ typedef _BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp> _Closure; \ - return _Expr<_Closure, _Tp> (_Closure (__v, __w)); \ - } \ + typedef typename __fun<_Name, _Tp>::result_type _Rt; \ + return _Expr<_Closure, _Rt>(_Closure(__v, __w)); \ + } \ \ template<typename _Tp> \ - inline _Expr<_BinClos<_Name,_ValArray,_Constant,_Tp,_Tp>,_Tp> \ - operator _Op (const valarray<_Tp> &__v, const _Tp &__t) \ + inline _Expr<_BinClos<_Name,_ValArray,_Constant,_Tp,_Tp>, \ + typename __fun<_Name, _Tp>::result_type> \ + operator _Op(const valarray<_Tp>& __v, const _Tp& __t) \ { \ - typedef _BinClos<_Name,_ValArray,_Constant,_Tp,_Tp> _Closure; \ - return _Expr<_Closure, _Tp> (_Closure (__v, __t)); \ + typedef _BinClos<_Name,_ValArray,_Constant,_Tp,_Tp> _Closure; \ + typedef typename __fun<_Name, _Tp>::result_type _Rt; \ + return _Expr<_Closure, _Rt>(_Closure(__v, __t)); \ } \ \ template<typename _Tp> \ - inline _Expr<_BinClos<_Name,_Constant,_ValArray,_Tp,_Tp>,_Tp> \ - operator _Op (const _Tp &__t, const valarray<_Tp> &__v) \ + inline _Expr<_BinClos<_Name,_Constant,_ValArray,_Tp,_Tp>, \ + typename __fun<_Name, _Tp>::result_type> \ + operator _Op(const _Tp& __t, const valarray<_Tp>& __v) \ { \ - typedef _BinClos<_Name,_Constant,_ValArray,_Tp,_Tp> _Closure; \ - return _Expr<_Closure, _Tp> (_Closure (__t, __v)); \ + typedef _BinClos<_Name,_Constant,_ValArray,_Tp,_Tp> _Closure; \ + typedef typename __fun<_Name, _Tp>::result_type _Rt; \ + return _Expr<_Closure, _Tp>(_Closure(__t, __v)); \ } -_DEFINE_BINARY_OPERATOR(+, plus) -_DEFINE_BINARY_OPERATOR(-, minus) -_DEFINE_BINARY_OPERATOR(*, multiplies) -_DEFINE_BINARY_OPERATOR(/, divides) -_DEFINE_BINARY_OPERATOR(%, modulus) -_DEFINE_BINARY_OPERATOR(^, _Bitwise_xor) -_DEFINE_BINARY_OPERATOR(&, _Bitwise_and) -_DEFINE_BINARY_OPERATOR(|, _Bitwise_or) -_DEFINE_BINARY_OPERATOR(<<, _Shift_left) -_DEFINE_BINARY_OPERATOR(>>, _Shift_right) - -#undef _DEFINE_BINARY_OPERATOR - -#define _DEFINE_LOGICAL_OPERATOR(_Op, _Name) \ - template<typename _Tp> \ - inline _Expr<_BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp>,bool> \ - operator _Op (const valarray<_Tp> &__v, const valarray<_Tp> &__w) \ - { \ - typedef _BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp> _Closure; \ - return _Expr<_Closure, bool> (_Closure (__v, __w)); \ - } \ - \ - template<class _Tp> \ - inline _Expr<_BinClos<_Name,_ValArray,_Constant,_Tp,_Tp>,bool> \ - operator _Op (const valarray<_Tp> &__v, const _Tp &__t) \ - { \ - typedef _BinClos<_Name,_ValArray,_Constant,_Tp,_Tp> _Closure; \ - return _Expr<_Closure, bool> (_Closure (__v, __t)); \ - } \ - \ - template<class _Tp> \ - inline _Expr<_BinClos<_Name,_Constant,_ValArray,_Tp,_Tp>,bool> \ - operator _Op (const _Tp &__t, const valarray<_Tp> &__v) \ - { \ - typedef _BinClos<_Name,_Constant,_ValArray,_Tp,_Tp> _Closure; \ - return _Expr<_Closure, bool> (_Closure (__t, __v)); \ - } - -_DEFINE_LOGICAL_OPERATOR(&&, logical_and) -_DEFINE_LOGICAL_OPERATOR(||, logical_or) -_DEFINE_LOGICAL_OPERATOR(==, equal_to) -_DEFINE_LOGICAL_OPERATOR(!=, not_equal_to) -_DEFINE_LOGICAL_OPERATOR(<, less) -_DEFINE_LOGICAL_OPERATOR(>, greater) -_DEFINE_LOGICAL_OPERATOR(<=, less_equal) -_DEFINE_LOGICAL_OPERATOR(>=, greater_equal) - -#undef _DEFINE_LOGICAL_OPERATOR +_DEFINE_BINARY_OPERATOR(+, __plus) +_DEFINE_BINARY_OPERATOR(-, __minus) +_DEFINE_BINARY_OPERATOR(*, __multiplies) +_DEFINE_BINARY_OPERATOR(/, __divides) +_DEFINE_BINARY_OPERATOR(%, __modulus) +_DEFINE_BINARY_OPERATOR(^, __bitwise_xor) +_DEFINE_BINARY_OPERATOR(&, __bitwise_and) +_DEFINE_BINARY_OPERATOR(|, __bitwise_or) +_DEFINE_BINARY_OPERATOR(<<, __shift_left) +_DEFINE_BINARY_OPERATOR(>>, __shift_right) +_DEFINE_BINARY_OPERATOR(&&, __logical_and) +_DEFINE_BINARY_OPERATOR(||, __logical_or) +_DEFINE_BINARY_OPERATOR(==, __equal_to) +_DEFINE_BINARY_OPERATOR(!=, __not_equal_to) +_DEFINE_BINARY_OPERATOR(<, __less) +_DEFINE_BINARY_OPERATOR(>, __greater) +_DEFINE_BINARY_OPERATOR(<=, __less_equal) +_DEFINE_BINARY_OPERATOR(>=, __greater_equal) } // namespace std diff --git a/contrib/libstdc++/include/std/std_vector.h b/contrib/libstdc++/include/std/std_vector.h index 4120aa9e3be2..5738ef7ade89 100644 --- a/contrib/libstdc++/include/std/std_vector.h +++ b/contrib/libstdc++/include/std/std_vector.h @@ -71,8 +71,9 @@ #include <bits/stl_vector.h> #include <bits/stl_bvector.h> +#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT +# include <bits/vector.tcc> +#endif + #endif /* _CPP_VECTOR */ -// Local Variables: -// mode:C++ -// End: |
