summaryrefslogtreecommitdiffstats
path: root/contrib/libstdc++/include/std
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libstdc++/include/std')
-rw-r--r--contrib/libstdc++/include/std/std_algorithm.h7
-rw-r--r--contrib/libstdc++/include/std/std_bitset.h1171
-rw-r--r--contrib/libstdc++/include/std/std_complex.h605
-rw-r--r--contrib/libstdc++/include/std/std_deque.h7
-rw-r--r--contrib/libstdc++/include/std/std_fstream.h167
-rw-r--r--contrib/libstdc++/include/std/std_functional.h7
-rw-r--r--contrib/libstdc++/include/std/std_iomanip.h20
-rw-r--r--contrib/libstdc++/include/std/std_ios.h11
-rw-r--r--contrib/libstdc++/include/std/std_iosfwd.h20
-rw-r--r--contrib/libstdc++/include/std/std_iostream.h21
-rw-r--r--contrib/libstdc++/include/std/std_istream.h150
-rw-r--r--contrib/libstdc++/include/std/std_iterator.h7
-rw-r--r--contrib/libstdc++/include/std/std_limits.h45
-rw-r--r--contrib/libstdc++/include/std/std_list.h7
-rw-r--r--contrib/libstdc++/include/std/std_locale.h5
-rw-r--r--contrib/libstdc++/include/std/std_map.h7
-rw-r--r--contrib/libstdc++/include/std/std_memory.h21
-rw-r--r--contrib/libstdc++/include/std/std_numeric.h7
-rw-r--r--contrib/libstdc++/include/std/std_ostream.h201
-rw-r--r--contrib/libstdc++/include/std/std_queue.h7
-rw-r--r--contrib/libstdc++/include/std/std_set.h7
-rw-r--r--contrib/libstdc++/include/std/std_sstream.h124
-rw-r--r--contrib/libstdc++/include/std/std_stack.h7
-rw-r--r--contrib/libstdc++/include/std/std_stdexcept.h20
-rw-r--r--contrib/libstdc++/include/std/std_streambuf.h75
-rw-r--r--contrib/libstdc++/include/std/std_string.h17
-rw-r--r--contrib/libstdc++/include/std/std_utility.h7
-rw-r--r--contrib/libstdc++/include/std/std_valarray.h338
-rw-r--r--contrib/libstdc++/include/std/std_vector.h7
29 files changed, 1765 insertions, 1330 deletions
diff --git a/contrib/libstdc++/include/std/std_algorithm.h b/contrib/libstdc++/include/std/std_algorithm.h
index 40e6246..7ffbf97 100644
--- a/contrib/libstdc++/include/std/std_algorithm.h
+++ b/contrib/libstdc++/include/std/std_algorithm.h
@@ -15,7 +15,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -53,9 +53,8 @@
* purpose. It is provided "as is" without express or implied warranty.
*/
-/** @file algorithm
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
+/** @file include/algorithm
+ * This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_ALGORITHM
diff --git a/contrib/libstdc++/include/std/std_bitset.h b/contrib/libstdc++/include/std/std_bitset.h
index 01e3f90..860e775 100644
--- a/contrib/libstdc++/include/std/std_bitset.h
+++ b/contrib/libstdc++/include/std/std_bitset.h
@@ -1,6 +1,7 @@
// <bitset> -*- C++ -*-
-// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006
+// 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
@@ -15,7 +16,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -40,9 +41,8 @@
* purpose. It is provided "as is" without express or implied warranty.
*/
-/** @file bitset
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
+/** @file include/bitset
+ * This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_BITSET
@@ -61,10 +61,11 @@
#define _GLIBCXX_BITSET_BITS_PER_WORD numeric_limits<unsigned long>::digits
#define _GLIBCXX_BITSET_WORDS(__n) \
- ((__n) < 1 ? 0 : ((__n) + _GLIBCXX_BITSET_BITS_PER_WORD - 1)/_GLIBCXX_BITSET_BITS_PER_WORD)
+ ((__n) < 1 ? 0 : ((__n) + _GLIBCXX_BITSET_BITS_PER_WORD - 1) \
+ / _GLIBCXX_BITSET_BITS_PER_WORD)
+
+_GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD)
-namespace _GLIBCXX_STD
-{
/**
* @if maint
* Base class, general case. It is a class inveriant that _Nw will be
@@ -81,7 +82,9 @@ namespace _GLIBCXX_STD
/// 0 is the least significant word.
_WordT _M_w[_Nw];
- _Base_bitset() { _M_do_reset(); }
+ _Base_bitset()
+ { _M_do_reset(); }
+
_Base_bitset(unsigned long __val)
{
_M_do_reset();
@@ -113,10 +116,12 @@ namespace _GLIBCXX_STD
{ return _M_w[_S_whichword(__pos)]; }
_WordT&
- _M_hiword() { return _M_w[_Nw - 1]; }
+ _M_hiword()
+ { return _M_w[_Nw - 1]; }
_WordT
- _M_hiword() const { return _M_w[_Nw - 1]; }
+ _M_hiword() const
+ { return _M_w[_Nw - 1]; }
void
_M_do_and(const _Base_bitset<_Nw>& __x)
@@ -160,7 +165,8 @@ namespace _GLIBCXX_STD
}
void
- _M_do_reset() { memset(_M_w, 0, _Nw * sizeof(_WordT)); }
+ _M_do_reset()
+ { std::memset(_M_w, 0, _Nw * sizeof(_WordT)); }
bool
_M_is_equal(const _Base_bitset<_Nw>& __x) const
@@ -220,10 +226,11 @@ namespace _GLIBCXX_STD
_M_w[__n] = _M_w[__n - __wshift];
else
{
- const size_t __sub_offset = _GLIBCXX_BITSET_BITS_PER_WORD - __offset;
+ const size_t __sub_offset = (_GLIBCXX_BITSET_BITS_PER_WORD
+ - __offset);
for (size_t __n = _Nw - 1; __n > __wshift; --__n)
- _M_w[__n] = (_M_w[__n - __wshift] << __offset) |
- (_M_w[__n - __wshift - 1] >> __sub_offset);
+ _M_w[__n] = ((_M_w[__n - __wshift] << __offset)
+ | (_M_w[__n - __wshift - 1] >> __sub_offset));
_M_w[__wshift] = _M_w[0] << __offset;
}
@@ -246,10 +253,11 @@ namespace _GLIBCXX_STD
_M_w[__n] = _M_w[__n + __wshift];
else
{
- const size_t __sub_offset = _GLIBCXX_BITSET_BITS_PER_WORD - __offset;
+ const size_t __sub_offset = (_GLIBCXX_BITSET_BITS_PER_WORD
+ - __offset);
for (size_t __n = 0; __n < __limit; ++__n)
- _M_w[__n] = (_M_w[__n + __wshift] >> __offset) |
- (_M_w[__n + __wshift + 1] << __sub_offset);
+ _M_w[__n] = ((_M_w[__n + __wshift] >> __offset)
+ | (_M_w[__n + __wshift + 1] << __sub_offset));
_M_w[__limit] = _M_w[_Nw-1] >> __offset;
}
@@ -275,8 +283,8 @@ namespace _GLIBCXX_STD
{
_WordT __thisword = _M_w[__i];
if (__thisword != static_cast<_WordT>(0))
- return __i * _GLIBCXX_BITSET_BITS_PER_WORD
- + __builtin_ctzl(__thisword);
+ return (__i * _GLIBCXX_BITSET_BITS_PER_WORD
+ + __builtin_ctzl(__thisword));
}
// not found, so return an indication of failure.
return __not_found;
@@ -301,23 +309,22 @@ namespace _GLIBCXX_STD
__thisword &= (~static_cast<_WordT>(0)) << _S_whichbit(__prev);
if (__thisword != static_cast<_WordT>(0))
- return __i * _GLIBCXX_BITSET_BITS_PER_WORD
- + __builtin_ctzl(__thisword);
+ return (__i * _GLIBCXX_BITSET_BITS_PER_WORD
+ + __builtin_ctzl(__thisword));
// check subsequent words
__i++;
- for ( ; __i < _Nw; __i++ )
+ for (; __i < _Nw; __i++)
{
__thisword = _M_w[__i];
if (__thisword != static_cast<_WordT>(0))
- return __i * _GLIBCXX_BITSET_BITS_PER_WORD
- + __builtin_ctzl(__thisword);
+ return (__i * _GLIBCXX_BITSET_BITS_PER_WORD
+ + __builtin_ctzl(__thisword));
}
// not found, so return an indication of failure.
return __not_found;
} // end _M_do_find_next
-
/**
* @if maint
* Base class, specialization for a single word.
@@ -331,8 +338,13 @@ namespace _GLIBCXX_STD
typedef unsigned long _WordT;
_WordT _M_w;
- _Base_bitset( void ) : _M_w(0) {}
- _Base_bitset(unsigned long __val) : _M_w(__val) {}
+ _Base_bitset(void)
+ : _M_w(0)
+ { }
+
+ _Base_bitset(unsigned long __val)
+ : _M_w(__val)
+ { }
static size_t
_S_whichword(size_t __pos )
@@ -351,53 +363,68 @@ namespace _GLIBCXX_STD
{ return (static_cast<_WordT>(1)) << _S_whichbit(__pos); }
_WordT&
- _M_getword(size_t) { return _M_w; }
+ _M_getword(size_t)
+ { return _M_w; }
_WordT
- _M_getword(size_t) const { return _M_w; }
+ _M_getword(size_t) const
+ { return _M_w; }
_WordT&
- _M_hiword() { return _M_w; }
+ _M_hiword()
+ { return _M_w; }
_WordT
- _M_hiword() const { return _M_w; }
+ _M_hiword() const
+ { return _M_w; }
void
- _M_do_and(const _Base_bitset<1>& __x) { _M_w &= __x._M_w; }
+ _M_do_and(const _Base_bitset<1>& __x)
+ { _M_w &= __x._M_w; }
void
- _M_do_or(const _Base_bitset<1>& __x) { _M_w |= __x._M_w; }
+ _M_do_or(const _Base_bitset<1>& __x)
+ { _M_w |= __x._M_w; }
void
- _M_do_xor(const _Base_bitset<1>& __x) { _M_w ^= __x._M_w; }
+ _M_do_xor(const _Base_bitset<1>& __x)
+ { _M_w ^= __x._M_w; }
void
- _M_do_left_shift(size_t __shift) { _M_w <<= __shift; }
+ _M_do_left_shift(size_t __shift)
+ { _M_w <<= __shift; }
void
- _M_do_right_shift(size_t __shift) { _M_w >>= __shift; }
+ _M_do_right_shift(size_t __shift)
+ { _M_w >>= __shift; }
void
- _M_do_flip() { _M_w = ~_M_w; }
+ _M_do_flip()
+ { _M_w = ~_M_w; }
void
- _M_do_set() { _M_w = ~static_cast<_WordT>(0); }
+ _M_do_set()
+ { _M_w = ~static_cast<_WordT>(0); }
void
- _M_do_reset() { _M_w = 0; }
+ _M_do_reset()
+ { _M_w = 0; }
bool
_M_is_equal(const _Base_bitset<1>& __x) const
{ return _M_w == __x._M_w; }
bool
- _M_is_any() const { return _M_w != 0; }
+ _M_is_any() const
+ { return _M_w != 0; }
size_t
- _M_do_count() const { return __builtin_popcountl(_M_w); }
+ _M_do_count() const
+ { return __builtin_popcountl(_M_w); }
unsigned long
- _M_do_to_ulong() const { return _M_w; }
+ _M_do_to_ulong() const
+ { return _M_w; }
size_t
_M_do_find_first(size_t __not_found) const
@@ -424,7 +451,6 @@ namespace _GLIBCXX_STD
}
};
-
/**
* @if maint
* Base class, specialization for no storage (zero-length %bitset).
@@ -437,8 +463,11 @@ namespace _GLIBCXX_STD
{
typedef unsigned long _WordT;
- _Base_bitset() {}
- _Base_bitset(unsigned long) {}
+ _Base_bitset()
+ { }
+
+ _Base_bitset(unsigned long)
+ { }
static size_t
_S_whichword(size_t __pos )
@@ -471,54 +500,69 @@ namespace _GLIBCXX_STD
}
_WordT
- _M_hiword() const { return 0; }
+ _M_hiword() const
+ { return 0; }
void
- _M_do_and(const _Base_bitset<0>&) { }
+ _M_do_and(const _Base_bitset<0>&)
+ { }
void
- _M_do_or(const _Base_bitset<0>&) { }
+ _M_do_or(const _Base_bitset<0>&)
+ { }
void
- _M_do_xor(const _Base_bitset<0>&) { }
+ _M_do_xor(const _Base_bitset<0>&)
+ { }
void
- _M_do_left_shift(size_t) { }
+ _M_do_left_shift(size_t)
+ { }
void
- _M_do_right_shift(size_t) { }
+ _M_do_right_shift(size_t)
+ { }
void
- _M_do_flip() { }
+ _M_do_flip()
+ { }
void
- _M_do_set() { }
+ _M_do_set()
+ { }
void
- _M_do_reset() { }
+ _M_do_reset()
+ { }
// Are all empty bitsets equal to each other? Are they equal to
// themselves? How to compare a thing which has no state? What is
// the sound of one zero-length bitset clapping?
bool
- _M_is_equal(const _Base_bitset<0>&) const { return true; }
+ _M_is_equal(const _Base_bitset<0>&) const
+ { return true; }
bool
- _M_is_any() const { return false; }
+ _M_is_any() const
+ { return false; }
size_t
- _M_do_count() const { return 0; }
+ _M_do_count() const
+ { return 0; }
unsigned long
- _M_do_to_ulong() const { return 0; }
+ _M_do_to_ulong() const
+ { return 0; }
// Normally "not found" is the size, but that could also be
// misinterpreted as an index in this corner case. Oh well.
size_t
- _M_do_find_first(size_t) const { return 0; }
+ _M_do_find_first(size_t) const
+ { return 0; }
size_t
- _M_do_find_next(size_t, size_t) const { return 0; }
+ _M_do_find_next(size_t, size_t) const
+ { return 0; }
};
@@ -532,8 +576,7 @@ namespace _GLIBCXX_STD
template<>
struct _Sanitize<0>
- { static void _S_do_sanitize(unsigned long) { } };
-
+ { static void _S_do_sanitize(unsigned long) {} };
/**
* @brief The %bitset class represents a @e fixed-size sequence of bits.
@@ -600,508 +643,540 @@ namespace _GLIBCXX_STD
* @endif
*/
template<size_t _Nb>
- class bitset : private _Base_bitset<_GLIBCXX_BITSET_WORDS(_Nb)>
- {
- private:
- typedef _Base_bitset<_GLIBCXX_BITSET_WORDS(_Nb)> _Base;
- typedef unsigned long _WordT;
-
- void
- _M_do_sanitize()
+ class bitset
+ : private _Base_bitset<_GLIBCXX_BITSET_WORDS(_Nb)>
{
- _Sanitize<_Nb%_GLIBCXX_BITSET_BITS_PER_WORD>::
- _S_do_sanitize(this->_M_hiword());
- }
+ private:
+ typedef _Base_bitset<_GLIBCXX_BITSET_WORDS(_Nb)> _Base;
+ typedef unsigned long _WordT;
- public:
- /**
- * This encapsulates the concept of a single bit. An instance of this
- * class is a proxy for an actual bit; this way the individual bit
- * operations are done as faster word-size bitwise instructions.
- *
- * Most users will never need to use this class directly; conversions
- * to and from bool are automatic and should be transparent. Overloaded
- * operators help to preserve the illusion.
- *
- * (On a typical system, this "bit %reference" is 64 times the size of
- * an actual bit. Ha.)
- */
- class reference
- {
- friend class bitset;
+ void
+ _M_do_sanitize()
+ {
+ _Sanitize<_Nb % _GLIBCXX_BITSET_BITS_PER_WORD>::
+ _S_do_sanitize(this->_M_hiword());
+ }
+
+ public:
+ /**
+ * This encapsulates the concept of a single bit. An instance of this
+ * class is a proxy for an actual bit; this way the individual bit
+ * operations are done as faster word-size bitwise instructions.
+ *
+ * Most users will never need to use this class directly; conversions
+ * to and from bool are automatic and should be transparent. Overloaded
+ * operators help to preserve the illusion.
+ *
+ * (On a typical system, this "bit %reference" is 64 times the size of
+ * an actual bit. Ha.)
+ */
+ class reference
+ {
+ friend class bitset;
+
+ _WordT *_M_wp;
+ size_t _M_bpos;
+
+ // left undefined
+ reference();
+
+ public:
+ reference(bitset& __b, size_t __pos)
+ {
+ _M_wp = &__b._M_getword(__pos);
+ _M_bpos = _Base::_S_whichbit(__pos);
+ }
- _WordT *_M_wp;
- size_t _M_bpos;
+ ~reference()
+ { }
- // left undefined
- reference();
+ // For b[i] = __x;
+ reference&
+ operator=(bool __x)
+ {
+ if (__x)
+ *_M_wp |= _Base::_S_maskbit(_M_bpos);
+ else
+ *_M_wp &= ~_Base::_S_maskbit(_M_bpos);
+ return *this;
+ }
- public:
- reference(bitset& __b, size_t __pos)
+ // For b[i] = b[__j];
+ reference&
+ operator=(const reference& __j)
+ {
+ if ((*(__j._M_wp) & _Base::_S_maskbit(__j._M_bpos)))
+ *_M_wp |= _Base::_S_maskbit(_M_bpos);
+ else
+ *_M_wp &= ~_Base::_S_maskbit(_M_bpos);
+ return *this;
+ }
+
+ // Flips the bit
+ bool
+ operator~() const
+ { return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) == 0; }
+
+ // For __x = b[i];
+ operator bool() const
+ { return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) != 0; }
+
+ // For b[i].flip();
+ reference&
+ flip()
+ {
+ *_M_wp ^= _Base::_S_maskbit(_M_bpos);
+ return *this;
+ }
+ };
+ friend class reference;
+
+ // 23.3.5.1 constructors:
+ /// All bits set to zero.
+ bitset()
+ { }
+
+ /// Initial bits bitwise-copied from a single word (others set to zero).
+ bitset(unsigned long __val)
+ : _Base(__val)
+ { _M_do_sanitize(); }
+
+ /**
+ * @brief Use a subset of a string.
+ * @param s A string of '0' and '1' characters.
+ * @param position Index of the first character in @a s to use;
+ * defaults to zero.
+ * @throw std::out_of_range If @a pos is bigger the size of @a s.
+ * @throw std::invalid_argument If a character appears in the string
+ * which is neither '0' nor '1'.
+ */
+ template<class _CharT, class _Traits, class _Alloc>
+ explicit
+ bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __s,
+ size_t __position = 0)
+ : _Base()
+ {
+ if (__position > __s.size())
+ __throw_out_of_range(__N("bitset::bitset initial position "
+ "not valid"));
+ _M_copy_from_string(__s, __position,
+ std::basic_string<_CharT, _Traits, _Alloc>::npos);
+ }
+
+ /**
+ * @brief Use a subset of a string.
+ * @param s A string of '0' and '1' characters.
+ * @param position Index of the first character in @a s to use.
+ * @param n The number of characters to copy.
+ * @throw std::out_of_range If @a pos is bigger the size of @a s.
+ * @throw std::invalid_argument If a character appears in the string
+ * which is neither '0' nor '1'.
+ */
+ template<class _CharT, class _Traits, class _Alloc>
+ bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __s,
+ size_t __position, size_t __n)
+ : _Base()
+ {
+ if (__position > __s.size())
+ __throw_out_of_range(__N("bitset::bitset initial position "
+ "not valid"));
+ _M_copy_from_string(__s, __position, __n);
+ }
+
+ // 23.3.5.2 bitset operations:
+ //@{
+ /**
+ * @brief Operations on bitsets.
+ * @param rhs A same-sized bitset.
+ *
+ * These should be self-explanatory.
+ */
+ bitset<_Nb>&
+ operator&=(const bitset<_Nb>& __rhs)
{
- _M_wp = &__b._M_getword(__pos);
- _M_bpos = _Base::_S_whichbit(__pos);
+ this->_M_do_and(__rhs);
+ return *this;
}
- ~reference() { }
+ bitset<_Nb>&
+ operator|=(const bitset<_Nb>& __rhs)
+ {
+ this->_M_do_or(__rhs);
+ return *this;
+ }
- // For b[i] = __x;
- reference&
- operator=(bool __x)
+ bitset<_Nb>&
+ operator^=(const bitset<_Nb>& __rhs)
+ {
+ this->_M_do_xor(__rhs);
+ return *this;
+ }
+ //@}
+
+ //@{
+ /**
+ * @brief Operations on bitsets.
+ * @param position The number of places to shift.
+ *
+ * These should be self-explanatory.
+ */
+ bitset<_Nb>&
+ operator<<=(size_t __position)
{
- if ( __x )
- *_M_wp |= _Base::_S_maskbit(_M_bpos);
+ if (__builtin_expect(__position < _Nb, 1))
+ {
+ this->_M_do_left_shift(__position);
+ this->_M_do_sanitize();
+ }
else
- *_M_wp &= ~_Base::_S_maskbit(_M_bpos);
+ this->_M_do_reset();
return *this;
}
- // For b[i] = b[__j];
- reference&
- operator=(const reference& __j)
+ bitset<_Nb>&
+ operator>>=(size_t __position)
{
- if ( (*(__j._M_wp) & _Base::_S_maskbit(__j._M_bpos)) )
- *_M_wp |= _Base::_S_maskbit(_M_bpos);
+ if (__builtin_expect(__position < _Nb, 1))
+ {
+ this->_M_do_right_shift(__position);
+ this->_M_do_sanitize();
+ }
else
- *_M_wp &= ~_Base::_S_maskbit(_M_bpos);
+ this->_M_do_reset();
+ return *this;
+ }
+ //@}
+
+ //@{
+ /**
+ * These versions of single-bit set, reset, flip, and test are
+ * extensions from the SGI version. They do no range checking.
+ * @ingroup SGIextensions
+ */
+ bitset<_Nb>&
+ _Unchecked_set(size_t __pos)
+ {
+ this->_M_getword(__pos) |= _Base::_S_maskbit(__pos);
return *this;
}
- // Flips the bit
- bool
- operator~() const
- { return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) == 0; }
-
- // For __x = b[i];
- operator bool() const
- { return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) != 0; }
-
- // For b[i].flip();
- reference&
- flip()
+ bitset<_Nb>&
+ _Unchecked_set(size_t __pos, int __val)
{
- *_M_wp ^= _Base::_S_maskbit(_M_bpos);
+ if (__val)
+ this->_M_getword(__pos) |= _Base::_S_maskbit(__pos);
+ else
+ this->_M_getword(__pos) &= ~_Base::_S_maskbit(__pos);
return *this;
}
- };
- friend class reference;
-
- // 23.3.5.1 constructors:
- /// All bits set to zero.
- bitset() { }
-
- /// Initial bits bitwise-copied from a single word (others set to zero).
- bitset(unsigned long __val) : _Base(__val)
- { _M_do_sanitize(); }
-
- /**
- * @brief Use a subset of a string.
- * @param s A string of '0' and '1' characters.
- * @param position Index of the first character in @a s to use; defaults
- * to zero.
- * @throw std::out_of_range If @a pos is bigger the size of @a s.
- * @throw std::invalid_argument If a character appears in the string
- * which is neither '0' nor '1'.
- */
- template<class _CharT, class _Traits, class _Alloc>
- explicit bitset(const basic_string<_CharT, _Traits, _Alloc>& __s,
- size_t __position = 0) : _Base()
+
+ bitset<_Nb>&
+ _Unchecked_reset(size_t __pos)
{
- if (__position > __s.size())
- __throw_out_of_range(__N("bitset::bitset initial position "
- "not valid"));
- _M_copy_from_string(__s, __position,
- basic_string<_CharT, _Traits, _Alloc>::npos);
+ this->_M_getword(__pos) &= ~_Base::_S_maskbit(__pos);
+ return *this;
}
- /**
- * @brief Use a subset of a string.
- * @param s A string of '0' and '1' characters.
- * @param position Index of the first character in @a s to use.
- * @param n The number of characters to copy.
- * @throw std::out_of_range If @a pos is bigger the size of @a s.
- * @throw std::invalid_argument If a character appears in the string
- * which is neither '0' nor '1'.
- */
- template<class _CharT, class _Traits, class _Alloc>
- bitset(const basic_string<_CharT, _Traits, _Alloc>& __s,
- size_t __position, size_t __n) : _Base()
+ bitset<_Nb>&
+ _Unchecked_flip(size_t __pos)
{
- if (__position > __s.size())
- __throw_out_of_range(__N("bitset::bitset initial position "
- "not valid"));
- _M_copy_from_string(__s, __position, __n);
+ this->_M_getword(__pos) ^= _Base::_S_maskbit(__pos);
+ return *this;
}
- // 23.3.5.2 bitset operations:
- //@{
- /**
- * @brief Operations on bitsets.
- * @param rhs A same-sized bitset.
- *
- * These should be self-explanatory.
- */
- bitset<_Nb>&
- operator&=(const bitset<_Nb>& __rhs)
- {
- this->_M_do_and(__rhs);
- return *this;
- }
+ bool
+ _Unchecked_test(size_t __pos) const
+ { return ((this->_M_getword(__pos) & _Base::_S_maskbit(__pos))
+ != static_cast<_WordT>(0)); }
+ //@}
+
+ // Set, reset, and flip.
+ /**
+ * @brief Sets every bit to true.
+ */
+ bitset<_Nb>&
+ set()
+ {
+ this->_M_do_set();
+ this->_M_do_sanitize();
+ return *this;
+ }
- bitset<_Nb>&
- operator|=(const bitset<_Nb>& __rhs)
- {
- this->_M_do_or(__rhs);
- return *this;
- }
+ /**
+ * @brief Sets a given bit to a particular value.
+ * @param position The index of the bit.
+ * @param val Either true or false, defaults to true.
+ * @throw std::out_of_range If @a pos is bigger the size of the %set.
+ */
+ bitset<_Nb>&
+ set(size_t __position, bool __val = true)
+ {
+ if (__position >= _Nb)
+ __throw_out_of_range(__N("bitset::set"));
+ return _Unchecked_set(__position, __val);
+ }
- bitset<_Nb>&
- operator^=(const bitset<_Nb>& __rhs)
- {
- this->_M_do_xor(__rhs);
- return *this;
- }
- //@}
-
- //@{
- /**
- * @brief Operations on bitsets.
- * @param position The number of places to shift.
- *
- * These should be self-explanatory.
- */
- bitset<_Nb>&
- operator<<=(size_t __position)
- {
- if (__builtin_expect(__position < _Nb, 1))
- {
- this->_M_do_left_shift(__position);
- this->_M_do_sanitize();
- }
- else
+ /**
+ * @brief Sets every bit to false.
+ */
+ bitset<_Nb>&
+ reset()
+ {
this->_M_do_reset();
- return *this;
- }
+ return *this;
+ }
- bitset<_Nb>&
- operator>>=(size_t __position)
- {
- if (__builtin_expect(__position < _Nb, 1))
- {
- this->_M_do_right_shift(__position);
- this->_M_do_sanitize();
- }
- else
- this->_M_do_reset();
- return *this;
- }
- //@}
-
- //@{
- /**
- * These versions of single-bit set, reset, flip, and test are
- * extensions from the SGI version. They do no range checking.
- * @ingroup SGIextensions
- */
- bitset<_Nb>&
- _Unchecked_set(size_t __pos)
- {
- this->_M_getword(__pos) |= _Base::_S_maskbit(__pos);
- return *this;
- }
+ /**
+ * @brief Sets a given bit to false.
+ * @param position The index of the bit.
+ * @throw std::out_of_range If @a pos is bigger the size of the %set.
+ *
+ * Same as writing @c set(pos,false).
+ */
+ bitset<_Nb>&
+ reset(size_t __position)
+ {
+ if (__position >= _Nb)
+ __throw_out_of_range(__N("bitset::reset"));
+ return _Unchecked_reset(__position);
+ }
+
+ /**
+ * @brief Toggles every bit to its opposite value.
+ */
+ bitset<_Nb>&
+ flip()
+ {
+ this->_M_do_flip();
+ this->_M_do_sanitize();
+ return *this;
+ }
- bitset<_Nb>&
- _Unchecked_set(size_t __pos, int __val)
- {
- if (__val)
- this->_M_getword(__pos) |= _Base::_S_maskbit(__pos);
- else
- this->_M_getword(__pos) &= ~_Base::_S_maskbit(__pos);
- return *this;
- }
+ /**
+ * @brief Toggles a given bit to its opposite value.
+ * @param position The index of the bit.
+ * @throw std::out_of_range If @a pos is bigger the size of the %set.
+ */
+ bitset<_Nb>&
+ flip(size_t __position)
+ {
+ if (__position >= _Nb)
+ __throw_out_of_range(__N("bitset::flip"));
+ return _Unchecked_flip(__position);
+ }
+
+ /// See the no-argument flip().
+ bitset<_Nb>
+ operator~() const
+ { return bitset<_Nb>(*this).flip(); }
+
+ //@{
+ /**
+ * @brief Array-indexing support.
+ * @param position Index into the %bitset.
+ * @return A bool for a 'const %bitset'. For non-const bitsets, an
+ * instance of the reference proxy class.
+ * @note These operators do no range checking and throw no exceptions,
+ * as required by DR 11 to the standard.
+ *
+ * @if maint
+ * _GLIBCXX_RESOLVE_LIB_DEFECTS Note that this implementation already
+ * resolves DR 11 (items 1 and 2), but does not do the range-checking
+ * required by that DR's resolution. -pme
+ * The DR has since been changed: range-checking is a precondition
+ * (users' responsibility), and these functions must not throw. -pme
+ * @endif
+ */
+ reference
+ operator[](size_t __position)
+ { return reference(*this,__position); }
- bitset<_Nb>&
- _Unchecked_reset(size_t __pos)
- {
- this->_M_getword(__pos) &= ~_Base::_S_maskbit(__pos);
- return *this;
- }
+ bool
+ operator[](size_t __position) const
+ { return _Unchecked_test(__position); }
+ //@}
+
+ /**
+ * @brief Retuns a numerical interpretation of the %bitset.
+ * @return The integral equivalent of the bits.
+ * @throw std::overflow_error If there are too many bits to be
+ * represented in an @c unsigned @c long.
+ */
+ unsigned long
+ to_ulong() const
+ { return this->_M_do_to_ulong(); }
+
+ /**
+ * @brief Retuns a character interpretation of the %bitset.
+ * @return The string equivalent of the bits.
+ *
+ * Note the ordering of the bits: decreasing character positions
+ * correspond to increasing bit positions (see the main class notes for
+ * an example).
+ */
+ template<class _CharT, class _Traits, class _Alloc>
+ std::basic_string<_CharT, _Traits, _Alloc>
+ to_string() const
+ {
+ std::basic_string<_CharT, _Traits, _Alloc> __result;
+ _M_copy_to_string(__result);
+ return __result;
+ }
- bitset<_Nb>&
- _Unchecked_flip(size_t __pos)
- {
- this->_M_getword(__pos) ^= _Base::_S_maskbit(__pos);
- return *this;
- }
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 434. bitset::to_string() hard to use.
+ template<class _CharT, class _Traits>
+ std::basic_string<_CharT, _Traits, std::allocator<_CharT> >
+ to_string() const
+ { return to_string<_CharT, _Traits, std::allocator<_CharT> >(); }
+
+ template<class _CharT>
+ std::basic_string<_CharT, std::char_traits<_CharT>,
+ std::allocator<_CharT> >
+ to_string() const
+ {
+ return to_string<_CharT, std::char_traits<_CharT>,
+ std::allocator<_CharT> >();
+ }
- bool
- _Unchecked_test(size_t __pos) const
- {
- return (this->_M_getword(__pos) & _Base::_S_maskbit(__pos))
- != static_cast<_WordT>(0);
- }
- //@}
-
- // Set, reset, and flip.
- /**
- * @brief Sets every bit to true.
- */
- bitset<_Nb>&
- set()
- {
- this->_M_do_set();
- this->_M_do_sanitize();
- return *this;
- }
+ std::basic_string<char, std::char_traits<char>, std::allocator<char> >
+ to_string() const
+ {
+ return to_string<char, std::char_traits<char>,
+ std::allocator<char> >();
+ }
- /**
- * @brief Sets a given bit to a particular value.
- * @param position The index of the bit.
- * @param val Either true or false, defaults to true.
- * @throw std::out_of_range If @a pos is bigger the size of the %set.
- */
- bitset<_Nb>&
- set(size_t __position, bool __val = true)
- {
- if (__position >= _Nb)
- __throw_out_of_range(__N("bitset::set"));
- return _Unchecked_set(__position, __val);
- }
+ // Helper functions for string operations.
+ template<class _CharT, class _Traits, class _Alloc>
+ void
+ _M_copy_from_string(const std::basic_string<_CharT,
+ _Traits, _Alloc>& __s,
+ size_t, size_t);
- /**
- * @brief Sets every bit to false.
- */
- bitset<_Nb>&
- reset()
- {
- this->_M_do_reset();
- return *this;
- }
+ template<class _CharT, class _Traits, class _Alloc>
+ void
+ _M_copy_to_string(std::basic_string<_CharT, _Traits, _Alloc>&) const;
- /**
- * @brief Sets a given bit to false.
- * @param position The index of the bit.
- * @throw std::out_of_range If @a pos is bigger the size of the %set.
- *
- * Same as writing @c set(pos,false).
- */
- bitset<_Nb>&
- reset(size_t __position)
- {
- if (__position >= _Nb)
- __throw_out_of_range(__N("bitset::reset"));
- return _Unchecked_reset(__position);
- }
+ /// Returns the number of bits which are set.
+ size_t
+ count() const
+ { return this->_M_do_count(); }
- /**
- * @brief Toggles every bit to its opposite value.
- */
- bitset<_Nb>&
- flip()
- {
- this->_M_do_flip();
- this->_M_do_sanitize();
- return *this;
- }
+ /// Returns the total number of bits.
+ size_t
+ size() const
+ { return _Nb; }
- /**
- * @brief Toggles a given bit to its opposite value.
- * @param position The index of the bit.
- * @throw std::out_of_range If @a pos is bigger the size of the %set.
- */
- bitset<_Nb>&
- flip(size_t __position)
- {
- if (__position >= _Nb)
- __throw_out_of_range(__N("bitset::flip"));
- return _Unchecked_flip(__position);
- }
+ //@{
+ /// These comparisons for equality/inequality are, well, @e bitwise.
+ bool
+ operator==(const bitset<_Nb>& __rhs) const
+ { return this->_M_is_equal(__rhs); }
- /// See the no-argument flip().
- bitset<_Nb>
- operator~() const { return bitset<_Nb>(*this).flip(); }
-
- //@{
- /**
- * @brief Array-indexing support.
- * @param position Index into the %bitset.
- * @return A bool for a 'const %bitset'. For non-const bitsets, an
- * instance of the reference proxy class.
- * @note These operators do no range checking and throw no exceptions,
- * as required by DR 11 to the standard.
- *
- * @if maint
- * _GLIBCXX_RESOLVE_LIB_DEFECTS Note that this implementation already
- * resolves DR 11 (items 1 and 2), but does not do the range-checking
- * required by that DR's resolution. -pme
- * The DR has since been changed: range-checking is a precondition
- * (users' responsibility), and these functions must not throw. -pme
- * @endif
- */
- reference
- operator[](size_t __position) { return reference(*this,__position); }
-
- bool
- operator[](size_t __position) const { return _Unchecked_test(__position); }
- //@}
-
- /**
- * @brief Retuns a numerical interpretation of the %bitset.
- * @return The integral equivalent of the bits.
- * @throw std::overflow_error If there are too many bits to be
- * represented in an @c unsigned @c long.
- */
- unsigned long
- to_ulong() const { return this->_M_do_to_ulong(); }
-
- /**
- * @brief Retuns a character interpretation of the %bitset.
- * @return The string equivalent of the bits.
- *
- * Note the ordering of the bits: decreasing character positions
- * correspond to increasing bit positions (see the main class notes for
- * an example).
- *
- * Also note that you must specify the string's template parameters
- * explicitly. Given a bitset @c bs and a string @s:
- * @code
- * s = bs.to_string<char,char_traits<char>,allocator<char> >();
- * @endcode
- */
- template<class _CharT, class _Traits, class _Alloc>
- basic_string<_CharT, _Traits, _Alloc>
- to_string() const
+ bool
+ operator!=(const bitset<_Nb>& __rhs) const
+ { return !this->_M_is_equal(__rhs); }
+ //@}
+
+ /**
+ * @brief Tests the value of a bit.
+ * @param position The index of a bit.
+ * @return The value at @a pos.
+ * @throw std::out_of_range If @a pos is bigger the size of the %set.
+ */
+ bool
+ test(size_t __position) const
{
- basic_string<_CharT, _Traits, _Alloc> __result;
- _M_copy_to_string(__result);
- return __result;
+ if (__position >= _Nb)
+ __throw_out_of_range(__N("bitset::test"));
+ return _Unchecked_test(__position);
}
+
+ /**
+ * @brief Tests whether any of the bits are on.
+ * @return True if at least one bit is set.
+ */
+ bool
+ any() const
+ { return this->_M_is_any(); }
- // Helper functions for string operations.
- template<class _CharT, class _Traits, class _Alloc>
- void
- _M_copy_from_string(const basic_string<_CharT,_Traits,_Alloc>& __s,
- size_t, size_t);
-
- template<class _CharT, class _Traits, class _Alloc>
- void
- _M_copy_to_string(basic_string<_CharT,_Traits,_Alloc>&) const;
-
- /// Returns the number of bits which are set.
- size_t
- count() const { return this->_M_do_count(); }
-
- /// Returns the total number of bits.
- size_t
- size() const { return _Nb; }
-
- //@{
- /// These comparisons for equality/inequality are, well, @e bitwise.
- bool
- operator==(const bitset<_Nb>& __rhs) const
- { return this->_M_is_equal(__rhs); }
-
- bool
- operator!=(const bitset<_Nb>& __rhs) const
- { return !this->_M_is_equal(__rhs); }
- //@}
-
- /**
- * @brief Tests the value of a bit.
- * @param position The index of a bit.
- * @return The value at @a pos.
- * @throw std::out_of_range If @a pos is bigger the size of the %set.
- */
- bool
- test(size_t __position) const
- {
- if (__position >= _Nb)
- __throw_out_of_range(__N("bitset::test"));
- return _Unchecked_test(__position);
- }
-
- /**
- * @brief Tests whether any of the bits are on.
- * @return True if at least one bit is set.
- */
- bool
- any() const { return this->_M_is_any(); }
-
- /**
- * @brief Tests whether any of the bits are on.
- * @return True if none of the bits are set.
- */
- bool
- none() const { return !this->_M_is_any(); }
-
- //@{
- /// Self-explanatory.
- bitset<_Nb>
- operator<<(size_t __position) const
- { return bitset<_Nb>(*this) <<= __position; }
-
- bitset<_Nb>
- operator>>(size_t __position) const
- { return bitset<_Nb>(*this) >>= __position; }
- //@}
-
- /**
- * @brief Finds the index of the first "on" bit.
- * @return The index of the first bit set, or size() if not found.
- * @ingroup SGIextensions
- * @sa _Find_next
- */
- size_t
- _Find_first() const
- { return this->_M_do_find_first(_Nb); }
-
- /**
- * @brief Finds the index of the next "on" bit after prev.
- * @return The index of the next bit set, or size() if not found.
- * @param prev Where to start searching.
- * @ingroup SGIextensions
- * @sa _Find_first
- */
- size_t
- _Find_next(size_t __prev ) const
- { return this->_M_do_find_next(__prev, _Nb); }
- };
+ /**
+ * @brief Tests whether any of the bits are on.
+ * @return True if none of the bits are set.
+ */
+ bool
+ none() const
+ { return !this->_M_is_any(); }
+
+ //@{
+ /// Self-explanatory.
+ bitset<_Nb>
+ operator<<(size_t __position) const
+ { return bitset<_Nb>(*this) <<= __position; }
+
+ bitset<_Nb>
+ operator>>(size_t __position) const
+ { return bitset<_Nb>(*this) >>= __position; }
+ //@}
+
+ /**
+ * @brief Finds the index of the first "on" bit.
+ * @return The index of the first bit set, or size() if not found.
+ * @ingroup SGIextensions
+ * @sa _Find_next
+ */
+ size_t
+ _Find_first() const
+ { return this->_M_do_find_first(_Nb); }
+
+ /**
+ * @brief Finds the index of the next "on" bit after prev.
+ * @return The index of the next bit set, or size() if not found.
+ * @param prev Where to start searching.
+ * @ingroup SGIextensions
+ * @sa _Find_first
+ */
+ size_t
+ _Find_next(size_t __prev ) const
+ { return this->_M_do_find_next(__prev, _Nb); }
+ };
// Definitions of non-inline member functions.
template<size_t _Nb>
template<class _CharT, class _Traits, class _Alloc>
- void
- bitset<_Nb>::_M_copy_from_string(const basic_string<_CharT, _Traits,
- _Alloc>& __s, size_t __pos, size_t __n)
- {
- reset();
- const size_t __nbits = std::min(_Nb, std::min(__n, __s.size() - __pos));
- for (size_t __i = 0; __i < __nbits; ++__i)
- {
- switch(__s[__pos + __nbits - __i - 1])
- {
- case '0':
- break;
- case '1':
- set(__i);
- break;
- default:
- __throw_invalid_argument(__N("bitset::_M_copy_from_string"));
- }
- }
- }
+ void
+ bitset<_Nb>::
+ _M_copy_from_string(const std::basic_string<_CharT, _Traits,
+ _Alloc>& __s, size_t __pos, size_t __n)
+ {
+ reset();
+ const size_t __nbits = std::min(_Nb, std::min(__n, __s.size() - __pos));
+ for (size_t __i = __nbits; __i > 0; --__i)
+ {
+ switch(__s[__pos + __nbits - __i])
+ {
+ case '0':
+ break;
+ case '1':
+ _Unchecked_set(__i - 1);
+ break;
+ default:
+ __throw_invalid_argument(__N("bitset::_M_copy_from_string"));
+ }
+ }
+ }
template<size_t _Nb>
template<class _CharT, class _Traits, class _Alloc>
- void
- bitset<_Nb>::_M_copy_to_string(basic_string<_CharT, _Traits,
- _Alloc>& __s) const
- {
- __s.assign(_Nb, '0');
- for (size_t __i = 0; __i < _Nb; ++__i)
- if (_Unchecked_test(__i))
- __s[_Nb - 1 - __i] = '1';
- }
+ void
+ bitset<_Nb>::
+ _M_copy_to_string(std::basic_string<_CharT, _Traits, _Alloc>& __s) const
+ {
+ __s.assign(_Nb, '0');
+ for (size_t __i = _Nb; __i > 0; --__i)
+ if (_Unchecked_test(__i - 1))
+ __s[_Nb - __i] = '1';
+ }
// 23.3.5.3 bitset operations:
//@{
@@ -1151,15 +1226,15 @@ namespace _GLIBCXX_STD
* hold.
*/
template<class _CharT, class _Traits, size_t _Nb>
- basic_istream<_CharT, _Traits>&
- operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x)
+ std::basic_istream<_CharT, _Traits>&
+ operator>>(std::basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x)
{
typedef typename _Traits::char_type char_type;
- basic_string<_CharT, _Traits> __tmp;
+ std::basic_string<_CharT, _Traits> __tmp;
__tmp.reserve(_Nb);
- ios_base::iostate __state = ios_base::goodbit;
- typename basic_istream<_CharT, _Traits>::sentry __sentry(__is);
+ std::ios_base::iostate __state = std::ios_base::goodbit;
+ typename std::basic_istream<_CharT, _Traits>::sentry __sentry(__is);
if (__sentry)
{
try
@@ -1169,19 +1244,19 @@ namespace _GLIBCXX_STD
// 303. Bitset input operator underspecified
const char_type __zero = __is.widen('0');
const char_type __one = __is.widen('1');
- for (size_t __i = 0; __i < _Nb; ++__i)
+ for (size_t __i = _Nb; __i > 0; --__i)
{
static typename _Traits::int_type __eof = _Traits::eof();
typename _Traits::int_type __c1 = __buf->sbumpc();
if (_Traits::eq_int_type(__c1, __eof))
{
- __state |= ios_base::eofbit;
+ __state |= std::ios_base::eofbit;
break;
}
else
{
- char_type __c2 = _Traits::to_char_type(__c1);
+ const char_type __c2 = _Traits::to_char_type(__c1);
if (__c2 == __zero)
__tmp.push_back('0');
else if (__c2 == __one)
@@ -1189,18 +1264,18 @@ namespace _GLIBCXX_STD
else if (_Traits::eq_int_type(__buf->sputbackc(__c2),
__eof))
{
- __state |= ios_base::failbit;
+ __state |= std::ios_base::failbit;
break;
}
}
}
}
catch(...)
- { __is._M_setstate(ios_base::badbit); }
+ { __is._M_setstate(std::ios_base::badbit); }
}
if (__tmp.empty() && _Nb)
- __state |= ios_base::failbit;
+ __state |= std::ios_base::failbit;
else
__x._M_copy_from_string(__tmp, static_cast<size_t>(0), _Nb);
if (__state)
@@ -1209,15 +1284,55 @@ namespace _GLIBCXX_STD
}
template <class _CharT, class _Traits, size_t _Nb>
- basic_ostream<_CharT, _Traits>&
- operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Nb>& __x)
+ std::basic_ostream<_CharT, _Traits>&
+ operator<<(std::basic_ostream<_CharT, _Traits>& __os,
+ const bitset<_Nb>& __x)
{
- basic_string<_CharT, _Traits> __tmp;
+ std::basic_string<_CharT, _Traits> __tmp;
__x._M_copy_to_string(__tmp);
return __os << __tmp;
}
+
+ // Specializations for zero-sized bitsets, to avoid "unsigned comparison
+ // with zero" warnings.
+ template<>
+ inline bitset<0>&
+ bitset<0>::
+ set(size_t, bool)
+ {
+ __throw_out_of_range(__N("bitset::set"));
+ return *this;
+ }
+
+ template<>
+ inline bitset<0>&
+ bitset<0>::
+ reset(size_t)
+ {
+ __throw_out_of_range(__N("bitset::reset"));
+ return *this;
+ }
+
+ template<>
+ inline bitset<0>&
+ bitset<0>::
+ flip(size_t)
+ {
+ __throw_out_of_range(__N("bitset::flip"));
+ return *this;
+ }
+
+ template<>
+ inline bool
+ bitset<0>::
+ test(size_t) const
+ {
+ __throw_out_of_range(__N("bitset::test"));
+ return false;
+ }
//@}
-} // namespace std
+
+_GLIBCXX_END_NESTED_NAMESPACE
#undef _GLIBCXX_BITSET_WORDS
#undef _GLIBCXX_BITSET_BITS_PER_WORD
diff --git a/contrib/libstdc++/include/std/std_complex.h b/contrib/libstdc++/include/std/std_complex.h
index 244ed28..26f31f6 100644
--- a/contrib/libstdc++/include/std/std_complex.h
+++ b/contrib/libstdc++/include/std/std_complex.h
@@ -16,7 +16,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -28,6 +28,10 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
+/** @file complex
+ * This is a Standard C++ Library header.
+ */
+
//
// ISO C++ 14882: 26.2 Complex Numbers
// Note: this is not a conforming implementation.
@@ -35,11 +39,6 @@
// Improved by Gabriel Dos Reis <dosreis@cmla.ens-cachan.fr>
//
-/** @file complex
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
- */
-
#ifndef _GLIBCXX_COMPLEX
#define _GLIBCXX_COMPLEX 1
@@ -50,9 +49,9 @@
#include <cmath>
#include <sstream>
-namespace std
-{
- // Forward declarations
+_GLIBCXX_BEGIN_NAMESPACE(std)
+
+ // Forward declarations.
template<typename _Tp> class complex;
template<> class complex<float>;
template<> class complex<double>;
@@ -87,7 +86,7 @@ namespace std
template<typename _Tp> complex<_Tp> pow(const complex<_Tp>&, const _Tp&);
/// Return @a x to the @a y'th power.
template<typename _Tp> complex<_Tp> pow(const complex<_Tp>&,
- const complex<_Tp>&);
+ const complex<_Tp>&);
/// Return @a x to the @a y'th power.
template<typename _Tp> complex<_Tp> pow(const _Tp&, const complex<_Tp>&);
/// Return complex sine of @a z.
@@ -113,9 +112,8 @@ namespace std
* @param Tp Type of real and imaginary values.
*/
template<typename _Tp>
- class complex
+ struct complex
{
- public:
/// Value typedef.
typedef _Tp value_type;
@@ -168,6 +166,8 @@ namespace std
template<typename _Up>
complex<_Tp>& operator/=(const complex<_Up>&);
+ const complex& __rep() const;
+
private:
_Tp _M_real;
_Tp _M_imag;
@@ -305,6 +305,10 @@ namespace std
_M_real = __r / __n;
return *this;
}
+
+ template<typename _Tp>
+ inline const complex<_Tp>&
+ complex<_Tp>::__rep() const { return *this; }
// Operators:
//@{
@@ -542,9 +546,10 @@ namespace std
imag(const complex<_Tp>& __z)
{ return __z.imag(); }
+ // 26.2.7/3 abs(__z): Returns the magnitude of __z.
template<typename _Tp>
inline _Tp
- abs(const complex<_Tp>& __z)
+ __complex_abs(const complex<_Tp>& __z)
{
_Tp __x = __z.real();
_Tp __y = __z.imag();
@@ -556,10 +561,52 @@ namespace std
return __s * sqrt(__x * __x + __y * __y);
}
+#if _GLIBCXX_USE_C99_COMPLEX
+ inline float
+ __complex_abs(__complex__ float __z) { return __builtin_cabsf(__z); }
+
+ inline double
+ __complex_abs(__complex__ double __z) { return __builtin_cabs(__z); }
+
+ inline long double
+ __complex_abs(const __complex__ long double& __z)
+ { return __builtin_cabsl(__z); }
+
+ template<typename _Tp>
+ inline _Tp
+ abs(const complex<_Tp>& __z) { return __complex_abs(__z.__rep()); }
+#else
template<typename _Tp>
inline _Tp
- arg(const complex<_Tp>& __z)
- { return atan2(__z.imag(), __z.real()); }
+ abs(const complex<_Tp>& __z) { return __complex_abs(__z); }
+#endif
+
+
+ // 26.2.7/4: arg(__z): Returns the phase angle of __z.
+ template<typename _Tp>
+ inline _Tp
+ __complex_arg(const complex<_Tp>& __z)
+ { return atan2(__z.imag(), __z.real()); }
+
+#if _GLIBCXX_USE_C99_COMPLEX
+ inline float
+ __complex_arg(__complex__ float __z) { return __builtin_cargf(__z); }
+
+ inline double
+ __complex_arg(__complex__ double __z) { return __builtin_carg(__z); }
+
+ inline long double
+ __complex_arg(const __complex__ long double& __z)
+ { return __builtin_cargl(__z); }
+
+ template<typename _Tp>
+ inline _Tp
+ arg(const complex<_Tp>& __z) { return __complex_arg(__z.__rep()); }
+#else
+ template<typename _Tp>
+ inline _Tp
+ arg(const complex<_Tp>& __z) { return __complex_arg(__z); }
+#endif
// 26.2.7/5: norm(__z) returns the squared magintude of __z.
// As defined, norm() is -not- a norm is the common mathematical
@@ -593,7 +640,8 @@ namespace std
inline _Tp
norm(const complex<_Tp>& __z)
{
- return _Norm_helper<__is_floating<_Tp>::_M_type && !_GLIBCXX_FAST_MATH>::_S_do_it(__z);
+ return _Norm_helper<__is_floating<_Tp>::__value
+ && !_GLIBCXX_FAST_MATH>::_S_do_it(__z);
}
template<typename _Tp>
@@ -607,60 +655,190 @@ namespace std
{ return complex<_Tp>(__z.real(), -__z.imag()); }
// Transcendentals
+
+ // 26.2.8/1 cos(__z): Returns the cosine of __z.
template<typename _Tp>
inline complex<_Tp>
- cos(const complex<_Tp>& __z)
+ __complex_cos(const complex<_Tp>& __z)
{
const _Tp __x = __z.real();
const _Tp __y = __z.imag();
return complex<_Tp>(cos(__x) * cosh(__y), -sin(__x) * sinh(__y));
}
+#if _GLIBCXX_USE_C99_COMPLEX
+ inline __complex__ float
+ __complex_cos(__complex__ float __z) { return __builtin_ccosf(__z); }
+
+ inline __complex__ double
+ __complex_cos(__complex__ double __z) { return __builtin_ccos(__z); }
+
+ inline __complex__ long double
+ __complex_cos(const __complex__ long double& __z)
+ { return __builtin_ccosl(__z); }
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ cos(const complex<_Tp>& __z) { return __complex_cos(__z.__rep()); }
+#else
+ template<typename _Tp>
+ inline complex<_Tp>
+ cos(const complex<_Tp>& __z) { return __complex_cos(__z); }
+#endif
+
+ // 26.2.8/2 cosh(__z): Returns the hyperbolic cosine of __z.
template<typename _Tp>
inline complex<_Tp>
- cosh(const complex<_Tp>& __z)
+ __complex_cosh(const complex<_Tp>& __z)
{
const _Tp __x = __z.real();
const _Tp __y = __z.imag();
return complex<_Tp>(cosh(__x) * cos(__y), sinh(__x) * sin(__y));
}
+#if _GLIBCXX_USE_C99_COMPLEX
+ inline __complex__ float
+ __complex_cosh(__complex__ float __z) { return __builtin_ccoshf(__z); }
+
+ inline __complex__ double
+ __complex_cosh(__complex__ double __z) { return __builtin_ccosh(__z); }
+
+ inline __complex__ long double
+ __complex_cosh(const __complex__ long double& __z)
+ { return __builtin_ccoshl(__z); }
+
template<typename _Tp>
inline complex<_Tp>
- exp(const complex<_Tp>& __z)
+ cosh(const complex<_Tp>& __z) { return __complex_cosh(__z.__rep()); }
+#else
+ template<typename _Tp>
+ inline complex<_Tp>
+ cosh(const complex<_Tp>& __z) { return __complex_cosh(__z); }
+#endif
+
+ // 26.2.8/3 exp(__z): Returns the complex base e exponential of x
+ template<typename _Tp>
+ inline complex<_Tp>
+ __complex_exp(const complex<_Tp>& __z)
{ return std::polar(exp(__z.real()), __z.imag()); }
+#if _GLIBCXX_USE_C99_COMPLEX
+ inline __complex__ float
+ __complex_exp(__complex__ float __z) { return __builtin_cexpf(__z); }
+
+ inline __complex__ double
+ __complex_exp(__complex__ double __z) { return __builtin_cexp(__z); }
+
+ inline __complex__ long double
+ __complex_exp(const __complex__ long double& __z)
+ { return __builtin_cexpl(__z); }
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ exp(const complex<_Tp>& __z) { return __complex_exp(__z.__rep()); }
+#else
template<typename _Tp>
inline complex<_Tp>
- log(const complex<_Tp>& __z)
+ exp(const complex<_Tp>& __z) { return __complex_exp(__z); }
+#endif
+
+ // 26.2.8/5 log(__z): Reurns the natural complex logaritm of __z.
+ // The branch cut is along the negative axis.
+ template<typename _Tp>
+ inline complex<_Tp>
+ __complex_log(const complex<_Tp>& __z)
{ return complex<_Tp>(log(std::abs(__z)), std::arg(__z)); }
+#if _GLIBCXX_USE_C99_COMPLEX
+ inline __complex__ float
+ __complex_log(__complex__ float __z) { return __builtin_clogf(__z); }
+
+ inline __complex__ double
+ __complex_log(__complex__ double __z) { return __builtin_clog(__z); }
+
+ inline __complex__ long double
+ __complex_log(const __complex__ long double& __z)
+ { return __builtin_clogl(__z); }
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ log(const complex<_Tp>& __z) { return __complex_log(__z.__rep()); }
+#else
+ template<typename _Tp>
+ inline complex<_Tp>
+ log(const complex<_Tp>& __z) { return __complex_log(__z); }
+#endif
+
template<typename _Tp>
inline complex<_Tp>
log10(const complex<_Tp>& __z)
{ return std::log(__z) / log(_Tp(10.0)); }
+ // 26.2.8/10 sin(__z): Returns the sine of __z.
template<typename _Tp>
inline complex<_Tp>
- sin(const complex<_Tp>& __z)
+ __complex_sin(const complex<_Tp>& __z)
{
const _Tp __x = __z.real();
const _Tp __y = __z.imag();
return complex<_Tp>(sin(__x) * cosh(__y), cos(__x) * sinh(__y));
}
+#if _GLIBCXX_USE_C99_COMPLEX
+ inline __complex__ float
+ __complex_sin(__complex__ float __z) { return __builtin_csinf(__z); }
+
+ inline __complex__ double
+ __complex_sin(__complex__ double __z) { return __builtin_csin(__z); }
+
+ inline __complex__ long double
+ __complex_sin(const __complex__ long double& __z)
+ { return __builtin_csinl(__z); }
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ sin(const complex<_Tp>& __z) { return __complex_sin(__z.__rep()); }
+#else
+ template<typename _Tp>
+ inline complex<_Tp>
+ sin(const complex<_Tp>& __z) { return __complex_sin(__z); }
+#endif
+
+ // 26.2.8/11 sinh(__z): Returns the hyperbolic sine of __z.
template<typename _Tp>
inline complex<_Tp>
- sinh(const complex<_Tp>& __z)
+ __complex_sinh(const complex<_Tp>& __z)
{
const _Tp __x = __z.real();
const _Tp __y = __z.imag();
return complex<_Tp>(sinh(__x) * cos(__y), cosh(__x) * sin(__y));
}
+#if _GLIBCXX_USE_C99_COMPLEX
+ inline __complex__ float
+ __complex_sinh(__complex__ float __z) { return __builtin_csinhf(__z); }
+
+ inline __complex__ double
+ __complex_sinh(__complex__ double __z) { return __builtin_csinh(__z); }
+
+ inline __complex__ long double
+ __complex_sinh(const __complex__ long double& __z)
+ { return __builtin_csinhl(__z); }
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ sinh(const complex<_Tp>& __z) { return __complex_sinh(__z.__rep()); }
+#else
+ template<typename _Tp>
+ inline complex<_Tp>
+ sinh(const complex<_Tp>& __z) { return __complex_sinh(__z); }
+#endif
+
+ // 26.2.8/13 sqrt(__z): Returns the complex square root of __z.
+ // The branch cut is on the negative axis.
template<typename _Tp>
complex<_Tp>
- sqrt(const complex<_Tp>& __z)
+ __complex_sqrt(const complex<_Tp>& __z)
{
_Tp __x = __z.real();
_Tp __y = __z.imag();
@@ -680,31 +858,98 @@ namespace std
}
}
+#if _GLIBCXX_USE_C99_COMPLEX
+ inline __complex__ float
+ __complex_sqrt(__complex__ float __z) { return __builtin_csqrtf(__z); }
+
+ inline __complex__ double
+ __complex_sqrt(__complex__ double __z) { return __builtin_csqrt(__z); }
+
+ inline __complex__ long double
+ __complex_sqrt(const __complex__ long double& __z)
+ { return __builtin_csqrtl(__z); }
+
template<typename _Tp>
inline complex<_Tp>
- tan(const complex<_Tp>& __z)
- {
- return std::sin(__z) / std::cos(__z);
- }
+ sqrt(const complex<_Tp>& __z) { return __complex_sqrt(__z.__rep()); }
+#else
+ template<typename _Tp>
+ inline complex<_Tp>
+ sqrt(const complex<_Tp>& __z) { return __complex_sqrt(__z); }
+#endif
+ // 26.2.8/14 tan(__z): Return the complex tangent of __z.
+
template<typename _Tp>
inline complex<_Tp>
- tanh(const complex<_Tp>& __z)
- {
- return std::sinh(__z) / std::cosh(__z);
- }
+ __complex_tan(const complex<_Tp>& __z)
+ { return std::sin(__z) / std::cos(__z); }
+
+#if _GLIBCXX_USE_C99_COMPLEX
+ inline __complex__ float
+ __complex_tan(__complex__ float __z) { return __builtin_ctanf(__z); }
+
+ inline __complex__ double
+ __complex_tan(__complex__ double __z) { return __builtin_ctan(__z); }
+
+ inline __complex__ long double
+ __complex_tan(const __complex__ long double& __z)
+ { return __builtin_ctanl(__z); }
template<typename _Tp>
inline complex<_Tp>
+ tan(const complex<_Tp>& __z) { return __complex_tan(__z.__rep()); }
+#else
+ template<typename _Tp>
+ inline complex<_Tp>
+ tan(const complex<_Tp>& __z) { return __complex_tan(__z); }
+#endif
+
+
+ // 26.2.8/15 tanh(__z): Returns the hyperbolic tangent of __z.
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ __complex_tanh(const complex<_Tp>& __z)
+ { return std::sinh(__z) / std::cosh(__z); }
+
+#if _GLIBCXX_USE_C99_COMPLEX
+ inline __complex__ float
+ __complex_tanh(__complex__ float __z) { return __builtin_ctanhf(__z); }
+
+ inline __complex__ double
+ __complex_tanh(__complex__ double __z) { return __builtin_ctanh(__z); }
+
+ inline __complex__ long double
+ __complex_tanh(const __complex__ long double& __z)
+ { return __builtin_ctanhl(__z); }
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ tanh(const complex<_Tp>& __z) { return __complex_tanh(__z.__rep()); }
+#else
+ template<typename _Tp>
+ inline complex<_Tp>
+ tanh(const complex<_Tp>& __z) { return __complex_tanh(__z); }
+#endif
+
+
+ // 26.2.8/9 pow(__x, __y): Returns the complex power base of __x
+ // raised to the __y-th power. The branch
+ // cut is on the negative axis.
+ template<typename _Tp>
+ inline complex<_Tp>
pow(const complex<_Tp>& __z, int __n)
- {
- return std::__pow_helper(__z, __n);
- }
+ { return std::__pow_helper(__z, __n); }
template<typename _Tp>
complex<_Tp>
pow(const complex<_Tp>& __x, const _Tp& __y)
{
+#ifndef _GLIBCXX_USE_C99_COMPLEX
+ if (__x == _Tp())
+ return _Tp();
+#endif
if (__x.imag() == _Tp() && __x.real() > _Tp())
return pow(__x.real(), __y);
@@ -714,10 +959,33 @@ namespace std
template<typename _Tp>
inline complex<_Tp>
+ __complex_pow(const complex<_Tp>& __x, const complex<_Tp>& __y)
+ { return __x == _Tp() ? _Tp() : std::exp(__y * std::log(__x)); }
+
+#if _GLIBCXX_USE_C99_COMPLEX
+ inline __complex__ float
+ __complex_pow(__complex__ float __x, __complex__ float __y)
+ { return __builtin_cpowf(__x, __y); }
+
+ inline __complex__ double
+ __complex_pow(__complex__ double __x, __complex__ double __y)
+ { return __builtin_cpow(__x, __y); }
+
+ inline __complex__ long double
+ __complex_pow(const __complex__ long double& __x,
+ const __complex__ long double& __y)
+ { return __builtin_cpowl(__x, __y); }
+
+ template<typename _Tp>
+ inline complex<_Tp>
pow(const complex<_Tp>& __x, const complex<_Tp>& __y)
- {
- return __x == _Tp() ? _Tp() : std::exp(__y * std::log(__x));
- }
+ { return __complex_pow(__x.__rep(), __y.__rep()); }
+#else
+ template<typename _Tp>
+ inline complex<_Tp>
+ pow(const complex<_Tp>& __x, const complex<_Tp>& __y)
+ { return __complex_pow(__x, __y); }
+#endif
template<typename _Tp>
inline complex<_Tp>
@@ -730,50 +998,49 @@ namespace std
// 26.2.3 complex specializations
// complex<float> specialization
- template<> class complex<float>
- {
- public:
- typedef float value_type;
-
- complex(float = 0.0f, float = 0.0f);
+ template<>
+ struct complex<float>
+ {
+ typedef float value_type;
+ typedef __complex__ float _ComplexT;
- explicit complex(const complex<double>&);
- explicit complex(const complex<long double>&);
+ complex(_ComplexT __z) : _M_value(__z) { }
- float& real();
- const float& real() const;
- float& imag();
- const float& imag() const;
+ complex(float = 0.0f, float = 0.0f);
- complex<float>& operator=(float);
- complex<float>& operator+=(float);
- complex<float>& operator-=(float);
- complex<float>& operator*=(float);
- complex<float>& operator/=(float);
-
- // Let's the compiler synthetize the copy and assignment
- // operator. It always does a pretty good job.
- // complex& operator= (const complex&);
- template<typename _Tp>
- complex<float>&operator=(const complex<_Tp>&);
- template<typename _Tp>
- complex<float>& operator+=(const complex<_Tp>&);
- template<class _Tp>
- complex<float>& operator-=(const complex<_Tp>&);
- template<class _Tp>
- complex<float>& operator*=(const complex<_Tp>&);
- template<class _Tp>
- complex<float>&operator/=(const complex<_Tp>&);
-
- private:
- typedef __complex__ float _ComplexT;
- _ComplexT _M_value;
-
- complex(_ComplexT __z) : _M_value(__z) { }
-
- friend class complex<double>;
- friend class complex<long double>;
- };
+ explicit complex(const complex<double>&);
+ explicit complex(const complex<long double>&);
+
+ float& real();
+ const float& real() const;
+ float& imag();
+ const float& imag() const;
+
+ complex<float>& operator=(float);
+ complex<float>& operator+=(float);
+ complex<float>& operator-=(float);
+ complex<float>& operator*=(float);
+ complex<float>& operator/=(float);
+
+ // Let's the compiler synthetize the copy and assignment
+ // operator. It always does a pretty good job.
+ // complex& operator= (const complex&);
+ template<typename _Tp>
+ complex<float>&operator=(const complex<_Tp>&);
+ template<typename _Tp>
+ complex<float>& operator+=(const complex<_Tp>&);
+ template<class _Tp>
+ complex<float>& operator-=(const complex<_Tp>&);
+ template<class _Tp>
+ complex<float>& operator*=(const complex<_Tp>&);
+ template<class _Tp>
+ complex<float>&operator/=(const complex<_Tp>&);
+
+ const _ComplexT& __rep() const { return _M_value; }
+
+ private:
+ _ComplexT _M_value;
+ };
inline float&
complex<float>::real()
@@ -885,49 +1152,48 @@ namespace std
// 26.2.3 complex specializations
// complex<double> specialization
- template<> class complex<double>
- {
- public:
- typedef double value_type;
+ template<>
+ struct complex<double>
+ {
+ typedef double value_type;
+ typedef __complex__ double _ComplexT;
- complex(double = 0.0, double = 0.0);
+ complex(_ComplexT __z) : _M_value(__z) { }
- complex(const complex<float>&);
- explicit complex(const complex<long double>&);
+ complex(double = 0.0, double = 0.0);
- double& real();
- const double& real() const;
- double& imag();
- const double& imag() const;
-
- complex<double>& operator=(double);
- complex<double>& operator+=(double);
- complex<double>& operator-=(double);
- complex<double>& operator*=(double);
- complex<double>& operator/=(double);
-
- // The compiler will synthetize this, efficiently.
- // complex& operator= (const complex&);
- template<typename _Tp>
- complex<double>& operator=(const complex<_Tp>&);
- template<typename _Tp>
- complex<double>& operator+=(const complex<_Tp>&);
- template<typename _Tp>
- complex<double>& operator-=(const complex<_Tp>&);
- template<typename _Tp>
- complex<double>& operator*=(const complex<_Tp>&);
- template<typename _Tp>
- complex<double>& operator/=(const complex<_Tp>&);
-
- private:
- typedef __complex__ double _ComplexT;
- _ComplexT _M_value;
-
- complex(_ComplexT __z) : _M_value(__z) { }
-
- friend class complex<float>;
- friend class complex<long double>;
- };
+ complex(const complex<float>&);
+ explicit complex(const complex<long double>&);
+
+ double& real();
+ const double& real() const;
+ double& imag();
+ const double& imag() const;
+
+ complex<double>& operator=(double);
+ complex<double>& operator+=(double);
+ complex<double>& operator-=(double);
+ complex<double>& operator*=(double);
+ complex<double>& operator/=(double);
+
+ // The compiler will synthetize this, efficiently.
+ // complex& operator= (const complex&);
+ template<typename _Tp>
+ complex<double>& operator=(const complex<_Tp>&);
+ template<typename _Tp>
+ complex<double>& operator+=(const complex<_Tp>&);
+ template<typename _Tp>
+ complex<double>& operator-=(const complex<_Tp>&);
+ template<typename _Tp>
+ complex<double>& operator*=(const complex<_Tp>&);
+ template<typename _Tp>
+ complex<double>& operator/=(const complex<_Tp>&);
+
+ const _ComplexT& __rep() const { return _M_value; }
+
+ private:
+ _ComplexT _M_value;
+ };
inline double&
complex<double>::real()
@@ -1039,49 +1305,48 @@ namespace std
// 26.2.3 complex specializations
// complex<long double> specialization
- template<> class complex<long double>
- {
- public:
- typedef long double value_type;
-
- complex(long double = 0.0L, long double = 0.0L);
-
- complex(const complex<float>&);
- complex(const complex<double>&);
-
- long double& real();
- const long double& real() const;
- long double& imag();
- const long double& imag() const;
-
- complex<long double>& operator= (long double);
- complex<long double>& operator+= (long double);
- complex<long double>& operator-= (long double);
- complex<long double>& operator*= (long double);
- complex<long double>& operator/= (long double);
-
- // The compiler knows how to do this efficiently
- // complex& operator= (const complex&);
- template<typename _Tp>
- complex<long double>& operator=(const complex<_Tp>&);
- template<typename _Tp>
- complex<long double>& operator+=(const complex<_Tp>&);
- template<typename _Tp>
- complex<long double>& operator-=(const complex<_Tp>&);
- template<typename _Tp>
- complex<long double>& operator*=(const complex<_Tp>&);
- template<typename _Tp>
- complex<long double>& operator/=(const complex<_Tp>&);
-
- private:
- typedef __complex__ long double _ComplexT;
- _ComplexT _M_value;
-
- complex(_ComplexT __z) : _M_value(__z) { }
-
- friend class complex<float>;
- friend class complex<double>;
- };
+ template<>
+ struct complex<long double>
+ {
+ typedef long double value_type;
+ typedef __complex__ long double _ComplexT;
+
+ complex(_ComplexT __z) : _M_value(__z) { }
+
+ complex(long double = 0.0L, long double = 0.0L);
+
+ complex(const complex<float>&);
+ complex(const complex<double>&);
+
+ long double& real();
+ const long double& real() const;
+ long double& imag();
+ const long double& imag() const;
+
+ complex<long double>& operator= (long double);
+ complex<long double>& operator+= (long double);
+ complex<long double>& operator-= (long double);
+ complex<long double>& operator*= (long double);
+ complex<long double>& operator/= (long double);
+
+ // The compiler knows how to do this efficiently
+ // complex& operator= (const complex&);
+ template<typename _Tp>
+ complex<long double>& operator=(const complex<_Tp>&);
+ template<typename _Tp>
+ complex<long double>& operator+=(const complex<_Tp>&);
+ template<typename _Tp>
+ complex<long double>& operator-=(const complex<_Tp>&);
+ template<typename _Tp>
+ complex<long double>& operator*=(const complex<_Tp>&);
+ template<typename _Tp>
+ complex<long double>& operator/=(const complex<_Tp>&);
+
+ const _ComplexT& __rep() const { return _M_value; }
+
+ private:
+ _ComplexT _M_value;
+ };
inline
complex<long double>::complex(long double __r, long double __i)
@@ -1197,30 +1462,28 @@ namespace std
// inlining. It suffices that class specializations be defined.
inline
complex<float>::complex(const complex<double>& __z)
- : _M_value(_ComplexT(__z._M_value)) { }
+ : _M_value(__z.__rep()) { }
inline
complex<float>::complex(const complex<long double>& __z)
- : _M_value(_ComplexT(__z._M_value)) { }
+ : _M_value(__z.__rep()) { }
inline
complex<double>::complex(const complex<float>& __z)
- : _M_value(_ComplexT(__z._M_value)) { }
+ : _M_value(__z.__rep()) { }
inline
complex<double>::complex(const complex<long double>& __z)
- {
- __real__ _M_value = __z.real();
- __imag__ _M_value = __z.imag();
- }
+ : _M_value(__z.__rep()) { }
inline
complex<long double>::complex(const complex<float>& __z)
- : _M_value(_ComplexT(__z._M_value)) { }
+ : _M_value(__z.__rep()) { }
inline
complex<long double>::complex(const complex<double>& __z)
- : _M_value(_ComplexT(__z._M_value)) { }
-} // namespace std
+ : _M_value(__z.__rep()) { }
+
+_GLIBCXX_END_NAMESPACE
#endif /* _GLIBCXX_COMPLEX */
diff --git a/contrib/libstdc++/include/std/std_deque.h b/contrib/libstdc++/include/std/std_deque.h
index 80817f6..57c6e43 100644
--- a/contrib/libstdc++/include/std/std_deque.h
+++ b/contrib/libstdc++/include/std/std_deque.h
@@ -15,7 +15,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -53,9 +53,8 @@
* purpose. It is provided "as is" without express or implied warranty.
*/
-/** @file deque
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
+/** @file include/deque
+ * This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_DEQUE
diff --git a/contrib/libstdc++/include/std/std_fstream.h b/contrib/libstdc++/include/std/std_fstream.h
index 3dec366..f664f2d 100644
--- a/contrib/libstdc++/include/std/std_fstream.h
+++ b/contrib/libstdc++/include/std/std_fstream.h
@@ -1,6 +1,6 @@
// File based streams -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -16,7 +16,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -28,15 +28,14 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
+/** @file fstream
+ * This is a Standard C++ Library header.
+ */
+
//
// ISO C++ 14882: 27.8 File-based streams
//
-/** @file fstream
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
- */
-
#ifndef _GLIBCXX_FSTREAM
#define _GLIBCXX_FSTREAM 1
@@ -49,8 +48,8 @@
#include <bits/basic_file.h>
#include <bits/gthr.h>
-namespace std
-{
+_GLIBCXX_BEGIN_NAMESPACE(std)
+
// [27.8.1.1] template class basic_filebuf
/**
* @brief The actual work of input and output (for files).
@@ -76,37 +75,20 @@ namespace std
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
- //@{
- /**
- * @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;
- //@}
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;
/**
@@ -117,30 +99,15 @@ namespace std
ios_base::openmode _M_mode;
// Beginning state type for codecvt.
- /**
- * @if maint
- * @doctodo
- * @endif
- */
__state_type _M_state_beg;
// During output, the state that corresponds to pptr(),
// during input, the state that corresponds to egptr() and
// _M_ext_next.
- /**
- * @if maint
- * @doctodo
- * @endif
- */
__state_type _M_state_cur;
// Not used for output. During input, the state that corresponds
// to eback() and _M_ext_buf.
- /**
- * @if maint
- * @doctodo
- * @endif
- */
__state_type _M_state_last;
/**
@@ -160,11 +127,6 @@ namespace std
size_t _M_buf_size;
// Set iff _M_buf is allocated memory from _M_allocate_internal_buffer.
- /**
- * @if maint
- * @doctodo
- * @endif
- */
bool _M_buf_allocated;
/**
@@ -255,7 +217,7 @@ namespace std
{
// Length _M_in_cur moved in the pback buffer.
_M_pback_cur_save += this->gptr() != this->eback();
- this->setg(this->_M_buf, _M_pback_cur_save, _M_pback_end_save);
+ this->setg(_M_buf, _M_pback_cur_save, _M_pback_end_save);
_M_pback_init = false;
}
}
@@ -282,7 +244,8 @@ namespace std
* @brief Returns true if the external file is open.
*/
bool
- is_open() const throw() { return _M_file.is_open(); }
+ is_open() const throw()
+ { return _M_file.is_open(); }
/**
* @brief Opens an external file.
@@ -315,24 +278,13 @@ namespace std
close() throw();
protected:
- /**
- * @if maint
- * @doctodo
- * @endif
- */
void
_M_allocate_internal_buffer();
- /**
- * @if maint
- * @doctodo
- * @endif
- */
void
_M_destroy_internal_buffer() throw();
// [27.8.1.4] overridden virtual functions
- // [documentation is inherited]
virtual streamsize
showmanyc();
@@ -341,11 +293,9 @@ namespace std
// charater from the real input source when the buffer is empty.
// Buffered input uses underflow()
- // [documentation is inherited]
virtual int_type
underflow();
- // [documentation is inherited]
virtual int_type
pbackfail(int_type __c = _Traits::eof());
@@ -356,21 +306,11 @@ namespace std
// character c.
// 27.5.2.4.5
// Consume some sequence of the characters in the pending sequence.
- /**
- * @if maint
- * @doctodo
- * @endif
- */
virtual int_type
overflow(int_type __c = _Traits::eof());
// Convert internal byte sequence to external, char-based
// sequence via codecvt.
- /**
- * @if maint
- * @doctodo
- * @endif
- */
bool
_M_convert_to_external(char_type*, streamsize);
@@ -389,47 +329,31 @@ namespace std
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);
// Common code for seekoff and seekpos
- /**
- * @if maint
- * @doctodo
- * @endif
- */
pos_type
_M_seek(off_type __off, ios_base::seekdir __way, __state_type __state);
- // [documentation is inherited]
virtual int
sync();
- // [documentation is inherited]
virtual void
imbue(const locale& __loc);
- // [documentation is inherited]
virtual streamsize
xsgetn(char_type* __s, streamsize __n);
- // [documentation is inherited]
virtual streamsize
xsputn(const char_type* __s, streamsize __n);
// Flushes output buffer, then writes unshift sequence.
- /**
- * @if maint
- * @doctodo
- * @endif
- */
bool
_M_terminate_output();
@@ -450,16 +374,16 @@ namespace std
void
_M_set_buffer(streamsize __off)
{
- const bool __testin = this->_M_mode & ios_base::in;
- const bool __testout = this->_M_mode & ios_base::out;
+ const bool __testin = _M_mode & ios_base::in;
+ const bool __testout = _M_mode & ios_base::out;
if (__testin && __off > 0)
- this->setg(this->_M_buf, this->_M_buf, this->_M_buf + __off);
+ this->setg(_M_buf, _M_buf, _M_buf + __off);
else
- this->setg(this->_M_buf, this->_M_buf, this->_M_buf);
+ this->setg(_M_buf, _M_buf, _M_buf);
- if (__testout && __off == 0 && this->_M_buf_size > 1 )
- this->setp(this->_M_buf, this->_M_buf + this->_M_buf_size - 1);
+ if (__testout && __off == 0 && _M_buf_size > 1 )
+ this->setp(_M_buf, _M_buf + _M_buf_size - 1);
else
this->setp(NULL, NULL);
}
@@ -490,11 +414,6 @@ namespace std
typedef basic_istream<char_type, traits_type> __istream_type;
private:
- /**
- * @if maint
- * @doctodo
- * @endif
- */
__filebuf_type _M_filebuf;
public:
@@ -552,7 +471,14 @@ namespace std
* @return @c rdbuf()->is_open()
*/
bool
- is_open() { return _M_filebuf.is_open(); }
+ is_open()
+ { return _M_filebuf.is_open(); }
+
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 365. Lack of const-qualification in clause 27
+ bool
+ is_open() const
+ { return _M_filebuf.is_open(); }
/**
* @brief Opens an external file.
@@ -570,6 +496,10 @@ namespace std
{
if (!_M_filebuf.open(__s, __mode | ios_base::in))
this->setstate(ios_base::failbit);
+ else
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 409. Closing an fstream should clear error state
+ this->clear();
}
/**
@@ -612,11 +542,6 @@ namespace std
typedef basic_ostream<char_type, traits_type> __ostream_type;
private:
- /**
- * @if maint
- * @doctodo
- * @endif
- */
__filebuf_type _M_filebuf;
public:
@@ -676,7 +601,14 @@ namespace std
* @return @c rdbuf()->is_open()
*/
bool
- is_open() { return _M_filebuf.is_open(); }
+ is_open()
+ { return _M_filebuf.is_open(); }
+
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 365. Lack of const-qualification in clause 27
+ bool
+ is_open() const
+ { return _M_filebuf.is_open(); }
/**
* @brief Opens an external file.
@@ -695,6 +627,10 @@ namespace std
{
if (!_M_filebuf.open(__s, __mode | ios_base::out))
this->setstate(ios_base::failbit);
+ else
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 409. Closing an fstream should clear error state
+ this->clear();
}
/**
@@ -738,11 +674,6 @@ namespace std
typedef basic_iostream<char_type, traits_type> __iostream_type;
private:
- /**
- * @if maint
- * @doctodo
- * @endif
- */
__filebuf_type _M_filebuf;
public:
@@ -800,7 +731,14 @@ namespace std
* @return @c rdbuf()->is_open()
*/
bool
- is_open() { return _M_filebuf.is_open(); }
+ is_open()
+ { return _M_filebuf.is_open(); }
+
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 365. Lack of const-qualification in clause 27
+ bool
+ is_open() const
+ { return _M_filebuf.is_open(); }
/**
* @brief Opens an external file.
@@ -819,6 +757,10 @@ namespace std
{
if (!_M_filebuf.open(__s, __mode))
this->setstate(ios_base::failbit);
+ else
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 409. Closing an fstream should clear error state
+ this->clear();
}
/**
@@ -834,7 +776,8 @@ namespace std
this->setstate(ios_base::failbit);
}
};
-} // namespace std
+
+_GLIBCXX_END_NAMESPACE
#ifndef _GLIBCXX_EXPORT_TEMPLATE
# include <bits/fstream.tcc>
diff --git a/contrib/libstdc++/include/std/std_functional.h b/contrib/libstdc++/include/std/std_functional.h
index 6819f20..feadaa2 100644
--- a/contrib/libstdc++/include/std/std_functional.h
+++ b/contrib/libstdc++/include/std/std_functional.h
@@ -15,7 +15,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -41,9 +41,8 @@
*
*/
-/** @file functional
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
+/** @file include/functional
+ * This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_FUNCTIONAL
diff --git a/contrib/libstdc++/include/std/std_iomanip.h b/contrib/libstdc++/include/std/std_iomanip.h
index 0d965c2..13b21d5 100644
--- a/contrib/libstdc++/include/std/std_iomanip.h
+++ b/contrib/libstdc++/include/std/std_iomanip.h
@@ -1,6 +1,6 @@
// Standard stream manipulators -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2001, 2002, 2003
+// Copyright (C) 1997, 1998, 1999, 2001, 2002, 2003, 2005
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -16,7 +16,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -28,15 +28,14 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
+/** @file iomanip
+ * This is a Standard C++ Library header.
+ */
+
//
// ISO C++ 14882: 27.6.3 Standard manipulators
//
-/** @file iomanip
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
- */
-
#ifndef _GLIBCXX_IOMANIP
#define _GLIBCXX_IOMANIP 1
@@ -46,8 +45,8 @@
#include <istream>
#include <functional>
-namespace std
-{
+_GLIBCXX_BEGIN_NAMESPACE(std)
+
// [27.6.3] standard manipulators
// Also see DR 183.
@@ -295,6 +294,7 @@ namespace std
extern template wistream& operator>>(wistream&, _Setw);
#endif
#endif
-} // namespace std
+
+_GLIBCXX_END_NAMESPACE
#endif /* _GLIBCXX_IOMANIP */
diff --git a/contrib/libstdc++/include/std/std_ios.h b/contrib/libstdc++/include/std/std_ios.h
index 596458f..f081115 100644
--- a/contrib/libstdc++/include/std/std_ios.h
+++ b/contrib/libstdc++/include/std/std_ios.h
@@ -15,7 +15,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -27,15 +27,14 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
+/** @file ios
+ * This is a Standard C++ Library header.
+ */
+
//
// ISO C++ 14882: 27.4 Iostreams base classes
//
-/** @file ios
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
- */
-
#ifndef _GLIBCXX_IOS
#define _GLIBCXX_IOS 1
diff --git a/contrib/libstdc++/include/std/std_iosfwd.h b/contrib/libstdc++/include/std/std_iosfwd.h
index 050b9e8..a4d0c3f 100644
--- a/contrib/libstdc++/include/std/std_iosfwd.h
+++ b/contrib/libstdc++/include/std/std_iosfwd.h
@@ -1,6 +1,6 @@
// Forwarding declarations -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2001, 2002, 2003
+// Copyright (C) 1997, 1998, 1999, 2001, 2002, 2003, 2005
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -16,7 +16,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -28,15 +28,14 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
+/** @file iosfwd
+ * This is a Standard C++ Library header.
+ */
+
//
// ISO C++ 14882: 27.2 Forward declarations
//
-/** @file iosfwd
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
- */
-
#ifndef _GLIBCXX_IOSFWD
#define _GLIBCXX_IOSFWD 1
@@ -50,8 +49,8 @@
#include <bits/postypes.h>
#include <bits/functexcept.h>
-namespace std
-{
+_GLIBCXX_BEGIN_NAMESPACE(std)
+
template<typename _CharT, typename _Traits = char_traits<_CharT> >
class basic_ios;
@@ -163,6 +162,7 @@ namespace std
typedef basic_fstream<wchar_t> wfstream; ///< @isiosfwd
#endif
/** @} */
-} // namespace std
+
+_GLIBCXX_END_NAMESPACE
#endif /* _GLIBCXX_IOSFWD */
diff --git a/contrib/libstdc++/include/std/std_iostream.h b/contrib/libstdc++/include/std/std_iostream.h
index f5049db..0ff0da2 100644
--- a/contrib/libstdc++/include/std/std_iostream.h
+++ b/contrib/libstdc++/include/std/std_iostream.h
@@ -1,6 +1,7 @@
// Standard iostream objects -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2001, 2002, 2005
+// 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
@@ -15,7 +16,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -27,15 +28,14 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
+/** @file iostream
+ * This is a Standard C++ Library header.
+ */
+
//
// ISO C++ 14882: 27.3 Standard iostream objects
//
-/** @file iostream
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
- */
-
#ifndef _GLIBCXX_IOSTREAM
#define _GLIBCXX_IOSTREAM 1
@@ -45,8 +45,8 @@
#include <ostream>
#include <istream>
-namespace std
-{
+_GLIBCXX_BEGIN_NAMESPACE(std)
+
/**
* @name Standard Stream Objects
*
@@ -75,6 +75,7 @@ namespace std
// For construction of filebuffers for cout, cin, cerr, clog et. al.
static ios_base::Init __ioinit;
-} // namespace std
+
+_GLIBCXX_END_NAMESPACE
#endif /* _GLIBCXX_IOSTREAM */
diff --git a/contrib/libstdc++/include/std/std_istream.h b/contrib/libstdc++/include/std/std_istream.h
index a3a53ba..e81c9cd 100644
--- a/contrib/libstdc++/include/std/std_istream.h
+++ b/contrib/libstdc++/include/std/std_istream.h
@@ -1,6 +1,6 @@
// Input streams -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2001, 2002, 2003
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -16,7 +16,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -33,8 +33,7 @@
//
/** @file istream
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
+ * This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_ISTREAM
@@ -45,8 +44,8 @@
#include <ios>
#include <limits> // For numeric_limits
-namespace std
-{
+_GLIBCXX_BEGIN_NAMESPACE(std)
+
// [27.6.1.1] Template class basic_istream
/**
* @brief Controlling input.
@@ -128,14 +127,23 @@ namespace std
* functions in constructs like "std::cin >> std::ws". For more
* information, see the iomanip header.
*/
- inline __istream_type&
- operator>>(__istream_type& (*__pf)(__istream_type&));
+ __istream_type&
+ operator>>(__istream_type& (*__pf)(__istream_type&))
+ { return __pf(*this); }
- inline __istream_type&
- operator>>(__ios_type& (*__pf)(__ios_type&));
+ __istream_type&
+ operator>>(__ios_type& (*__pf)(__ios_type&))
+ {
+ __pf(*this);
+ return *this;
+ }
- inline __istream_type&
- operator>>(ios_base& (*__pf)(ios_base&));
+ __istream_type&
+ operator>>(ios_base& (*__pf)(ios_base&))
+ {
+ __pf(*this);
+ return *this;
+ }
//@}
// [27.6.1.2.2] arithmetic extractors
@@ -167,45 +175,56 @@ namespace std
* @c num_get facet) to parse the input data.
*/
__istream_type&
- operator>>(bool& __n);
+ operator>>(bool& __n)
+ { return _M_extract(__n); }
__istream_type&
operator>>(short& __n);
__istream_type&
- operator>>(unsigned short& __n);
+ operator>>(unsigned short& __n)
+ { return _M_extract(__n); }
__istream_type&
operator>>(int& __n);
-
+
__istream_type&
- operator>>(unsigned int& __n);
+ operator>>(unsigned int& __n)
+ { return _M_extract(__n); }
__istream_type&
- operator>>(long& __n);
+ operator>>(long& __n)
+ { return _M_extract(__n); }
__istream_type&
- operator>>(unsigned long& __n);
+ operator>>(unsigned long& __n)
+ { return _M_extract(__n); }
#ifdef _GLIBCXX_USE_LONG_LONG
__istream_type&
- operator>>(long long& __n);
+ operator>>(long long& __n)
+ { return _M_extract(__n); }
__istream_type&
- operator>>(unsigned long long& __n);
+ operator>>(unsigned long long& __n)
+ { return _M_extract(__n); }
#endif
__istream_type&
- operator>>(float& __f);
+ operator>>(float& __f)
+ { return _M_extract(__f); }
__istream_type&
- operator>>(double& __f);
+ operator>>(double& __f)
+ { return _M_extract(__f); }
__istream_type&
- operator>>(long double& __f);
+ operator>>(long double& __f)
+ { return _M_extract(__f); }
__istream_type&
- operator>>(void*& __p);
+ operator>>(void*& __p)
+ { return _M_extract(__p); }
/**
* @brief Extracting into another streambuf.
@@ -237,7 +256,7 @@ namespace std
* @return The number of characters extracted by the previous
* unformatted input function dispatched for this stream.
*/
- inline streamsize
+ streamsize
gcount() const
{ return _M_gcount; }
@@ -321,7 +340,7 @@ namespace std
*
* Returns @c get(s,n,widen('\n')).
*/
- inline __istream_type&
+ __istream_type&
get(char_type* __s, streamsize __n)
{ return this->get(__s, __n, this->widen('\n')); }
@@ -354,7 +373,7 @@ namespace std
*
* Returns @c get(sb,widen('\n')).
*/
- inline __istream_type&
+ __istream_type&
get(__streambuf_type& __sb)
{ return this->get(__sb, this->widen('\n')); }
@@ -394,7 +413,7 @@ namespace std
*
* Returns @c getline(s,n,widen('\n')).
*/
- inline __istream_type&
+ __istream_type&
getline(char_type* __s, streamsize __n)
{ return this->getline(__s, __n, this->widen('\n')); }
@@ -412,9 +431,20 @@ namespace std
* - 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().
+ *
+ * NB: Provide three overloads, instead of the single function
+ * (with defaults) mandated by the Standard: this leads to a
+ * better performing implementation, while still conforming to
+ * the Standard.
*/
__istream_type&
- ignore(streamsize __n = 1, int_type __delim = traits_type::eof());
+ ignore();
+
+ __istream_type&
+ ignore(streamsize __n);
+
+ __istream_type&
+ ignore(streamsize __n, int_type __delim);
/**
* @brief Looking ahead in the stream
@@ -562,8 +592,45 @@ namespace std
protected:
explicit
basic_istream(): _M_gcount(streamsize(0)) { }
+
+ template<typename _ValueT>
+ __istream_type&
+ _M_extract(_ValueT& __v);
};
+
+ // Explicit specialization declarations, defined in src/istream.cc.
+ template<>
+ basic_istream<char>&
+ basic_istream<char>::
+ getline(char_type* __s, streamsize __n, char_type __delim);
+
+ template<>
+ basic_istream<char>&
+ basic_istream<char>::
+ ignore(streamsize __n);
+
+ template<>
+ basic_istream<char>&
+ basic_istream<char>::
+ ignore(streamsize __n, int_type __delim);
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ template<>
+ basic_istream<wchar_t>&
+ basic_istream<wchar_t>::
+ getline(char_type* __s, streamsize __n, char_type __delim);
+
+ template<>
+ basic_istream<wchar_t>&
+ basic_istream<wchar_t>::
+ ignore(streamsize __n);
+ template<>
+ basic_istream<wchar_t>&
+ basic_istream<wchar_t>::
+ ignore(streamsize __n, int_type __delim);
+#endif
+
/**
* @brief Performs setup work for input streams.
*
@@ -617,7 +684,8 @@ namespace std
* For ease of use, sentries may be converted to booleans. The
* return value is that of the sentry state (true == okay).
*/
- operator bool() const { return _M_ok; }
+ operator bool() const
+ { return _M_ok; }
private:
bool _M_ok;
@@ -641,12 +709,12 @@ namespace std
operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c);
template<class _Traits>
- basic_istream<char, _Traits>&
+ inline basic_istream<char, _Traits>&
operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
{ return (__in >> reinterpret_cast<char&>(__c)); }
template<class _Traits>
- basic_istream<char, _Traits>&
+ inline basic_istream<char, _Traits>&
operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
{ return (__in >> reinterpret_cast<char&>(__c)); }
//@}
@@ -680,15 +748,20 @@ namespace std
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s);
-
+
+ // Explicit specialization declaration, defined in src/istream.cc.
+ template<>
+ basic_istream<char>&
+ operator>>(basic_istream<char>& __in, char* __s);
+
template<class _Traits>
- basic_istream<char,_Traits>&
- operator>>(basic_istream<char,_Traits>& __in, unsigned char* __s)
+ inline basic_istream<char, _Traits>&
+ operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s)
{ return (__in >> reinterpret_cast<char*>(__s)); }
template<class _Traits>
- basic_istream<char,_Traits>&
- operator>>(basic_istream<char,_Traits>& __in, signed char* __s)
+ inline basic_istream<char, _Traits>&
+ operator>>(basic_istream<char, _Traits>& __in, signed char* __s)
{ return (__in >> reinterpret_cast<char*>(__s)); }
//@}
@@ -765,7 +838,8 @@ namespace std
template<typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
ws(basic_istream<_CharT, _Traits>& __is);
-} // namespace std
+
+_GLIBCXX_END_NAMESPACE
#ifndef _GLIBCXX_EXPORT_TEMPLATE
# include <bits/istream.tcc>
diff --git a/contrib/libstdc++/include/std/std_iterator.h b/contrib/libstdc++/include/std/std_iterator.h
index 6e3840b..f0317b4 100644
--- a/contrib/libstdc++/include/std/std_iterator.h
+++ b/contrib/libstdc++/include/std/std_iterator.h
@@ -15,7 +15,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -53,9 +53,8 @@
* purpose. It is provided "as is" without express or implied warranty.
*/
-/** @file iterator
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
+/** @file include/iterator
+ * This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_ITERATOR
diff --git a/contrib/libstdc++/include/std/std_limits.h b/contrib/libstdc++/include/std/std_limits.h
index 7f96647..d1211fd 100644
--- a/contrib/libstdc++/include/std/std_limits.h
+++ b/contrib/libstdc++/include/std/std_limits.h
@@ -1,6 +1,7 @@
-// The template and inlines for the -*- C++ -*- numeric_limits classes.
+// The template and inlines for the numeric_limits classes. -*- C++ -*-
-// Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005
+// 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
@@ -15,7 +16,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -27,6 +28,10 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
+/** @file limits
+ * This is a Standard C++ Library header.
+ */
+
// Note: this is not a conforming implementation.
// Written by Gabriel Dos Reis <gdr@codesourcery.com>
@@ -35,11 +40,6 @@
// 18.2.1
//
-/** @file limits
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
- */
-
#ifndef _GLIBCXX_NUMERIC_LIMITS
#define _GLIBCXX_NUMERIC_LIMITS 1
@@ -147,8 +147,8 @@
(__glibcxx_digits (T) * 643 / 2136)
-namespace std
-{
+_GLIBCXX_BEGIN_NAMESPACE(std)
+
/**
* @brief Describes the rounding style for floating-point types.
*
@@ -310,6 +310,8 @@ namespace std
// Now there follow 15 explicit specializations. Yes, 15. Make sure
// you get the count right.
+
+ /// numeric_limits<bool> specialization.
template<>
struct numeric_limits<bool>
{
@@ -363,6 +365,7 @@ namespace std
static const float_round_style round_style = round_toward_zero;
};
+ /// numeric_limits<char> specialization.
template<>
struct numeric_limits<char>
{
@@ -413,6 +416,7 @@ namespace std
static const float_round_style round_style = round_toward_zero;
};
+ /// numeric_limits<signed char> specialization.
template<>
struct numeric_limits<signed char>
{
@@ -463,6 +467,7 @@ namespace std
static const float_round_style round_style = round_toward_zero;
};
+ /// numeric_limits<unsigned char> specialization.
template<>
struct numeric_limits<unsigned char>
{
@@ -513,6 +518,7 @@ namespace std
static const float_round_style round_style = round_toward_zero;
};
+ /// numeric_limits<wchar_t> specialization.
template<>
struct numeric_limits<wchar_t>
{
@@ -563,6 +569,7 @@ namespace std
static const float_round_style round_style = round_toward_zero;
};
+ /// numeric_limits<short> specialization.
template<>
struct numeric_limits<short>
{
@@ -613,6 +620,7 @@ namespace std
static const float_round_style round_style = round_toward_zero;
};
+ /// numeric_limits<unsigned short> specialization.
template<>
struct numeric_limits<unsigned short>
{
@@ -663,6 +671,7 @@ namespace std
static const float_round_style round_style = round_toward_zero;
};
+ /// numeric_limits<int> specialization.
template<>
struct numeric_limits<int>
{
@@ -713,6 +722,7 @@ namespace std
static const float_round_style round_style = round_toward_zero;
};
+ /// numeric_limits<unsigned int> specialization.
template<>
struct numeric_limits<unsigned int>
{
@@ -763,6 +773,7 @@ namespace std
static const float_round_style round_style = round_toward_zero;
};
+ /// numeric_limits<long> specialization.
template<>
struct numeric_limits<long>
{
@@ -813,6 +824,7 @@ namespace std
static const float_round_style round_style = round_toward_zero;
};
+ /// numeric_limits<unsigned long> specialization.
template<>
struct numeric_limits<unsigned long>
{
@@ -863,6 +875,7 @@ namespace std
static const float_round_style round_style = round_toward_zero;
};
+ /// numeric_limits<long long> specialization.
template<>
struct numeric_limits<long long>
{
@@ -913,6 +926,7 @@ namespace std
static const float_round_style round_style = round_toward_zero;
};
+ /// numeric_limits<unsigned long long> specialization.
template<>
struct numeric_limits<unsigned long long>
{
@@ -963,6 +977,7 @@ namespace std
static const float_round_style round_style = round_toward_zero;
};
+ /// numeric_limits<float> specialization.
template<>
struct numeric_limits<float>
{
@@ -993,7 +1008,7 @@ namespace std
static const bool has_quiet_NaN = __FLT_HAS_QUIET_NAN__;
static const bool has_signaling_NaN = has_quiet_NaN;
static const float_denorm_style has_denorm
- = __FLT_DENORM_MIN__ ? denorm_present : denorm_absent;
+ = bool(__FLT_HAS_DENORM__) ? denorm_present : denorm_absent;
static const bool has_denorm_loss = __glibcxx_float_has_denorm_loss;
static float infinity() throw()
@@ -1019,6 +1034,7 @@ namespace std
#undef __glibcxx_float_traps
#undef __glibcxx_float_tinyness_before
+ /// numeric_limits<double> specialization.
template<>
struct numeric_limits<double>
{
@@ -1049,7 +1065,7 @@ namespace std
static const bool has_quiet_NaN = __DBL_HAS_QUIET_NAN__;
static const bool has_signaling_NaN = has_quiet_NaN;
static const float_denorm_style has_denorm
- = __DBL_DENORM_MIN__ ? denorm_present : denorm_absent;
+ = bool(__DBL_HAS_DENORM__) ? denorm_present : denorm_absent;
static const bool has_denorm_loss = __glibcxx_double_has_denorm_loss;
static double infinity() throw()
@@ -1075,6 +1091,7 @@ namespace std
#undef __glibcxx_double_traps
#undef __glibcxx_double_tinyness_before
+ /// numeric_limits<long double> specialization.
template<>
struct numeric_limits<long double>
{
@@ -1105,7 +1122,7 @@ namespace std
static const bool has_quiet_NaN = __LDBL_HAS_QUIET_NAN__;
static const bool has_signaling_NaN = has_quiet_NaN;
static const float_denorm_style has_denorm
- = __LDBL_DENORM_MIN__ ? denorm_present : denorm_absent;
+ = bool(__LDBL_HAS_DENORM__) ? denorm_present : denorm_absent;
static const bool has_denorm_loss
= __glibcxx_long_double_has_denorm_loss;
@@ -1132,7 +1149,7 @@ namespace std
#undef __glibcxx_long_double_traps
#undef __glibcxx_long_double_tinyness_before
-} // namespace std
+_GLIBCXX_END_NAMESPACE
#undef __glibcxx_signed
#undef __glibcxx_min
diff --git a/contrib/libstdc++/include/std/std_list.h b/contrib/libstdc++/include/std/std_list.h
index 285a29d..b46f654 100644
--- a/contrib/libstdc++/include/std/std_list.h
+++ b/contrib/libstdc++/include/std/std_list.h
@@ -15,7 +15,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -53,9 +53,8 @@
* purpose. It is provided "as is" without express or implied warranty.
*/
-/** @file list
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
+/** @file include/list
+ * This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_LIST
diff --git a/contrib/libstdc++/include/std/std_locale.h b/contrib/libstdc++/include/std/std_locale.h
index 43417fb..5223f90 100644
--- a/contrib/libstdc++/include/std/std_locale.h
+++ b/contrib/libstdc++/include/std/std_locale.h
@@ -15,7 +15,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -32,8 +32,7 @@
//
/** @file locale
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
+ * This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_LOCALE
diff --git a/contrib/libstdc++/include/std/std_map.h b/contrib/libstdc++/include/std/std_map.h
index 4a88ae2..a7e8f9c 100644
--- a/contrib/libstdc++/include/std/std_map.h
+++ b/contrib/libstdc++/include/std/std_map.h
@@ -15,7 +15,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -53,9 +53,8 @@
* purpose. It is provided "as is" without express or implied warranty.
*/
-/** @file map
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
+/** @file include/map
+ * This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_MAP
diff --git a/contrib/libstdc++/include/std/std_memory.h b/contrib/libstdc++/include/std/std_memory.h
index 1d278e6..b57a94f 100644
--- a/contrib/libstdc++/include/std/std_memory.h
+++ b/contrib/libstdc++/include/std/std_memory.h
@@ -1,6 +1,6 @@
// <memory> -*- C++ -*-
-// Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2004, 2005 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
@@ -15,7 +15,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -41,9 +41,8 @@
*
*/
-/** @file memory
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
+/** @file include/memory
+ * This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_MEMORY
@@ -60,8 +59,8 @@
#include <debug/debug.h>
#include <limits>
-namespace std
-{
+_GLIBCXX_BEGIN_NAMESPACE(std)
+
/**
* @if maint
* This is a helper function. The unused second parameter exists to
@@ -255,7 +254,7 @@ namespace std
* 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
+ * @endif
*/
~auto_ptr() { delete _M_ptr; }
@@ -336,7 +335,7 @@ namespace std
}
}
- /** @{
+ /**
* @brief Automatic conversions
*
* These operations convert an %auto_ptr into and from an auto_ptr_ref
@@ -368,8 +367,8 @@ namespace std
template<typename _Tp1>
operator auto_ptr<_Tp1>() throw()
{ return auto_ptr<_Tp1>(this->release()); }
- /** @} */
};
-} // namespace std
+
+_GLIBCXX_END_NAMESPACE
#endif /* _GLIBCXX_MEMORY */
diff --git a/contrib/libstdc++/include/std/std_numeric.h b/contrib/libstdc++/include/std/std_numeric.h
index 88661e9..03f82dd 100644
--- a/contrib/libstdc++/include/std/std_numeric.h
+++ b/contrib/libstdc++/include/std/std_numeric.h
@@ -15,7 +15,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -53,9 +53,8 @@
* purpose. It is provided "as is" without express or implied warranty.
*/
-/** @file numeric
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
+/** @file include/numeric
+ * This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_NUMERIC
diff --git a/contrib/libstdc++/include/std/std_ostream.h b/contrib/libstdc++/include/std/std_ostream.h
index e3590f2..23e9510 100644
--- a/contrib/libstdc++/include/std/std_ostream.h
+++ b/contrib/libstdc++/include/std/std_ostream.h
@@ -1,6 +1,7 @@
// Output streams -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+// 2006, 2007
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -16,7 +17,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -28,24 +29,24 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
+/** @file ostream
+ * This is a Standard C++ Library header.
+ */
+
//
// ISO C++ 14882: 27.6.2 Output streams
//
-/** @file ostream
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
- */
-
#ifndef _GLIBCXX_OSTREAM
#define _GLIBCXX_OSTREAM 1
#pragma GCC system_header
#include <ios>
+#include <bits/ostream_insert.h>
+
+_GLIBCXX_BEGIN_NAMESPACE(std)
-namespace std
-{
// [27.6.2.1] Template class basic_ostream
/**
* @brief Controlling output.
@@ -73,26 +74,6 @@ namespace std
__num_put_type;
typedef ctype<_CharT> __ctype_type;
- 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.
@@ -127,14 +108,34 @@ namespace std
* functions in constructs like "std::cout << std::endl". For more
* information, see the iomanip header.
*/
- inline __ostream_type&
- operator<<(__ostream_type& (*__pf)(__ostream_type&));
-
- inline __ostream_type&
- operator<<(__ios_type& (*__pf)(__ios_type&));
-
- inline __ostream_type&
- operator<<(ios_base& (*__pf) (ios_base&));
+ __ostream_type&
+ operator<<(__ostream_type& (*__pf)(__ostream_type&))
+ {
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // DR 60. What is a formatted input function?
+ // The inserters for manipulators are *not* formatted output functions.
+ return __pf(*this);
+ }
+
+ __ostream_type&
+ operator<<(__ios_type& (*__pf)(__ios_type&))
+ {
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // DR 60. What is a formatted input function?
+ // The inserters for manipulators are *not* formatted output functions.
+ __pf(*this);
+ return *this;
+ }
+
+ __ostream_type&
+ operator<<(ios_base& (*__pf) (ios_base&))
+ {
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // DR 60. What is a formatted input function?
+ // The inserters for manipulators are *not* formatted output functions.
+ __pf(*this);
+ return *this;
+ }
//@}
// [27.6.2.5.2] arithmetic inserters
@@ -165,64 +166,68 @@ namespace std
* @c num_get facet) to perform numeric formatting.
*/
__ostream_type&
- operator<<(long __n);
+ operator<<(long __n)
+ { return _M_insert(__n); }
__ostream_type&
- operator<<(unsigned long __n);
+ operator<<(unsigned long __n)
+ { return _M_insert(__n); }
__ostream_type&
- operator<<(bool __n);
+ operator<<(bool __n)
+ { return _M_insert(__n); }
__ostream_type&
- operator<<(short __n)
- {
- ios_base::fmtflags __fmt = this->flags() & ios_base::basefield;
- if (__fmt & ios_base::oct || __fmt & ios_base::hex)
- return this->operator<<(static_cast<unsigned long>
- (static_cast<unsigned short>(__n)));
- else
- return this->operator<<(static_cast<long>(__n));
- }
+ operator<<(short __n);
__ostream_type&
operator<<(unsigned short __n)
- { return this->operator<<(static_cast<unsigned long>(__n)); }
+ {
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 117. basic_ostream uses nonexistent num_put member functions.
+ return _M_insert(static_cast<unsigned long>(__n));
+ }
__ostream_type&
- operator<<(int __n)
- {
- ios_base::fmtflags __fmt = this->flags() & ios_base::basefield;
- if (__fmt & ios_base::oct || __fmt & ios_base::hex)
- return this->operator<<(static_cast<unsigned long>
- (static_cast<unsigned int>(__n)));
- else
- return this->operator<<(static_cast<long>(__n));
- }
+ operator<<(int __n);
__ostream_type&
operator<<(unsigned int __n)
- { return this->operator<<(static_cast<unsigned long>(__n)); }
+ {
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 117. basic_ostream uses nonexistent num_put member functions.
+ return _M_insert(static_cast<unsigned long>(__n));
+ }
#ifdef _GLIBCXX_USE_LONG_LONG
__ostream_type&
- operator<<(long long __n);
+ operator<<(long long __n)
+ { return _M_insert(__n); }
__ostream_type&
- operator<<(unsigned long long __n);
+ operator<<(unsigned long long __n)
+ { return _M_insert(__n); }
#endif
__ostream_type&
- operator<<(double __f);
+ operator<<(double __f)
+ { return _M_insert(__f); }
__ostream_type&
operator<<(float __f)
- { return this->operator<<(static_cast<double>(__f)); }
+ {
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 117. basic_ostream uses nonexistent num_put member functions.
+ return _M_insert(static_cast<double>(__f));
+ }
__ostream_type&
- operator<<(long double __f);
+ operator<<(long double __f)
+ { return _M_insert(__f); }
__ostream_type&
- operator<<(const void* __p);
+ operator<<(const void* __p)
+ { return _M_insert(__p); }
/**
* @brief Extracting from another streambuf.
@@ -285,7 +290,7 @@ namespace std
void
_M_write(const char_type* __s, streamsize __n)
{
- streamsize __put = this->rdbuf()->sputn(__s, __n);
+ const streamsize __put = this->rdbuf()->sputn(__s, __n);
if (__put != __n)
this->setstate(ios_base::badbit);
}
@@ -359,6 +364,10 @@ namespace std
protected:
explicit
basic_ostream() { }
+
+ template<typename _ValueT>
+ __ostream_type&
+ _M_insert(_ValueT __v);
};
/**
@@ -376,7 +385,7 @@ namespace std
{
// Data Members:
bool _M_ok;
- basic_ostream<_CharT,_Traits>& _M_os;
+ basic_ostream<_CharT, _Traits>& _M_os;
public:
/**
@@ -391,7 +400,7 @@ namespace std
* true ("okay").
*/
explicit
- sentry(basic_ostream<_CharT,_Traits>& __os);
+ sentry(basic_ostream<_CharT, _Traits>& __os);
/**
* @brief Possibly flushes the stream.
@@ -440,27 +449,29 @@ namespace std
* @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);
+ inline basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)
+ { return __ostream_insert(__out, &__c, 1); }
template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>&
+ inline basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)
{ return (__out << __out.widen(__c)); }
// Specialization
template <class _Traits>
- basic_ostream<char, _Traits>&
- operator<<(basic_ostream<char, _Traits>& __out, char __c);
+ inline basic_ostream<char, _Traits>&
+ operator<<(basic_ostream<char, _Traits>& __out, char __c)
+ { return __ostream_insert(__out, &__c, 1); }
// Signed and unsigned
template<class _Traits>
- basic_ostream<char, _Traits>&
+ inline basic_ostream<char, _Traits>&
operator<<(basic_ostream<char, _Traits>& __out, signed char __c)
{ return (__out << static_cast<char>(__c)); }
template<class _Traits>
- basic_ostream<char, _Traits>&
+ inline basic_ostream<char, _Traits>&
operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)
{ return (__out << static_cast<char>(__c)); }
//@}
@@ -480,8 +491,16 @@ namespace std
* 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);
+ inline basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)
+ {
+ if (!__s)
+ __out.setstate(ios_base::badbit);
+ else
+ __ostream_insert(__out, __s,
+ static_cast<streamsize>(_Traits::length(__s)));
+ return __out;
+ }
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits> &
@@ -489,17 +508,25 @@ namespace std
// Partial specializationss
template<class _Traits>
- basic_ostream<char, _Traits>&
- operator<<(basic_ostream<char, _Traits>& __out, const char* __s);
-
+ inline basic_ostream<char, _Traits>&
+ operator<<(basic_ostream<char, _Traits>& __out, const char* __s)
+ {
+ if (!__s)
+ __out.setstate(ios_base::badbit);
+ else
+ __ostream_insert(__out, __s,
+ static_cast<streamsize>(_Traits::length(__s)));
+ return __out;
+ }
+
// Signed and unsigned
template<class _Traits>
- basic_ostream<char, _Traits>&
+ inline basic_ostream<char, _Traits>&
operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)
{ return (__out << reinterpret_cast<const char*>(__s)); }
template<class _Traits>
- basic_ostream<char, _Traits> &
+ inline basic_ostream<char, _Traits> &
operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)
{ return (__out << reinterpret_cast<const char*>(__s)); }
//@}
@@ -514,7 +541,7 @@ namespace std
* on this subject.
*/
template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>&
+ inline basic_ostream<_CharT, _Traits>&
endl(basic_ostream<_CharT, _Traits>& __os)
{ return flush(__os.put(__os.widen('\n'))); }
@@ -525,7 +552,7 @@ namespace std
* this correctly writes the ASCII @c NUL character string terminator.
*/
template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>&
+ inline basic_ostream<_CharT, _Traits>&
ends(basic_ostream<_CharT, _Traits>& __os)
{ return __os.put(_CharT()); }
@@ -535,11 +562,11 @@ namespace std
* This manipulator simply calls the stream's @c flush() member function.
*/
template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>&
+ inline basic_ostream<_CharT, _Traits>&
flush(basic_ostream<_CharT, _Traits>& __os)
{ return __os.flush(); }
-} // namespace std
+_GLIBCXX_END_NAMESPACE
#ifndef _GLIBCXX_EXPORT_TEMPLATE
# include <bits/ostream.tcc>
diff --git a/contrib/libstdc++/include/std/std_queue.h b/contrib/libstdc++/include/std/std_queue.h
index 9a6523b..1242a06 100644
--- a/contrib/libstdc++/include/std/std_queue.h
+++ b/contrib/libstdc++/include/std/std_queue.h
@@ -15,7 +15,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -53,9 +53,8 @@
* purpose. It is provided "as is" without express or implied warranty.
*/
-/** @file queue
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
+/** @file include/queue
+ * This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_QUEUE
diff --git a/contrib/libstdc++/include/std/std_set.h b/contrib/libstdc++/include/std/std_set.h
index 7ef8c9f..65ebe8a 100644
--- a/contrib/libstdc++/include/std/std_set.h
+++ b/contrib/libstdc++/include/std/std_set.h
@@ -15,7 +15,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -53,9 +53,8 @@
* purpose. It is provided "as is" without express or implied warranty.
*/
-/** @file set
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
+/** @file include/set
+ * This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_SET
diff --git a/contrib/libstdc++/include/std/std_sstream.h b/contrib/libstdc++/include/std/std_sstream.h
index 0a6738a..a09815c 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, 2003, 2004
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -16,7 +16,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -28,15 +28,14 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
+/** @file sstream
+ * This is a Standard C++ Library header.
+ */
+
//
// ISO C++ 14882: 27.7 String-based streams
//
-/** @file sstream
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
- */
-
#ifndef _GLIBCXX_SSTREAM
#define _GLIBCXX_SSTREAM 1
@@ -45,8 +44,8 @@
#include <istream>
#include <ostream>
-namespace std
-{
+_GLIBCXX_BEGIN_NAMESPACE(std)
+
// [27.7.1] template class basic_stringbuf
/**
* @brief The actual work of input and output (for std::string).
@@ -73,16 +72,9 @@ namespace std
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
- //@{
- /**
- * @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:
/**
@@ -93,11 +85,6 @@ namespace std
ios_base::openmode _M_mode;
// Data Members:
- /**
- * @if maint
- * @doctodo
- * @endif
- */
__string_type _M_string;
public:
@@ -140,16 +127,18 @@ namespace std
__string_type
str() const
{
+ __string_type __ret;
if (this->pptr())
{
// The current egptr() may not be the actual string end.
if (this->pptr() > this->egptr())
- return __string_type(this->pbase(), this->pptr());
+ __ret = __string_type(this->pbase(), this->pptr());
else
- return __string_type(this->pbase(), this->egptr());
+ __ret = __string_type(this->pbase(), this->egptr());
}
else
- return _M_string;
+ __ret = _M_string;
+ return __ret;
}
/**
@@ -164,36 +153,39 @@ namespace std
{
// Cannot use _M_string = __s, since v3 strings are COW.
_M_string.assign(__s.data(), __s.size());
- _M_stringbuf_init(this->_M_mode);
+ _M_stringbuf_init(_M_mode);
}
protected:
// Common initialization code goes here.
- /**
- * @if maint
- * @doctodo
- * @endif
- */
void
_M_stringbuf_init(ios_base::openmode __mode)
{
- this->_M_mode = __mode;
-
+ _M_mode = __mode;
__size_type __len = 0;
- if (this->_M_mode & (ios_base::ate | ios_base::app))
+ if (_M_mode & (ios_base::ate | ios_base::app))
__len = _M_string.size();
_M_sync(const_cast<char_type*>(_M_string.data()), 0, __len);
}
- // [documentation is inherited]
+ virtual streamsize
+ showmanyc()
+ {
+ streamsize __ret = -1;
+ if (_M_mode & ios_base::in)
+ {
+ _M_update_egptr();
+ __ret = this->egptr() - this->gptr();
+ }
+ return __ret;
+ }
+
virtual int_type
underflow();
- // [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());
@@ -219,64 +211,34 @@ namespace std
// things will quickly blow up.
// Step 1: Destroy the current internal array.
- _M_string = __string_type(__s, __n);
+ _M_string.clear();
// Step 2: Use the external array.
- _M_sync(__s, 0, 0);
+ _M_sync(__s, __n, 0);
}
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);
// Internal function for correctly updating the internal buffer
- // for a particular _M_string, due to initialization or
- // re-sizing of an existing _M_string.
- // 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
- */
+ // for a particular _M_string, due to initialization or re-sizing
+ // of an existing _M_string.
void
- _M_sync(char_type* __base, __size_type __i, __size_type __o)
- {
- const bool __testin = this->_M_mode & ios_base::in;
- const bool __testout = this->_M_mode & ios_base::out;
- const __size_type __len = _M_string.size();
-
- if (__testin)
- this->setg(__base, __base + __i, __base + __len);
- if (__testout)
- {
- this->setp(__base, __base + _M_string.capacity());
- this->pbump(__o);
- // We need a pointer to the string end anyway, even when
- // !__testin: in that case, however, for the correct
- // functioning of the streambuf inlines all the get area
- // pointers must be identical.
- if (!__testin)
- this->setg(__base + __len, __base + __len, __base + __len);
- }
- }
+ _M_sync(char_type* __base, __size_type __i, __size_type __o);
// Internal function for correctly updating egptr() to the actual
// string end.
void
_M_update_egptr()
{
- const bool __testin = this->_M_mode & ios_base::in;
-
+ const bool __testin = _M_mode & ios_base::in;
if (this->pptr() && this->pptr() > this->egptr())
if (__testin)
this->setg(this->eback(), this->gptr(), this->pptr());
@@ -315,11 +277,6 @@ namespace std
typedef basic_istream<char_type, traits_type> __istream_type;
private:
- /**
- * @if maint
- * @doctodo
- * @endif
- */
__stringbuf_type _M_stringbuf;
public:
@@ -433,11 +390,6 @@ namespace std
typedef basic_ostream<char_type, traits_type> __ostream_type;
private:
- /**
- * @if maint
- * @doctodo
- * @endif
- */
__stringbuf_type _M_stringbuf;
public:
@@ -551,11 +503,6 @@ namespace std
typedef basic_iostream<char_type, traits_type> __iostream_type;
private:
- /**
- * @if maint
- * @doctodo
- * @endif
- */
__stringbuf_type _M_stringbuf;
public:
@@ -634,7 +581,8 @@ namespace std
str(const __string_type& __s)
{ _M_stringbuf.str(__s); }
};
-} // namespace std
+
+_GLIBCXX_END_NAMESPACE
#ifndef _GLIBCXX_EXPORT_TEMPLATE
# include <bits/sstream.tcc>
diff --git a/contrib/libstdc++/include/std/std_stack.h b/contrib/libstdc++/include/std/std_stack.h
index 70f0456..396f62e 100644
--- a/contrib/libstdc++/include/std/std_stack.h
+++ b/contrib/libstdc++/include/std/std_stack.h
@@ -15,7 +15,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -53,9 +53,8 @@
* purpose. It is provided "as is" without express or implied warranty.
*/
-/** @file stack
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
+/** @file include/stack
+ * This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_STACK
diff --git a/contrib/libstdc++/include/std/std_stdexcept.h b/contrib/libstdc++/include/std/std_stdexcept.h
index ebd97f5..2d56b38 100644
--- a/contrib/libstdc++/include/std/std_stdexcept.h
+++ b/contrib/libstdc++/include/std/std_stdexcept.h
@@ -1,6 +1,6 @@
// Standard exception classes -*- C++ -*-
-// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2005 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
@@ -15,7 +15,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -27,15 +27,14 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
+/** @file stdexcept
+ * This is a Standard C++ Library header.
+ */
+
//
// ISO C++ 19.1 Exception classes
//
-/** @file stdexcept
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
- */
-
#ifndef _GLIBCXX_STDEXCEPT
#define _GLIBCXX_STDEXCEPT 1
@@ -44,8 +43,8 @@
#include <exception>
#include <string>
-namespace std
-{
+_GLIBCXX_BEGIN_NAMESPACE(std)
+
/** Logic errors represent problems in the internal logic of a program;
* in theory, these are preventable, and even detectable before the
* program runs (e.g., violations of class invariants).
@@ -143,6 +142,7 @@ namespace std
public:
explicit underflow_error(const string& __arg);
};
-} // namespace std
+
+_GLIBCXX_END_NAMESPACE
#endif /* _GLIBCXX_STDEXCEPT */
diff --git a/contrib/libstdc++/include/std/std_streambuf.h b/contrib/libstdc++/include/std/std_streambuf.h
index 42b3d78..9de7907 100644
--- a/contrib/libstdc++/include/std/std_streambuf.h
+++ b/contrib/libstdc++/include/std/std_streambuf.h
@@ -1,6 +1,6 @@
// Stream buffer classes -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -16,7 +16,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -28,17 +28,16 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
+/** @file streambuf
+ * This is a Standard C++ Library header.
+ */
+
//
// ISO C++ 14882: 27.5 Stream buffers
//
-/** @file streambuf
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
- */
-
-#ifndef _CLIBXX_STREAMBUF
-#define _CLIBXX_STREAMBUF 1
+#ifndef _GLIBXX_STREAMBUF
+#define _GLIBXX_STREAMBUF 1
#pragma GCC system_header
@@ -46,9 +45,11 @@
#include <iosfwd>
#include <bits/localefwd.h>
#include <bits/ios_base.h>
+#include <bits/cpp_type_traits.h>
+#include <ext/type_traits.h>
+
+_GLIBCXX_BEGIN_NAMESPACE(std)
-namespace std
-{
/**
* @if maint
* Does stuff.
@@ -56,9 +57,9 @@ namespace std
*/
template<typename _CharT, typename _Traits>
streamsize
- __copy_streambufs(basic_streambuf<_CharT, _Traits>* __sbin,
- basic_streambuf<_CharT, _Traits>* __sbout);
-
+ __copy_streambufs_eof(basic_streambuf<_CharT, _Traits>*,
+ basic_streambuf<_CharT, _Traits>*, bool&);
+
/**
* @brief The actual work of input and output (interface).
*
@@ -152,9 +153,34 @@ namespace std
friend class ostreambuf_iterator<char_type, traits_type>;
friend streamsize
- __copy_streambufs<>(__streambuf_type* __sbin,
- __streambuf_type* __sbout);
-
+ __copy_streambufs_eof<>(__streambuf_type*, __streambuf_type*, bool&);
+
+ template<typename _CharT2>
+ friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value,
+ _CharT2*>::__type
+ __copy_aux(istreambuf_iterator<_CharT2>,
+ istreambuf_iterator<_CharT2>, _CharT2*);
+
+ template<typename _CharT2>
+ friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value,
+ istreambuf_iterator<_CharT2> >::__type
+ find(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>,
+ const _CharT2&);
+
+ template<typename _CharT2, typename _Traits2>
+ friend basic_istream<_CharT2, _Traits2>&
+ operator>>(basic_istream<_CharT2, _Traits2>&, _CharT2*);
+
+ template<typename _CharT2, typename _Traits2, typename _Alloc>
+ friend basic_istream<_CharT2, _Traits2>&
+ operator>>(basic_istream<_CharT2, _Traits2>&,
+ basic_string<_CharT2, _Traits2, _Alloc>&);
+
+ template<typename _CharT2, typename _Traits2, typename _Alloc>
+ friend basic_istream<_CharT2, _Traits2>&
+ getline(basic_istream<_CharT2, _Traits2>&,
+ basic_string<_CharT2, _Traits2, _Alloc>&, _CharT2);
+
protected:
//@{
/**
@@ -775,7 +801,20 @@ namespace std
__streambuf_type&
operator=(const __streambuf_type&) { return *this; };
};
-} // namespace std
+
+ // Explicit specialization declarations, defined in src/streambuf.cc.
+ template<>
+ streamsize
+ __copy_streambufs_eof(basic_streambuf<char>* __sbin,
+ basic_streambuf<char>* __sbout, bool& __ineof);
+#ifdef _GLIBCXX_USE_WCHAR_T
+ template<>
+ streamsize
+ __copy_streambufs_eof(basic_streambuf<wchar_t>* __sbin,
+ basic_streambuf<wchar_t>* __sbout, bool& __ineof);
+#endif
+
+_GLIBCXX_END_NAMESPACE
#ifndef _GLIBCXX_EXPORT_TEMPLATE
# include <bits/streambuf.tcc>
diff --git a/contrib/libstdc++/include/std/std_string.h b/contrib/libstdc++/include/std/std_string.h
index 2b15658..3046946 100644
--- a/contrib/libstdc++/include/std/std_string.h
+++ b/contrib/libstdc++/include/std/std_string.h
@@ -1,6 +1,7 @@
// Components for manipulating sequences of characters -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+// 2006, 2007
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -16,7 +17,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -28,15 +29,14 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
+/** @file include/string
+ * This is a Standard C++ Library header.
+ */
+
//
// ISO C++ 14882: 21 Strings library
//
-/** @file string
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
- */
-
#ifndef _GLIBCXX_STRING
#define _GLIBCXX_STRING 1
@@ -46,8 +46,9 @@
#include <bits/stringfwd.h>
#include <bits/char_traits.h>
#include <memory> // For allocator.
-#include <bits/type_traits.h>
+#include <bits/cpp_type_traits.h>
#include <iosfwd> // For operators >>, <<, and getline decls.
+#include <bits/ostream_insert.h>
#include <bits/stl_iterator.h>
#include <bits/stl_function.h> // For less
#include <bits/basic_string.h>
diff --git a/contrib/libstdc++/include/std/std_utility.h b/contrib/libstdc++/include/std/std_utility.h
index fe93090..84c9131 100644
--- a/contrib/libstdc++/include/std/std_utility.h
+++ b/contrib/libstdc++/include/std/std_utility.h
@@ -15,7 +15,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -53,9 +53,8 @@
* purpose. It is provided "as is" without express or implied warranty.
*/
-/** @file utility
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
+/** @file include/utility
+ * This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_UTILITY
diff --git a/contrib/libstdc++/include/std/std_valarray.h b/contrib/libstdc++/include/std/std_valarray.h
index b893b33..87f30ec 100644
--- a/contrib/libstdc++/include/std/std_valarray.h
+++ b/contrib/libstdc++/include/std/std_valarray.h
@@ -1,6 +1,6 @@
// The template and inlines for the -*- C++ -*- valarray class.
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -16,7 +16,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -28,13 +28,12 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
-// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
-
/** @file valarray
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
+ * This is a Standard C++ Library header.
*/
+// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
+
#ifndef _GLIBCXX_VALARRAY
#define _GLIBCXX_VALARRAY 1
@@ -48,8 +47,8 @@
#include <algorithm>
#include <debug/debug.h>
-namespace std
-{
+_GLIBCXX_BEGIN_NAMESPACE(std)
+
template<class _Clos, typename _Tp>
class _Expr;
@@ -88,13 +87,13 @@ namespace std
template<class _Tp> class mask_array; // masked array
template<class _Tp> class indirect_array; // indirected array
-} // namespace std
+_GLIBCXX_END_NAMESPACE
#include <bits/valarray_array.h>
#include <bits/valarray_before.h>
-namespace std
-{
+_GLIBCXX_BEGIN_NAMESPACE(std)
+
/**
* @brief Smart array designed to support numeric processing.
*
@@ -147,7 +146,8 @@ namespace std
valarray(const indirect_array<_Tp>&);
template<class _Dom>
- valarray(const _Expr<_Dom,_Tp>& __e);
+ valarray(const _Expr<_Dom, _Tp>& __e);
+
~valarray();
// _lib.valarray.assign_ assignment:
@@ -155,7 +155,7 @@ namespace std
* @brief Assign elements to an array.
*
* Assign elements of array to values in @a v. Results are undefined
- * if @a v is not the same size as this array.
+ * if @a v does not have the same size as this array.
*
* @param v Valarray to get values from.
*/
@@ -174,7 +174,7 @@ namespace std
* @brief Assign elements to an array subset.
*
* Assign elements of array to values in @a sa. Results are undefined
- * if @a sa is not the same size as this array.
+ * if @a sa does not have the same size as this array.
*
* @param sa Array slice to get values from.
*/
@@ -184,7 +184,7 @@ namespace std
* @brief Assign elements to an array subset.
*
* Assign elements of array to values in @a ga. Results are undefined
- * if @a ga is not the same size as this array.
+ * if @a ga does not have the same size as this array.
*
* @param ga Array slice to get values from.
*/
@@ -194,7 +194,7 @@ namespace std
* @brief Assign elements to an array subset.
*
* Assign elements of array to values in @a ma. Results are undefined
- * if @a ma is not the same size as this array.
+ * if @a ma does not have the same size as this array.
*
* @param ma Array slice to get values from.
*/
@@ -204,14 +204,14 @@ namespace std
* @brief Assign elements to an array subset.
*
* Assign elements of array to values in @a ia. Results are undefined
- * if @a ia is not the same size as this array.
+ * if @a ia does not have the same size as this array.
*
* @param ia Array slice to get values from.
*/
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:
/**
@@ -231,20 +231,20 @@ namespace std
* @brief Return an array subset.
*
* Returns a new valarray containing the elements of the array
- * indicated by the slice argument. The new valarray is the size of
- * the input slice. @see slice.
+ * indicated by the slice argument. The new valarray has the same size
+ * as the input slice. @see slice.
*
* @param s The source slice.
* @return New valarray containing elements in @a s.
*/
- _Expr<_SClos<_ValArray,_Tp>, _Tp> operator[](slice) const;
+ _Expr<_SClos<_ValArray, _Tp>, _Tp> operator[](slice) const;
/**
* @brief Return a reference to an array subset.
*
* Returns a new valarray containing the elements of the array
- * indicated by the slice argument. The new valarray is the size of
- * the input slice. @see slice.
+ * indicated by the slice argument. The new valarray has the same size
+ * as the input slice. @see slice.
*
* @param s The source slice.
* @return New valarray containing elements in @a s.
@@ -260,14 +260,14 @@ namespace std
* @param s The source slice.
* @return Slice_array referencing elements indicated by @a s.
*/
- _Expr<_GClos<_ValArray,_Tp>, _Tp> operator[](const gslice&) const;
+ _Expr<_GClos<_ValArray, _Tp>, _Tp> operator[](const gslice&) const;
/**
* @brief Return a reference to an array subset.
*
* Returns a new valarray containing the elements of the array
- * indicated by the gslice argument. The new valarray is
- * the size of the input gslice. @see gslice.
+ * indicated by the gslice argument. The new valarray has
+ * the same size as the input gslice. @see gslice.
*
* @param s The source gslice.
* @return New valarray containing elements in @a s.
@@ -286,7 +286,7 @@ namespace std
* @param m The valarray bitmask.
* @return New valarray containing elements indicated by @a m.
*/
- valarray<_Tp> operator[](const valarray<bool>&) const;
+ valarray<_Tp> operator[](const valarray<bool>&) const;
/**
* @brief Return a reference to an array subset.
@@ -405,26 +405,25 @@ namespace std
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:
/// Return the number of elements in array.
@@ -444,16 +443,13 @@ namespace std
/// Return the maximum element using operator<().
_Tp max() const;
- // // FIXME: Extension
- // _Tp product () const;
-
/**
* @brief Return a shifted array.
*
* A new valarray is constructed as a copy of this array with elements
* in shifted positions. For an element with index i, the new position
- * is i - n. The new valarray is the same size as the current one.
- * New elements without a value are set to 0. Elements whos new
+ * is i - n. The new valarray has the same size as the current one.
+ * New elements without a value are set to 0. Elements whose new
* position is outside the bounds of the array are discarded.
*
* Positive arguments shift toward index 0, discarding elements [0, n).
@@ -469,7 +465,7 @@ namespace std
*
* A new valarray is constructed as a copy of this array with elements
* in shifted positions. For an element with index i, the new position
- * is (i - n) % size(). The new valarray is the same size as the
+ * is (i - n) % size(). The new valarray has the same size as the
* current one. Elements that are shifted beyond the array bounds are
* shifted into the other end of the array. No elements are lost.
*
@@ -486,29 +482,29 @@ namespace std
*
* Returns a new valarray with elements assigned to the result of
* applying func to the corresponding element of this array. The new
- * array is the same size as this one.
+ * array has the same size as this one.
*
* @param func Function of Tp returning Tp to apply.
* @return New valarray with transformed elements.
*/
- _Expr<_ValFunClos<_ValArray,_Tp>,_Tp> apply(_Tp func(_Tp)) const;
+ _Expr<_ValFunClos<_ValArray, _Tp>, _Tp> apply(_Tp func(_Tp)) const;
/**
* @brief Apply a function to the array.
*
* Returns a new valarray with elements assigned to the result of
* applying func to the corresponding element of this array. The new
- * array is the same size as this one.
+ * array has the same size as this one.
*
* @param func Function of const Tp& returning Tp to apply.
* @return New valarray with transformed elements.
*/
- _Expr<_RefFunClos<_ValArray,_Tp>,_Tp> apply(_Tp func(const _Tp&)) const;
+ _Expr<_RefFunClos<_ValArray, _Tp>, _Tp> apply(_Tp func(const _Tp&)) const;
/**
* @brief Resize array.
*
- * Resize this array to be @a size and set all elements to @a c. All
+ * Resize this array to @a size and set all elements to @a c. All
* references and iterators are invalidated.
*
* @param size New array size.
@@ -528,7 +524,7 @@ namespace std
valarray<_Tp>::operator[](size_t __i) const
{
__glibcxx_requires_subscript(__i);
- return _M_data[__i];
+ return _M_data[__i];
}
template<typename _Tp>
@@ -536,21 +532,20 @@ namespace std
valarray<_Tp>::operator[](size_t __i)
{
__glibcxx_requires_subscript(__i);
- return _M_data[__i];
+ return _M_data[__i];
}
-} // std::
+_GLIBCXX_END_NAMESPACE
#include <bits/valarray_after.h>
-
#include <bits/slice_array.h>
#include <bits/gslice.h>
#include <bits/gslice_array.h>
#include <bits/mask_array.h>
#include <bits/indirect_array.h>
-namespace std
-{
+_GLIBCXX_BEGIN_NAMESPACE(std)
+
template<typename _Tp>
inline
valarray<_Tp>::valarray() : _M_size(0), _M_data(0) {}
@@ -558,19 +553,19 @@ namespace std
template<typename _Tp>
inline
valarray<_Tp>::valarray(size_t __n)
- : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
+ : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
{ std::__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))
+ : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
{ std::__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))
+ : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
{
_GLIBCXX_DEBUG_ASSERT(__p != 0 || __n == 0);
std::__valarray_copy_construct(__p, __p + __n, _M_data);
@@ -579,25 +574,26 @@ namespace std
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))
- { std::__valarray_copy_construct(__v._M_data, __v._M_data + _M_size, _M_data); }
+ : _M_size(__v._M_size), _M_data(__valarray_get_storage<_Tp>(__v._M_size))
+ { std::__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))
+ : _M_size(__sa._M_sz), _M_data(__valarray_get_storage<_Tp>(__sa._M_sz))
{
- std::__valarray_copy
+ std::__valarray_copy_construct
(__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))
+ : _M_size(__ga._M_index.size()),
+ _M_data(__valarray_get_storage<_Tp>(_M_size))
{
- std::__valarray_copy
+ std::__valarray_copy_construct
(__ga._M_array, _Array<size_t>(__ga._M_index),
_Array<_Tp>(_M_data), _M_size);
}
@@ -605,26 +601,26 @@ namespace std
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))
+ : _M_size(__ma._M_sz), _M_data(__valarray_get_storage<_Tp>(__ma._M_sz))
{
- std::__valarray_copy
+ std::__valarray_copy_construct
(__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))
+ : _M_size(__ia._M_sz), _M_data(__valarray_get_storage<_Tp>(__ia._M_sz))
{
- std::__valarray_copy
+ std::__valarray_copy_construct
(__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))
- { std::__valarray_copy(__e, _M_size, _Array<_Tp>(_M_data)); }
+ : _M_size(__e.size()), _M_data(__valarray_get_storage<_Tp>(_M_size))
+ { std::__valarray_copy_construct(__e, _M_size, _Array<_Tp>(_M_data)); }
template<typename _Tp>
inline
@@ -711,9 +707,7 @@ namespace std
template<typename _Tp>
inline slice_array<_Tp>
valarray<_Tp>::operator[](slice __s)
- {
- return slice_array<_Tp>(_Array<_Tp>(_M_data), __s);
- }
+ { return slice_array<_Tp>(_Array<_Tp>(_M_data), __s); }
template<typename _Tp>
inline _Expr<_GClos<_ValArray,_Tp>, _Tp>
@@ -784,65 +778,91 @@ namespace std
return std::__valarray_sum(_M_data, _M_data + _M_size);
}
-// template<typename _Tp>
-// inline _Tp
-// valarray<_Tp>::product () const
-// {
-// return __valarray_product(_M_data, _M_data + _M_size);
-// }
-
- template <class _Tp>
+ template<class _Tp>
inline valarray<_Tp>
valarray<_Tp>::shift(int __n) const
{
- _Tp* const __a = static_cast<_Tp*>
- (__builtin_alloca(sizeof(_Tp) * _M_size));
- if (__n == 0) // no shift
- std::__valarray_copy_construct(_M_data, _M_data + _M_size, __a);
- else if (__n > 0) // __n > 0: shift left
- {
- if (size_t(__n) > _M_size)
- std::__valarray_default_construct(__a, __a + __n);
- else
- {
- std::__valarray_copy_construct(_M_data+__n, _M_data + _M_size, __a);
- std::__valarray_default_construct(__a+_M_size-__n, __a + _M_size);
- }
- }
- else // __n < 0: shift right
- {
- std::__valarray_copy_construct (_M_data, _M_data+_M_size+__n, __a-__n);
- std::__valarray_default_construct(__a, __a - __n);
- }
- return valarray<_Tp> (__a, _M_size);
+ valarray<_Tp> __ret;
+
+ if (_M_size == 0)
+ return __ret;
+
+ _Tp* __restrict__ __tmp_M_data =
+ std::__valarray_get_storage<_Tp>(_M_size);
+
+ if (__n == 0)
+ std::__valarray_copy_construct(_M_data,
+ _M_data + _M_size, __tmp_M_data);
+ else if (__n > 0) // shift left
+ {
+ if (size_t(__n) > _M_size)
+ __n = _M_size;
+
+ std::__valarray_copy_construct(_M_data + __n,
+ _M_data + _M_size, __tmp_M_data);
+ std::__valarray_default_construct(__tmp_M_data + _M_size - __n,
+ __tmp_M_data + _M_size);
+ }
+ else // shift right
+ {
+ if (size_t(-__n) > _M_size)
+ __n = -_M_size;
+
+ std::__valarray_copy_construct(_M_data, _M_data + _M_size + __n,
+ __tmp_M_data - __n);
+ std::__valarray_default_construct(__tmp_M_data,
+ __tmp_M_data - __n);
+ }
+
+ __ret._M_size = _M_size;
+ __ret._M_data = __tmp_M_data;
+ return __ret;
}
- template <class _Tp>
+ template<class _Tp>
inline valarray<_Tp>
- valarray<_Tp>::cshift (int __n) const
+ valarray<_Tp>::cshift(int __n) const
{
- _Tp* const __a = static_cast<_Tp*>
- (__builtin_alloca (sizeof(_Tp) * _M_size));
- if (__n == 0) // no cshift
- std::__valarray_copy_construct(_M_data, _M_data + _M_size, __a);
- else if (__n > 0) // cshift left
- {
- std::__valarray_copy_construct(_M_data, _M_data+__n, __a+_M_size-__n);
- std::__valarray_copy_construct(_M_data+__n, _M_data + _M_size, __a);
- }
- else // cshift right
- {
- std::__valarray_copy_construct
- (_M_data + _M_size+__n, _M_data + _M_size, __a);
- std::__valarray_copy_construct
- (_M_data, _M_data + _M_size+__n, __a - __n);
- }
- return valarray<_Tp>(__a, _M_size);
+ valarray<_Tp> __ret;
+
+ if (_M_size == 0)
+ return __ret;
+
+ _Tp* __restrict__ __tmp_M_data =
+ std::__valarray_get_storage<_Tp>(_M_size);
+
+ if (__n == 0)
+ std::__valarray_copy_construct(_M_data,
+ _M_data + _M_size, __tmp_M_data);
+ else if (__n > 0) // cshift left
+ {
+ if (size_t(__n) > _M_size)
+ __n = __n % _M_size;
+
+ std::__valarray_copy_construct(_M_data, _M_data + __n,
+ __tmp_M_data + _M_size - __n);
+ std::__valarray_copy_construct(_M_data + __n, _M_data + _M_size,
+ __tmp_M_data);
+ }
+ else // cshift right
+ {
+ if (size_t(-__n) > _M_size)
+ __n = -(size_t(-__n) % _M_size);
+
+ std::__valarray_copy_construct(_M_data + _M_size + __n,
+ _M_data + _M_size, __tmp_M_data);
+ std::__valarray_copy_construct(_M_data, _M_data + _M_size + __n,
+ __tmp_M_data - __n);
+ }
+
+ __ret._M_size = _M_size;
+ __ret._M_data = __tmp_M_data;
+ return __ret;
}
- template <class _Tp>
+ template<class _Tp>
inline void
- valarray<_Tp>::resize (size_t __n, _Tp __c)
+ 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
@@ -862,7 +882,7 @@ namespace std
valarray<_Tp>::min() const
{
_GLIBCXX_DEBUG_ASSERT(_M_size > 0);
- return *std::min_element (_M_data, _M_data+_M_size);
+ return *std::min_element(_M_data, _M_data+_M_size);
}
template<typename _Tp>
@@ -870,34 +890,34 @@ namespace std
valarray<_Tp>::max() const
{
_GLIBCXX_DEBUG_ASSERT(_M_size > 0);
- return *std::max_element (_M_data, _M_data+_M_size);
+ return *std::max_element(_M_data, _M_data+_M_size);
}
template<class _Tp>
- inline _Expr<_ValFunClos<_ValArray,_Tp>,_Tp>
+ 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));
+ typedef _ValFunClos<_ValArray, _Tp> _Closure;
+ return _Expr<_Closure, _Tp>(_Closure(*this, func));
}
template<class _Tp>
- inline _Expr<_RefFunClos<_ValArray,_Tp>,_Tp>
+ 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));
+ typedef _RefFunClos<_ValArray, _Tp> _Closure;
+ return _Expr<_Closure, _Tp>(_Closure(*this, func));
}
#define _DEFINE_VALARRAY_UNARY_OPERATOR(_Op, _Name) \
template<typename _Tp> \
- inline typename valarray<_Tp>::template _UnaryOp<_Name>::_Rt \
- valarray<_Tp>::operator _Op() const \
- { \
- typedef _UnClos<_Name,_ValArray,_Tp> _Closure; \
- typedef typename __fun<_Name, _Tp>::result_type _Rt; \
- return _Expr<_Closure, _Rt>(_Closure(*this)); \
- }
+ inline typename valarray<_Tp>::template _UnaryOp<_Name>::_Rt \
+ valarray<_Tp>::operator _Op() const \
+ { \
+ 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)
@@ -941,7 +961,7 @@ _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(>>, __shift_right)
#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) \
+ valarray<_Tp>::operator _Op##=(const _Expr<_Dom, _Tp>& __e) \
{ \
_Array_augmented_##_Name(_Array<_Tp>(_M_data), __e, _M_size); \
return *this; \
@@ -963,35 +983,35 @@ _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(>>, __shift_right)
#define _DEFINE_BINARY_OPERATOR(_Op, _Name) \
template<typename _Tp> \
- inline _Expr<_BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp>, \
+ inline _Expr<_BinClos<_Name, _ValArray, _ValArray, _Tp, _Tp>, \
typename __fun<_Name, _Tp>::result_type> \
operator _Op(const valarray<_Tp>& __v, const valarray<_Tp>& __w) \
{ \
_GLIBCXX_DEBUG_ASSERT(__v.size() == __w.size()); \
- typedef _BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp> _Closure; \
+ typedef _BinClos<_Name, _ValArray, _ValArray, _Tp, _Tp> _Closure; \
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>, \
- typename __fun<_Name, _Tp>::result_type> \
- operator _Op(const valarray<_Tp>& __v, const _Tp& __t) \
- { \
- typedef _BinClos<_Name,_ValArray,_Constant,_Tp,_Tp> _Closure; \
- typedef typename __fun<_Name, _Tp>::result_type _Rt; \
- return _Expr<_Closure, _Rt>(_Closure(__v, __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; \
+ 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>, \
- typename __fun<_Name, _Tp>::result_type> \
- operator _Op(const _Tp& __t, const valarray<_Tp>& __v) \
- { \
- typedef _BinClos<_Name,_Constant,_ValArray,_Tp,_Tp> _Closure; \
- typedef typename __fun<_Name, _Tp>::result_type _Rt; \
- return _Expr<_Closure, _Tp>(_Closure(__t, __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; \
+ typedef typename __fun<_Name, _Tp>::result_type _Rt; \
+ return _Expr<_Closure, _Tp>(_Closure(__t, __v)); \
+ }
_DEFINE_BINARY_OPERATOR(+, __plus)
_DEFINE_BINARY_OPERATOR(-, __minus)
@@ -1012,6 +1032,8 @@ _DEFINE_BINARY_OPERATOR(>, __greater)
_DEFINE_BINARY_OPERATOR(<=, __less_equal)
_DEFINE_BINARY_OPERATOR(>=, __greater_equal)
-} // namespace std
+#undef _DEFINE_BINARY_OPERATOR
+
+_GLIBCXX_END_NAMESPACE
#endif /* _GLIBCXX_VALARRAY */
diff --git a/contrib/libstdc++/include/std/std_vector.h b/contrib/libstdc++/include/std/std_vector.h
index 16e50a9..a4a527e 100644
--- a/contrib/libstdc++/include/std/std_vector.h
+++ b/contrib/libstdc++/include/std/std_vector.h
@@ -15,7 +15,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -53,9 +53,8 @@
* purpose. It is provided "as is" without express or implied warranty.
*/
-/** @file vector
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
+/** @file include/vector
+ * This is a Standard C++ Library header.
*/
#ifndef _GLIBCXX_VECTOR
OpenPOWER on IntegriCloud