diff options
Diffstat (limited to 'gcc-4.4.3/libstdc++-v3/include/std')
44 files changed, 15183 insertions, 0 deletions
diff --git a/gcc-4.4.3/libstdc++-v3/include/std/algorithm b/gcc-4.4.3/libstdc++-v3/include/std/algorithm new file mode 100644 index 000000000..cb8488c53 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/algorithm @@ -0,0 +1,68 @@ +// <algorithm> -*- C++ -*- + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 +// 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file include/algorithm + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_ALGORITHM +#define _GLIBCXX_ALGORITHM 1 + +#pragma GCC system_header + +#include <bits/stl_algobase.h> +#include <bits/stl_algo.h> + +#ifdef _GLIBCXX_PARALLEL +# include <parallel/algorithm> +#endif + +#endif /* _GLIBCXX_ALGORITHM */ diff --git a/gcc-4.4.3/libstdc++-v3/include/std/array b/gcc-4.4.3/libstdc++-v3/include/std/array new file mode 100644 index 000000000..70e775644 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/array @@ -0,0 +1,60 @@ +// <array> -*- C++ -*- + +// Copyright (C) 2007, 2008, 2009 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file include/array + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_ARRAY +#define _GLIBCXX_ARRAY 1 + +#pragma GCC system_header + +#ifndef __GXX_EXPERIMENTAL_CXX0X__ +# include <c++0x_warning.h> +#else + +#if defined(_GLIBCXX_INCLUDE_AS_TR1) +# error C++0x header cannot be included from TR1 header +#endif + +#include <bits/stl_algobase.h> + +#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# include <tr1_impl/array> +#else +# define _GLIBCXX_INCLUDE_AS_CXX0X +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 +# define _GLIBCXX_END_NAMESPACE_TR1 +# define _GLIBCXX_TR1 +# include <tr1_impl/array> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_CXX0X +#endif + +#endif // __GXX_EXPERIMENTAL_CXX0X__ + +#endif // _GLIBCXX_ARRAY diff --git a/gcc-4.4.3/libstdc++-v3/include/std/bitset b/gcc-4.4.3/libstdc++-v3/include/std/bitset new file mode 100644 index 000000000..5ca442989 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/bitset @@ -0,0 +1,1396 @@ +// <bitset> -*- C++ -*- + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 +// 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/* + * Copyright (c) 1998 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file include/bitset + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_BITSET +#define _GLIBCXX_BITSET 1 + +#pragma GCC system_header + +#include <cstddef> // For size_t +#include <string> +#include <bits/functexcept.h> // For invalid_argument, out_of_range, + // overflow_error +#include <iosfwd> +#include <cxxabi-forced.h> + +#define _GLIBCXX_BITSET_BITS_PER_WORD (__CHAR_BIT__ * sizeof(unsigned long)) +#define _GLIBCXX_BITSET_WORDS(__n) \ + ((__n) < 1 ? 0 : ((__n) + _GLIBCXX_BITSET_BITS_PER_WORD - 1) \ + / _GLIBCXX_BITSET_BITS_PER_WORD) + +_GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) + + /** + * Base class, general case. It is a class invariant that _Nw will be + * nonnegative. + * + * See documentation for bitset. + */ + template<size_t _Nw> + struct _Base_bitset + { + typedef unsigned long _WordT; + + /// 0 is the least significant word. + _WordT _M_w[_Nw]; + + _Base_bitset() + { _M_do_reset(); } + + _Base_bitset(unsigned long __val) + { + _M_do_reset(); + _M_w[0] = __val; + } + + static size_t + _S_whichword(size_t __pos ) + { return __pos / _GLIBCXX_BITSET_BITS_PER_WORD; } + + static size_t + _S_whichbyte(size_t __pos ) + { return (__pos % _GLIBCXX_BITSET_BITS_PER_WORD) / __CHAR_BIT__; } + + static size_t + _S_whichbit(size_t __pos ) + { return __pos % _GLIBCXX_BITSET_BITS_PER_WORD; } + + static _WordT + _S_maskbit(size_t __pos ) + { return (static_cast<_WordT>(1)) << _S_whichbit(__pos); } + + _WordT& + _M_getword(size_t __pos) + { return _M_w[_S_whichword(__pos)]; } + + _WordT + _M_getword(size_t __pos) const + { return _M_w[_S_whichword(__pos)]; } + + _WordT& + _M_hiword() + { return _M_w[_Nw - 1]; } + + _WordT + _M_hiword() const + { return _M_w[_Nw - 1]; } + + void + _M_do_and(const _Base_bitset<_Nw>& __x) + { + for (size_t __i = 0; __i < _Nw; __i++) + _M_w[__i] &= __x._M_w[__i]; + } + + void + _M_do_or(const _Base_bitset<_Nw>& __x) + { + for (size_t __i = 0; __i < _Nw; __i++) + _M_w[__i] |= __x._M_w[__i]; + } + + void + _M_do_xor(const _Base_bitset<_Nw>& __x) + { + for (size_t __i = 0; __i < _Nw; __i++) + _M_w[__i] ^= __x._M_w[__i]; + } + + void + _M_do_left_shift(size_t __shift); + + void + _M_do_right_shift(size_t __shift); + + void + _M_do_flip() + { + for (size_t __i = 0; __i < _Nw; __i++) + _M_w[__i] = ~_M_w[__i]; + } + + void + _M_do_set() + { + for (size_t __i = 0; __i < _Nw; __i++) + _M_w[__i] = ~static_cast<_WordT>(0); + } + + void + _M_do_reset() + { __builtin_memset(_M_w, 0, _Nw * sizeof(_WordT)); } + + bool + _M_is_equal(const _Base_bitset<_Nw>& __x) const + { + for (size_t __i = 0; __i < _Nw; ++__i) + if (_M_w[__i] != __x._M_w[__i]) + return false; + return true; + } + + size_t + _M_are_all_aux() const + { + for (size_t __i = 0; __i < _Nw - 1; __i++) + if (_M_w[__i] != ~static_cast<_WordT>(0)) + return 0; + return ((_Nw - 1) * _GLIBCXX_BITSET_BITS_PER_WORD + + __builtin_popcountl(_M_hiword())); + } + + bool + _M_is_any() const + { + for (size_t __i = 0; __i < _Nw; __i++) + if (_M_w[__i] != static_cast<_WordT>(0)) + return true; + return false; + } + + size_t + _M_do_count() const + { + size_t __result = 0; + for (size_t __i = 0; __i < _Nw; __i++) + __result += __builtin_popcountl(_M_w[__i]); + return __result; + } + + unsigned long + _M_do_to_ulong() const; + + // find first "on" bit + size_t + _M_do_find_first(size_t __not_found) const; + + // find the next "on" bit that follows "prev" + size_t + _M_do_find_next(size_t __prev, size_t __not_found) const; + }; + + // Definitions of non-inline functions from _Base_bitset. + template<size_t _Nw> + void + _Base_bitset<_Nw>::_M_do_left_shift(size_t __shift) + { + if (__builtin_expect(__shift != 0, 1)) + { + const size_t __wshift = __shift / _GLIBCXX_BITSET_BITS_PER_WORD; + const size_t __offset = __shift % _GLIBCXX_BITSET_BITS_PER_WORD; + + if (__offset == 0) + for (size_t __n = _Nw - 1; __n >= __wshift; --__n) + _M_w[__n] = _M_w[__n - __wshift]; + else + { + 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[__wshift] = _M_w[0] << __offset; + } + + std::fill(_M_w + 0, _M_w + __wshift, static_cast<_WordT>(0)); + } + } + + template<size_t _Nw> + void + _Base_bitset<_Nw>::_M_do_right_shift(size_t __shift) + { + if (__builtin_expect(__shift != 0, 1)) + { + const size_t __wshift = __shift / _GLIBCXX_BITSET_BITS_PER_WORD; + const size_t __offset = __shift % _GLIBCXX_BITSET_BITS_PER_WORD; + const size_t __limit = _Nw - __wshift - 1; + + if (__offset == 0) + for (size_t __n = 0; __n <= __limit; ++__n) + _M_w[__n] = _M_w[__n + __wshift]; + else + { + 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[__limit] = _M_w[_Nw-1] >> __offset; + } + + std::fill(_M_w + __limit + 1, _M_w + _Nw, static_cast<_WordT>(0)); + } + } + + template<size_t _Nw> + unsigned long + _Base_bitset<_Nw>::_M_do_to_ulong() const + { + for (size_t __i = 1; __i < _Nw; ++__i) + if (_M_w[__i]) + __throw_overflow_error(__N("_Base_bitset::_M_do_to_ulong")); + return _M_w[0]; + } + + template<size_t _Nw> + size_t + _Base_bitset<_Nw>::_M_do_find_first(size_t __not_found) const + { + for (size_t __i = 0; __i < _Nw; __i++) + { + _WordT __thisword = _M_w[__i]; + if (__thisword != static_cast<_WordT>(0)) + return (__i * _GLIBCXX_BITSET_BITS_PER_WORD + + __builtin_ctzl(__thisword)); + } + // not found, so return an indication of failure. + return __not_found; + } + + template<size_t _Nw> + size_t + _Base_bitset<_Nw>::_M_do_find_next(size_t __prev, size_t __not_found) const + { + // make bound inclusive + ++__prev; + + // check out of bounds + if (__prev >= _Nw * _GLIBCXX_BITSET_BITS_PER_WORD) + return __not_found; + + // search first word + size_t __i = _S_whichword(__prev); + _WordT __thisword = _M_w[__i]; + + // mask off bits below bound + __thisword &= (~static_cast<_WordT>(0)) << _S_whichbit(__prev); + + if (__thisword != static_cast<_WordT>(0)) + return (__i * _GLIBCXX_BITSET_BITS_PER_WORD + + __builtin_ctzl(__thisword)); + + // check subsequent words + __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)); + } + // not found, so return an indication of failure. + return __not_found; + } // end _M_do_find_next + + /** + * Base class, specialization for a single word. + * + * See documentation for bitset. + */ + template<> + struct _Base_bitset<1> + { + typedef unsigned long _WordT; + _WordT _M_w; + + _Base_bitset(void) + : _M_w(0) + { } + + _Base_bitset(unsigned long __val) + : _M_w(__val) + { } + + static size_t + _S_whichword(size_t __pos ) + { return __pos / _GLIBCXX_BITSET_BITS_PER_WORD; } + + static size_t + _S_whichbyte(size_t __pos ) + { return (__pos % _GLIBCXX_BITSET_BITS_PER_WORD) / __CHAR_BIT__; } + + static size_t + _S_whichbit(size_t __pos ) + { return __pos % _GLIBCXX_BITSET_BITS_PER_WORD; } + + static _WordT + _S_maskbit(size_t __pos ) + { return (static_cast<_WordT>(1)) << _S_whichbit(__pos); } + + _WordT& + _M_getword(size_t) + { return _M_w; } + + _WordT + _M_getword(size_t) const + { return _M_w; } + + _WordT& + _M_hiword() + { return _M_w; } + + _WordT + _M_hiword() const + { return _M_w; } + + void + _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; } + + void + _M_do_xor(const _Base_bitset<1>& __x) + { _M_w ^= __x._M_w; } + + void + _M_do_left_shift(size_t __shift) + { _M_w <<= __shift; } + + void + _M_do_right_shift(size_t __shift) + { _M_w >>= __shift; } + + void + _M_do_flip() + { _M_w = ~_M_w; } + + void + _M_do_set() + { _M_w = ~static_cast<_WordT>(0); } + + void + _M_do_reset() + { _M_w = 0; } + + bool + _M_is_equal(const _Base_bitset<1>& __x) const + { return _M_w == __x._M_w; } + + size_t + _M_are_all_aux() const + { return __builtin_popcountl(_M_w); } + + bool + _M_is_any() const + { return _M_w != 0; } + + size_t + _M_do_count() const + { return __builtin_popcountl(_M_w); } + + unsigned long + _M_do_to_ulong() const + { return _M_w; } + + size_t + _M_do_find_first(size_t __not_found) const + { + if (_M_w != 0) + return __builtin_ctzl(_M_w); + else + return __not_found; + } + + // find the next "on" bit that follows "prev" + size_t + _M_do_find_next(size_t __prev, size_t __not_found) const + { + ++__prev; + if (__prev >= ((size_t) _GLIBCXX_BITSET_BITS_PER_WORD)) + return __not_found; + + _WordT __x = _M_w >> __prev; + if (__x != 0) + return __builtin_ctzl(__x) + __prev; + else + return __not_found; + } + }; + + /** + * Base class, specialization for no storage (zero-length %bitset). + * + * See documentation for bitset. + */ + template<> + struct _Base_bitset<0> + { + typedef unsigned long _WordT; + + _Base_bitset() + { } + + _Base_bitset(unsigned long) + { } + + static size_t + _S_whichword(size_t __pos ) + { return __pos / _GLIBCXX_BITSET_BITS_PER_WORD; } + + static size_t + _S_whichbyte(size_t __pos ) + { return (__pos % _GLIBCXX_BITSET_BITS_PER_WORD) / __CHAR_BIT__; } + + static size_t + _S_whichbit(size_t __pos ) + { return __pos % _GLIBCXX_BITSET_BITS_PER_WORD; } + + static _WordT + _S_maskbit(size_t __pos ) + { return (static_cast<_WordT>(1)) << _S_whichbit(__pos); } + + // This would normally give access to the data. The bounds-checking + // in the bitset class will prevent the user from getting this far, + // but (1) it must still return an lvalue to compile, and (2) the + // user might call _Unchecked_set directly, in which case this /needs/ + // to fail. Let's not penalize zero-length users unless they actually + // make an unchecked call; all the memory ugliness is therefore + // localized to this single should-never-get-this-far function. + _WordT& + _M_getword(size_t) const + { + __throw_out_of_range(__N("_Base_bitset::_M_getword")); + return *new _WordT; + } + + _WordT + _M_hiword() const + { return 0; } + + void + _M_do_and(const _Base_bitset<0>&) + { } + + void + _M_do_or(const _Base_bitset<0>&) + { } + + void + _M_do_xor(const _Base_bitset<0>&) + { } + + void + _M_do_left_shift(size_t) + { } + + void + _M_do_right_shift(size_t) + { } + + void + _M_do_flip() + { } + + void + _M_do_set() + { } + + void + _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; } + + size_t + _M_are_all_aux() const + { return 0; } + + bool + _M_is_any() const + { return false; } + + size_t + _M_do_count() const + { return 0; } + + unsigned long + _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; } + + size_t + _M_do_find_next(size_t, size_t) const + { return 0; } + }; + + + // Helper class to zero out the unused high-order bits in the highest word. + template<size_t _Extrabits> + struct _Sanitize + { + static void _S_do_sanitize(unsigned long& __val) + { __val &= ~((~static_cast<unsigned long>(0)) << _Extrabits); } + }; + + template<> + struct _Sanitize<0> + { static void _S_do_sanitize(unsigned long) {} }; + + /** + * @brief The %bitset class represents a @e fixed-size sequence of bits. + * + * @ingroup containers + * + * (Note that %bitset does @e not meet the formal requirements of a + * <a href="tables.html#65">container</a>. Mainly, it lacks iterators.) + * + * The template argument, @a Nb, may be any non-negative number, + * specifying the number of bits (e.g., "0", "12", "1024*1024"). + * + * In the general unoptimized case, storage is allocated in word-sized + * blocks. Let B be the number of bits in a word, then (Nb+(B-1))/B + * words will be used for storage. B - Nb%B bits are unused. (They are + * the high-order bits in the highest word.) It is a class invariant + * that those unused bits are always zero. + * + * If you think of %bitset as "a simple array of bits," be aware that + * your mental picture is reversed: a %bitset behaves the same way as + * bits in integers do, with the bit at index 0 in the "least significant + * / right-hand" position, and the bit at index Nb-1 in the "most + * significant / left-hand" position. Thus, unlike other containers, a + * %bitset's index "counts from right to left," to put it very loosely. + * + * This behavior is preserved when translating to and from strings. For + * example, the first line of the following program probably prints + * "b('a') is 0001100001" on a modern ASCII system. + * + * @code + * #include <bitset> + * #include <iostream> + * #include <sstream> + * + * using namespace std; + * + * int main() + * { + * long a = 'a'; + * bitset<10> b(a); + * + * cout << "b('a') is " << b << endl; + * + * ostringstream s; + * s << b; + * string str = s.str(); + * cout << "index 3 in the string is " << str[3] << " but\n" + * << "index 3 in the bitset is " << b[3] << endl; + * } + * @endcode + * + * Also see: + * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt12ch33s02.html + * for a description of extensions. + * + * Most of the actual code isn't contained in %bitset<> itself, but in the + * base class _Base_bitset. The base class works with whole words, not with + * individual bits. This allows us to specialize _Base_bitset for the + * important special case where the %bitset is only a single word. + * + * Extra confusion can result due to the fact that the storage for + * _Base_bitset @e is a regular array, and is indexed as such. This is + * carefully encapsulated. + */ + 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() + { + _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); + } + + ~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; + } + + // 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, + _CharT('0'), _CharT('1')); + } + + /** + * @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, _CharT('0'), _CharT('1')); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 396. what are characters zero and one. + template<class _CharT, class _Traits, class _Alloc> + bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __s, + size_t __position, size_t __n, + _CharT __zero, _CharT __one = _CharT('1')) + : _Base() + { + if (__position > __s.size()) + __throw_out_of_range(__N("bitset::bitset initial position " + "not valid")); + _M_copy_from_string(__s, __position, __n, __zero, __one); + } + + // 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; + } + + bitset<_Nb>& + operator|=(const bitset<_Nb>& __rhs) + { + this->_M_do_or(__rhs); + return *this; + } + + 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 + this->_M_do_reset(); + 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; + } + + 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; + } + + bitset<_Nb>& + _Unchecked_reset(size_t __pos) + { + this->_M_getword(__pos) &= ~_Base::_S_maskbit(__pos); + return *this; + } + + bitset<_Nb>& + _Unchecked_flip(size_t __pos) + { + this->_M_getword(__pos) ^= _Base::_S_maskbit(__pos); + 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; + } + + /** + * @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); + } + + /** + * @brief Sets every bit to false. + */ + bitset<_Nb>& + reset() + { + this->_M_do_reset(); + 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; + } + + /** + * @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. + * + * _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 + */ + reference + operator[](size_t __position) + { return reference(*this,__position); } + + bool + operator[](size_t __position) const + { return _Unchecked_test(__position); } + //@} + + /** + * @brief Returns 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 Returns 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, _CharT('0'), _CharT('1')); + return __result; + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 396. what are characters zero and one. + template<class _CharT, class _Traits, class _Alloc> + std::basic_string<_CharT, _Traits, _Alloc> + to_string(_CharT __zero, _CharT __one = _CharT('1')) const + { + std::basic_string<_CharT, _Traits, _Alloc> __result; + _M_copy_to_string(__result, __zero, __one); + return __result; + } + + // _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> >(); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 853. to_string needs updating with zero and one. + template<class _CharT, class _Traits> + std::basic_string<_CharT, _Traits, std::allocator<_CharT> > + to_string(_CharT __zero, _CharT __one = _CharT('1')) const + { return to_string<_CharT, _Traits, + std::allocator<_CharT> >(__zero, __one); } + + 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> >(); + } + + template<class _CharT> + std::basic_string<_CharT, std::char_traits<_CharT>, + std::allocator<_CharT> > + to_string(_CharT __zero, _CharT __one = _CharT('1')) const + { + return to_string<_CharT, std::char_traits<_CharT>, + std::allocator<_CharT> >(__zero, __one); + } + + 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> >(); + } + + std::basic_string<char, std::char_traits<char>, std::allocator<char> > + to_string(char __zero, char __one = '1') const + { + return to_string<char, std::char_traits<char>, + std::allocator<char> >(__zero, __one); + } + + // Helper functions for string operations. + template<class _CharT, class _Traits> + void + _M_copy_from_ptr(const _CharT*, size_t, size_t, size_t, + _CharT, _CharT); + + template<class _CharT, class _Traits, class _Alloc> + void + _M_copy_from_string(const std::basic_string<_CharT, + _Traits, _Alloc>& __s, size_t __pos, size_t __n, + _CharT __zero, _CharT __one) + { _M_copy_from_ptr<_CharT, _Traits>(__s.data(), __s.size(), __pos, __n, + __zero, __one); } + + template<class _CharT, class _Traits, class _Alloc> + void + _M_copy_to_string(std::basic_string<_CharT, _Traits, _Alloc>&, + _CharT, _CharT) const; + + // NB: Backward compat. + template<class _CharT, class _Traits, class _Alloc> + void + _M_copy_from_string(const std::basic_string<_CharT, + _Traits, _Alloc>& __s, size_t __pos, size_t __n) + { _M_copy_from_string(__s, __pos, __n, _CharT('0'), _CharT('1')); } + + template<class _CharT, class _Traits, class _Alloc> + void + _M_copy_to_string(std::basic_string<_CharT, _Traits,_Alloc>& __s) const + { _M_copy_to_string(__s, _CharT('0'), _CharT('1')); } + + /// 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); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 693. std::bitset::all() missing. + /** + * @brief Tests whether all the bits are on. + * @return True if all the bits are set. + */ + bool + all() const + { return this->_M_are_all_aux() == _Nb; } + + /** + * @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); } + }; + + // Definitions of non-inline member functions. + template<size_t _Nb> + template<class _CharT, class _Traits> + void + bitset<_Nb>:: + _M_copy_from_ptr(const _CharT* __s, size_t __len, + size_t __pos, size_t __n, _CharT __zero, _CharT __one) + { + reset(); + const size_t __nbits = std::min(_Nb, std::min(__n, __len - __pos)); + for (size_t __i = __nbits; __i > 0; --__i) + { + const _CharT __c = __s[__pos + __nbits - __i]; + if (_Traits::eq(__c, __zero)) + ; + else if (_Traits::eq(__c, __one)) + _Unchecked_set(__i - 1); + else + __throw_invalid_argument(__N("bitset::_M_copy_from_ptr")); + } + } + + template<size_t _Nb> + template<class _CharT, class _Traits, class _Alloc> + void + bitset<_Nb>:: + _M_copy_to_string(std::basic_string<_CharT, _Traits, _Alloc>& __s, + _CharT __zero, _CharT __one) const + { + __s.assign(_Nb, __zero); + for (size_t __i = _Nb; __i > 0; --__i) + if (_Unchecked_test(__i - 1)) + _Traits::assign(__s[_Nb - __i], __one); + } + + // 23.3.5.3 bitset operations: + //@{ + /** + * @brief Global bitwise operations on bitsets. + * @param x A bitset. + * @param y A bitset of the same size as @a x. + * @return A new bitset. + * + * These should be self-explanatory. + */ + template<size_t _Nb> + inline bitset<_Nb> + operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y) + { + bitset<_Nb> __result(__x); + __result &= __y; + return __result; + } + + template<size_t _Nb> + inline bitset<_Nb> + operator|(const bitset<_Nb>& __x, const bitset<_Nb>& __y) + { + bitset<_Nb> __result(__x); + __result |= __y; + return __result; + } + + template <size_t _Nb> + inline bitset<_Nb> + operator^(const bitset<_Nb>& __x, const bitset<_Nb>& __y) + { + bitset<_Nb> __result(__x); + __result ^= __y; + return __result; + } + //@} + + //@{ + /** + * @brief Global I/O operators for bitsets. + * + * Direct I/O between streams and bitsets is supported. Output is + * straightforward. Input will skip whitespace, only accept '0' and '1' + * characters, and will only extract as many digits as the %bitset will + * hold. + */ + template<class _CharT, class _Traits, size_t _Nb> + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x) + { + typedef typename _Traits::char_type char_type; + typedef std::basic_istream<_CharT, _Traits> __istream_type; + typedef typename __istream_type::ios_base __ios_base; + + std::basic_string<_CharT, _Traits> __tmp; + __tmp.reserve(_Nb); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 303. Bitset input operator underspecified + const char_type __zero = __is.widen('0'); + const char_type __one = __is.widen('1'); + + typename __ios_base::iostate __state = __ios_base::goodbit; + typename __istream_type::sentry __sentry(__is); + if (__sentry) + { + __try + { + for (size_t __i = _Nb; __i > 0; --__i) + { + static typename _Traits::int_type __eof = _Traits::eof(); + + typename _Traits::int_type __c1 = __is.rdbuf()->sbumpc(); + if (_Traits::eq_int_type(__c1, __eof)) + { + __state |= __ios_base::eofbit; + break; + } + else + { + const char_type __c2 = _Traits::to_char_type(__c1); + if (_Traits::eq(__c2, __zero)) + __tmp.push_back(__zero); + else if (_Traits::eq(__c2, __one)) + __tmp.push_back(__one); + else if (_Traits:: + eq_int_type(__is.rdbuf()->sputbackc(__c2), + __eof)) + { + __state |= __ios_base::failbit; + break; + } + } + } + } + __catch(__cxxabiv1::__forced_unwind&) + { + __is._M_setstate(__ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { __is._M_setstate(__ios_base::badbit); } + } + + if (__tmp.empty() && _Nb) + __state |= __ios_base::failbit; + else + __x._M_copy_from_string(__tmp, static_cast<size_t>(0), _Nb, + __zero, __one); + if (__state) + __is.setstate(__state); + return __is; + } + + template <class _CharT, class _Traits, size_t _Nb> + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const bitset<_Nb>& __x) + { + std::basic_string<_CharT, _Traits> __tmp; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 396. what are characters zero and one. + const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__os.getloc()); + __x._M_copy_to_string(__tmp, __ct.widen('0'), __ct.widen('1')); + return __os << __tmp; + } + //@} + +_GLIBCXX_END_NESTED_NAMESPACE + +#undef _GLIBCXX_BITSET_WORDS +#undef _GLIBCXX_BITSET_BITS_PER_WORD + +#ifdef _GLIBCXX_DEBUG +# include <debug/bitset> +#endif + +#endif /* _GLIBCXX_BITSET */ diff --git a/gcc-4.4.3/libstdc++-v3/include/std/c++0x_warning.h b/gcc-4.4.3/libstdc++-v3/include/std/c++0x_warning.h new file mode 100644 index 000000000..b74f3396c --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/c++0x_warning.h @@ -0,0 +1,36 @@ +// Copyright (C) 2007, 2009 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file include/c++0x_warning.h + * This is a Standard C++ Library header. + */ + +#ifndef _CXX0X_WARNING_H +#define _CXX0X_WARNING_H 1 + +#ifndef __GXX_EXPERIMENTAL_CXX0X__ +#error This file requires compiler and library support for the upcoming \ +ISO C++ standard, C++0x. This support is currently experimental, and must be \ +enabled with the -std=c++0x or -std=gnu++0x compiler options. +#endif + +#endif diff --git a/gcc-4.4.3/libstdc++-v3/include/std/chrono b/gcc-4.4.3/libstdc++-v3/include/std/chrono new file mode 100644 index 000000000..aaa9646f2 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/chrono @@ -0,0 +1,672 @@ +// <chrono> -*- C++ -*- + +// Copyright (C) 2008, 2009 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file include/chrono + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_CHRONO +#define _GLIBCXX_CHRONO 1 + +#pragma GCC system_header + +#ifndef __GXX_EXPERIMENTAL_CXX0X__ +# include <c++0x_warning.h> +#else + +#ifdef _GLIBCXX_INCLUDE_AS_TR1 +# error C++0x header cannot be included from TR1 header +#endif + +#include <ratio> +#include <type_traits> +#include <limits> +#include <ctime> + +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 + +namespace std +{ + /** + * @defgroup chrono Time + * @ingroup utilities + * + * Classes and functions for time. + * @{ + */ + + /** @namespace std::chrono + * @brief ISO C++ 0x entities sub namespace for time and date. + */ + namespace chrono + { + template<typename _Rep, typename _Period = ratio<1>> + struct duration; + + template<typename _Clock, typename _Duration = typename _Clock::duration> + struct time_point; + } + + // 20.8.2.3 specialization of common_type (for duration) + template<typename _Rep1, typename _Period1, typename _Rep2, typename _Period2> + struct common_type<chrono::duration<_Rep1, _Period1>, + chrono::duration<_Rep2, _Period2>> + { + typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type, + ratio<__static_gcd<_Period1::num, _Period2::num>::value, + (_Period1::den / __static_gcd<_Period1::den, _Period2::den>::value) + * _Period2::den>> type; + }; + + // 20.8.2.3 specialization of common_type (for time_point) + template<typename _Clock, typename _Duration1, typename _Duration2> + struct common_type<chrono::time_point<_Clock, _Duration1>, + chrono::time_point<_Clock, _Duration2>> + { + typedef chrono::time_point<_Clock, + typename common_type<_Duration1, _Duration2>::type> type; + }; + + namespace chrono + { + // Primary template for duration_cast impl. + template<typename _ToDuration, typename _CF, typename _CR, + bool _NumIsOne = false, bool _DenIsOne = false> + struct __duration_cast_impl + { + template<typename _Rep, typename _Period> + static _ToDuration __cast(const duration<_Rep, _Period>& __d) + { + return _ToDuration(static_cast< + typename _ToDuration::rep>(static_cast<_CR>(__d.count()) + * static_cast<_CR>(_CF::num) + / static_cast<_CR>(_CF::den))); + } + }; + + template<typename _ToDuration, typename _CF, typename _CR> + struct __duration_cast_impl<_ToDuration, _CF, _CR, true, true> + { + template<typename _Rep, typename _Period> + static _ToDuration __cast(const duration<_Rep, _Period>& __d) + { + return _ToDuration( + static_cast<typename _ToDuration::rep>(__d.count())); + } + }; + + template<typename _ToDuration, typename _CF, typename _CR> + struct __duration_cast_impl<_ToDuration, _CF, _CR, true, false> + { + template<typename _Rep, typename _Period> + static _ToDuration __cast(const duration<_Rep, _Period>& __d) + { + return _ToDuration(static_cast<typename _ToDuration::rep>( + static_cast<_CR>(__d.count()) / static_cast<_CR>(_CF::den))); + } + }; + + template<typename _ToDuration, typename _CF, typename _CR> + struct __duration_cast_impl<_ToDuration, _CF, _CR, false, true> + { + template<typename _Rep, typename _Period> + static _ToDuration __cast(const duration<_Rep, _Period>& __d) + { + return _ToDuration(static_cast<typename _ToDuration::rep>( + static_cast<_CR>(__d.count()) * static_cast<_CR>(_CF::num))); + } + }; + + /// duration_cast + template<typename _ToDuration, typename _Rep, typename _Period> + inline _ToDuration + duration_cast(const duration<_Rep, _Period>& __d) + { + typedef typename + ratio_divide<_Period, typename _ToDuration::period>::type __cf; + typedef typename + common_type<typename _ToDuration::rep, _Rep, intmax_t>::type __cr; + + return __duration_cast_impl<_ToDuration, __cf, __cr, + __cf::num == 1, __cf::den == 1>::__cast(__d); + } + + /// treat_as_floating_point + template<typename _Rep> + struct treat_as_floating_point + : is_floating_point<_Rep> + { }; + + /// duration_values + template<typename _Rep> + struct duration_values + { + static const _Rep + zero() + { return _Rep(0); } + + static const _Rep + max() + { return numeric_limits<_Rep>::max(); } + + static const _Rep + min() + { return numeric_limits<_Rep>::min(); } + }; + + template<typename _Tp> + struct __is_duration + : std::false_type + { }; + + template<typename _Rep, typename _Period> + struct __is_duration<duration<_Rep, _Period>> + : std::true_type + { }; + + template<typename T> + struct __is_ratio + : std::false_type + { }; + + template<intmax_t _Num, intmax_t _Den> + struct __is_ratio<ratio<_Num, _Den>> + : std::true_type + { }; + + /// duration + template<typename _Rep, typename _Period> + struct duration + { + static_assert(!__is_duration<_Rep>::value, "rep cannot be a duration"); + static_assert(__is_ratio<_Period>::value, + "period must be a specialization of ratio"); + static_assert(_Period::num > 0, "period must be positive"); + + typedef _Rep rep; + typedef _Period period; + + // 20.8.3.1 construction / copy / destroy + duration() = default; + + template<typename _Rep2> + explicit duration(_Rep2 const& __rep) + : __r(static_cast<rep>(__rep)) + { + static_assert(is_convertible<_Rep2,rep>::value + && (treat_as_floating_point<rep>::value + || !treat_as_floating_point<_Rep2>::value), + "cannot construct integral duration with floating point type"); + } + + template<typename _Rep2, typename _Period2> + duration(const duration<_Rep2, _Period2>& __d) + : __r(duration_cast<duration>(__d).count()) + { + static_assert(treat_as_floating_point<rep>::value == true + || ratio_divide<_Period2, period>::type::den == 1, + "the resulting duration is not exactly representable"); + } + + ~duration() = default; + duration(const duration&) = default; + duration& operator=(const duration&) = default; + + // 20.8.3.2 observer + rep + count() const + { return __r; } + + // 20.8.3.3 arithmetic + duration + operator+() const + { return *this; } + + duration + operator-() const + { return duration(-__r); } + + duration& + operator++() + { + ++__r; + return *this; + } + + duration + operator++(int) + { return duration(__r++); } + + duration& + operator--() + { + --__r; + return *this; + } + + duration + operator--(int) + { return duration(__r--); } + + duration& + operator+=(const duration& __d) + { + __r += __d.count(); + return *this; + } + + duration& + operator-=(const duration& __d) + { + __r -= __d.count(); + return *this; + } + + duration& + operator*=(const rep& __rhs) + { + __r *= __rhs; + return *this; + } + + duration& + operator/=(const rep& __rhs) + { + __r /= __rhs; + return *this; + } + + // 20.8.3.4 special values + // TODO: These should be constexprs. + static const duration + zero() + { return duration(duration_values<rep>::zero()); } + + static const duration + min() + { return duration(duration_values<rep>::min()); } + + static const duration + max() + { return duration(duration_values<rep>::max()); } + + private: + rep __r; + }; + + template<typename _Rep1, typename _Period1, + typename _Rep2, typename _Period2> + inline typename common_type<duration<_Rep1, _Period1>, + duration<_Rep2, _Period2>>::type + operator+(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { + typedef typename common_type<duration<_Rep1, _Period1>, + duration<_Rep2, _Period2>>::type __ct; + return __ct(__lhs) += __rhs; + } + + template<typename _Rep1, typename _Period1, + typename _Rep2, typename _Period2> + inline typename common_type<duration<_Rep1, _Period1>, + duration<_Rep2, _Period2>>::type + operator-(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { + typedef typename common_type<duration<_Rep1, _Period1>, + duration<_Rep2, _Period2>>::type __ct; + return __ct(__lhs) -= __rhs; + } + + template<typename _Rep1, typename _Period, typename _Rep2> + inline duration<typename common_type<_Rep1, _Rep2>::type, _Period> + operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s) + { + typedef typename common_type<_Rep1, _Rep2>::type __cr; + return duration<__cr, _Period>(__d) *= __s; + } + + template<typename _Rep1, typename _Period, typename _Rep2> + inline duration<typename common_type<_Rep1, _Rep2>::type, _Period> + operator*(const _Rep2& __s, const duration<_Rep1, _Period>& __d) + { return __d * __s; } + + template<typename _Tp, typename _Up, typename _Ep = void> + struct __division_impl; + + template<typename _Rep1, typename _Period, typename _Rep2> + struct __division_impl<duration<_Rep1, _Period>, _Rep2, + typename enable_if<!__is_duration<_Rep2>::value>::type> + { + typedef typename common_type<_Rep1, _Rep2>::type __cr; + typedef + duration<typename common_type<_Rep1, _Rep2>::type, _Period> __rt; + + static __rt + __divide(const duration<_Rep1, _Period>& __d, const _Rep2& __s) + { return duration<__cr, _Period>(__d) /= __s; } + }; + + template<typename _Rep1, typename _Period1, + typename _Rep2, typename _Period2> + struct __division_impl<duration<_Rep1, _Period1>, + duration<_Rep2, _Period2>> + { + typedef typename common_type<duration<_Rep1, _Period1>, + duration<_Rep2, _Period2>>::type __ct; + typedef typename common_type<_Rep1, _Rep2>::type __rt; + + static __rt + __divide(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { return __ct(__lhs).count() / __ct(__rhs).count(); } + }; + + template<typename _Rep, typename _Period, typename _Up> + inline typename __division_impl<duration<_Rep, _Period>, _Up>::__rt + operator/(const duration<_Rep, _Period>& __d, const _Up& __u) + { + return + __division_impl<duration<_Rep, _Period>, _Up>::__divide(__d, __u); + } + + // comparisons + template<typename _Rep1, typename _Period1, + typename _Rep2, typename _Period2> + inline bool + operator==(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { + typedef typename common_type<duration<_Rep1, _Period1>, + duration<_Rep2, _Period2>>::type __ct; + return __ct(__lhs).count() == __ct(__rhs).count(); + } + + template<typename _Rep1, typename _Period1, + typename _Rep2, typename _Period2> + inline bool + operator<(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { + typedef typename common_type<duration<_Rep1, _Period1>, + duration<_Rep2, _Period2>>::type __ct; + return __ct(__lhs).count() < __ct(__rhs).count(); + } + + template<typename _Rep1, typename _Period1, + typename _Rep2, typename _Period2> + inline bool + operator!=(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { return !(__lhs == __rhs); } + + template<typename _Rep1, typename _Period1, + typename _Rep2, typename _Period2> + inline bool + operator<=(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { return !(__rhs < __lhs); } + + template<typename _Rep1, typename _Period1, + typename _Rep2, typename _Period2> + inline bool + operator>(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { return __rhs < __lhs; } + + template<typename _Rep1, typename _Period1, + typename _Rep2, typename _Period2> + inline bool + operator>=(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { return !(__lhs < __rhs); } + + /// nanoseconds + typedef duration<int64_t, nano> nanoseconds; + + /// microseconds + typedef duration<int64_t, micro> microseconds; + + /// milliseconds + typedef duration<int64_t, milli> milliseconds; + + /// seconds + typedef duration<int64_t > seconds; + + /// minutes + typedef duration<int, ratio< 60>> minutes; + + /// hours + typedef duration<int, ratio<3600>> hours; + + /// time_point + template<typename _Clock, typename _Duration> + struct time_point + { + typedef _Clock clock; + typedef _Duration duration; + typedef typename duration::rep rep; + typedef typename duration::period period; + + time_point() : __d(duration::zero()) + { } + + explicit time_point(const duration& __dur) + : __d(duration::zero() + __dur) + { } + + // conversions + template<typename _Duration2> + time_point(const time_point<clock, _Duration2>& __t) + : __d(__t.time_since_epoch()) + { } + + // observer + duration + time_since_epoch() const + { return __d; } + + // arithmetic + time_point& + operator+=(const duration& __dur) + { + __d += __dur; + return *this; + } + + time_point& + operator-=(const duration& __dur) + { + __d -= __dur; + return *this; + } + + // special values + // TODO: These should be constexprs. + static const time_point + min() + { return time_point(duration::min()); } + + static const time_point + max() + { return time_point(duration::max()); } + + private: + duration __d; + }; + + /// time_point_cast + template<typename _ToDuration, typename _Clock, typename _Duration> + inline time_point<_Clock, _ToDuration> + time_point_cast(const time_point<_Clock, _Duration>& __t) + { + return time_point<_Clock, _ToDuration>( + duration_cast<_ToDuration>(__t.time_since_epoch())); + } + + template<typename _Clock, typename _Duration1, + typename _Rep2, typename _Period2> + inline time_point<_Clock, + typename common_type<_Duration1, duration<_Rep2, _Period2>>::type> + operator+(const time_point<_Clock, _Duration1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { + typedef time_point<_Clock, + typename common_type<_Duration1, + duration<_Rep2, _Period2>>::type> __ct; + return __ct(__lhs) += __rhs; + } + + template<typename _Rep1, typename _Period1, + typename _Clock, typename _Duration2> + inline time_point<_Clock, + typename common_type<duration<_Rep1, _Period1>, _Duration2>::type> + operator+(const duration<_Rep1, _Period1>& __lhs, + const time_point<_Clock, _Duration2>& __rhs) + { return __rhs + __lhs; } + + template<typename _Clock, typename _Duration1, + typename _Rep2, typename _Period2> + inline time_point<_Clock, + typename common_type<_Duration1, duration<_Rep2, _Period2>>::type> + operator-(const time_point<_Clock, _Duration1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { return __lhs + (-__rhs); } + + template<typename _Clock, typename _Duration1, typename _Duration2> + inline typename common_type<_Duration1, _Duration2>::type + operator-(const time_point<_Clock, _Duration1>& __lhs, + const time_point<_Clock, _Duration2>& __rhs) + { return __lhs.time_since_epoch() - __rhs.time_since_epoch(); } + + template<typename _Clock, typename _Duration1, typename _Duration2> + inline bool + operator==(const time_point<_Clock, _Duration1>& __lhs, + const time_point<_Clock, _Duration2>& __rhs) + { return __lhs.time_since_epoch() == __rhs.time_since_epoch(); } + + template<typename _Clock, typename _Duration1, typename _Duration2> + inline bool + operator!=(const time_point<_Clock, _Duration1>& __lhs, + const time_point<_Clock, _Duration2>& __rhs) + { return !(__lhs == __rhs); } + + template<typename _Clock, typename _Duration1, typename _Duration2> + inline bool + operator<(const time_point<_Clock, _Duration1>& __lhs, + const time_point<_Clock, _Duration2>& __rhs) + { return __lhs.time_since_epoch() < __rhs.time_since_epoch(); } + + template<typename _Clock, typename _Duration1, typename _Duration2> + inline bool + operator<=(const time_point<_Clock, _Duration1>& __lhs, + const time_point<_Clock, _Duration2>& __rhs) + { return !(__rhs < __lhs); } + + template<typename _Clock, typename _Duration1, typename _Duration2> + inline bool + operator>(const time_point<_Clock, _Duration1>& __lhs, + const time_point<_Clock, _Duration2>& __rhs) + { return __rhs < __lhs; } + + template<typename _Clock, typename _Duration1, typename _Duration2> + inline bool + operator>=(const time_point<_Clock, _Duration1>& __lhs, + const time_point<_Clock, _Duration2>& __rhs) + { return !(__lhs < __rhs); } + + /// system_clock + struct system_clock + { +#ifdef _GLIBCXX_USE_CLOCK_REALTIME + typedef chrono::nanoseconds duration; +#elif defined(_GLIBCXX_USE_GETTIMEOFDAY) + typedef chrono::microseconds duration; +#else + typedef chrono::seconds duration; +#endif + + typedef duration::rep rep; + typedef duration::period period; + typedef chrono::time_point<system_clock, duration> time_point; + + static const bool is_monotonic = false; + + static time_point + now(); + + // Map to C API + static std::time_t + to_time_t(const time_point& __t) + { + return std::time_t( + duration_cast<chrono::seconds>(__t.time_since_epoch()).count()); + } + + static time_point + from_time_t(std::time_t __t) + { + return time_point_cast<system_clock::duration>( + chrono::time_point<system_clock, chrono::seconds>( + chrono::seconds(__t))); + } + + // TODO: requires constexpr + /* + static_assert( + system_clock::duration::min() < + system_clock::duration::zero(), + "a clock's minimum duration cannot be less than its epoch"); + */ + }; + +#ifdef _GLIBCXX_USE_CLOCK_MONOTONIC + /// monotonic_clock + struct monotonic_clock + { + typedef chrono::nanoseconds duration; + typedef duration::rep rep; + typedef duration::period period; + typedef chrono::time_point<monotonic_clock, duration> time_point; + + static const bool is_monotonic = true; + + static time_point + now(); + }; +#else + typedef system_clock monotonic_clock; +#endif + + typedef system_clock high_resolution_clock; + } // namespace chrono + + // @} group chrono +} // namespace std + +#endif //_GLIBCXX_USE_C99_STDINT_TR1 + +#endif //__GXX_EXPERIMENTAL_CXX0X__ + +#endif //_GLIBCXX_CHRONO diff --git a/gcc-4.4.3/libstdc++-v3/include/std/complex b/gcc-4.4.3/libstdc++-v3/include/std/complex new file mode 100644 index 000000000..4c0d3fbe7 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/complex @@ -0,0 +1,1587 @@ +// The template and inlines for the -*- C++ -*- complex number classes. + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, +// 2006, 2007, 2008, 2009 +// 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file include/complex + * This is a Standard C++ Library header. + */ + +// +// ISO C++ 14882: 26.2 Complex Numbers +// Note: this is not a conforming implementation. +// Initially implemented by Ulrich Drepper <drepper@cygnus.com> +// Improved by Gabriel Dos Reis <dosreis@cmla.ens-cachan.fr> +// + +#ifndef _GLIBCXX_COMPLEX +#define _GLIBCXX_COMPLEX 1 + +#pragma GCC system_header + +#include <bits/c++config.h> +#include <bits/cpp_type_traits.h> +#include <ext/type_traits.h> +#include <cmath> +#include <sstream> + +_GLIBCXX_BEGIN_NAMESPACE(std) + + /** + * @defgroup complex_numbers Complex Numbers + * @ingroup numerics + * + * Classes and functions for complex numbers. + * @{ + */ + + // Forward declarations. + template<typename _Tp> class complex; + template<> class complex<float>; + template<> class complex<double>; + template<> class complex<long double>; + + /// Return magnitude of @a z. + template<typename _Tp> _Tp abs(const complex<_Tp>&); + /// Return phase angle of @a z. + template<typename _Tp> _Tp arg(const complex<_Tp>&); + /// Return @a z magnitude squared. + template<typename _Tp> _Tp norm(const complex<_Tp>&); + + /// Return complex conjugate of @a z. + template<typename _Tp> complex<_Tp> conj(const complex<_Tp>&); + /// Return complex with magnitude @a rho and angle @a theta. + template<typename _Tp> complex<_Tp> polar(const _Tp&, const _Tp& = 0); + + // Transcendentals: + /// Return complex cosine of @a z. + template<typename _Tp> complex<_Tp> cos(const complex<_Tp>&); + /// Return complex hyperbolic cosine of @a z. + template<typename _Tp> complex<_Tp> cosh(const complex<_Tp>&); + /// Return complex base e exponential of @a z. + template<typename _Tp> complex<_Tp> exp(const complex<_Tp>&); + /// Return complex natural logarithm of @a z. + template<typename _Tp> complex<_Tp> log(const complex<_Tp>&); + /// Return complex base 10 logarithm of @a z. + template<typename _Tp> complex<_Tp> log10(const complex<_Tp>&); +#ifndef __GXX_EXPERIMENTAL_CXX0X__ + // DR 844. + /// Return @a x to the @a y'th power. + template<typename _Tp> complex<_Tp> pow(const complex<_Tp>&, int); +#endif + /// Return @a x to the @a y'th power. + 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>&); + /// 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. + template<typename _Tp> complex<_Tp> sin(const complex<_Tp>&); + /// Return complex hyperbolic sine of @a z. + template<typename _Tp> complex<_Tp> sinh(const complex<_Tp>&); + /// Return complex square root of @a z. + template<typename _Tp> complex<_Tp> sqrt(const complex<_Tp>&); + /// Return complex tangent of @a z. + template<typename _Tp> complex<_Tp> tan(const complex<_Tp>&); + /// Return complex hyperbolic tangent of @a z. + template<typename _Tp> complex<_Tp> tanh(const complex<_Tp>&); + + + // 26.2.2 Primary template class complex + /** + * Template to represent complex numbers. + * + * Specializations for float, double, and long double are part of the + * library. Results with any other type are not guaranteed. + * + * @param Tp Type of real and imaginary values. + */ + template<typename _Tp> + struct complex + { + /// Value typedef. + typedef _Tp value_type; + + /// Default constructor. First parameter is x, second parameter is y. + /// Unspecified parameters default to 0. + complex(const _Tp& __r = _Tp(), const _Tp& __i = _Tp()) + : _M_real(__r), _M_imag(__i) { } + + // Lets the compiler synthesize the copy constructor + // complex (const complex<_Tp>&); + /// Copy constructor. + template<typename _Up> + complex(const complex<_Up>& __z) + : _M_real(__z.real()), _M_imag(__z.imag()) { } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 387. std::complex over-encapsulated. + _Tp real() const + { return _M_real; } + + _Tp imag() const + { return _M_imag; } +#else + /// Return real part of complex number. + _Tp& real() + { return _M_real; } + + /// Return real part of complex number. + const _Tp& real() const + { return _M_real; } + + /// Return imaginary part of complex number. + _Tp& imag() + { return _M_imag; } + + /// Return imaginary part of complex number. + const _Tp& imag() const + { return _M_imag; } +#endif + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 387. std::complex over-encapsulated. + void real(_Tp __val) + { _M_real = __val; } + + void imag(_Tp __val) + { _M_imag = __val; } + + /// Assign this complex number to scalar @a t. + complex<_Tp>& operator=(const _Tp&); + + /// Add @a t to this complex number. + // 26.2.5/1 + complex<_Tp>& + operator+=(const _Tp& __t) + { + _M_real += __t; + return *this; + } + + /// Subtract @a t from this complex number. + // 26.2.5/3 + complex<_Tp>& + operator-=(const _Tp& __t) + { + _M_real -= __t; + return *this; + } + + /// Multiply this complex number by @a t. + complex<_Tp>& operator*=(const _Tp&); + /// Divide this complex number by @a t. + complex<_Tp>& operator/=(const _Tp&); + + // Lets the compiler synthesize the + // copy and assignment operator + // complex<_Tp>& operator= (const complex<_Tp>&); + /// Assign this complex number to complex @a z. + template<typename _Up> + complex<_Tp>& operator=(const complex<_Up>&); + /// Add @a z to this complex number. + template<typename _Up> + complex<_Tp>& operator+=(const complex<_Up>&); + /// Subtract @a z from this complex number. + template<typename _Up> + complex<_Tp>& operator-=(const complex<_Up>&); + /// Multiply this complex number by @a z. + template<typename _Up> + complex<_Tp>& operator*=(const complex<_Up>&); + /// Divide this complex number by @a z. + template<typename _Up> + complex<_Tp>& operator/=(const complex<_Up>&); + + const complex& __rep() const + { return *this; } + + private: + _Tp _M_real; + _Tp _M_imag; + }; + + template<typename _Tp> + complex<_Tp>& + complex<_Tp>::operator=(const _Tp& __t) + { + _M_real = __t; + _M_imag = _Tp(); + return *this; + } + + // 26.2.5/5 + template<typename _Tp> + complex<_Tp>& + complex<_Tp>::operator*=(const _Tp& __t) + { + _M_real *= __t; + _M_imag *= __t; + return *this; + } + + // 26.2.5/7 + template<typename _Tp> + complex<_Tp>& + complex<_Tp>::operator/=(const _Tp& __t) + { + _M_real /= __t; + _M_imag /= __t; + return *this; + } + + template<typename _Tp> + template<typename _Up> + complex<_Tp>& + complex<_Tp>::operator=(const complex<_Up>& __z) + { + _M_real = __z.real(); + _M_imag = __z.imag(); + return *this; + } + + // 26.2.5/9 + template<typename _Tp> + template<typename _Up> + complex<_Tp>& + complex<_Tp>::operator+=(const complex<_Up>& __z) + { + _M_real += __z.real(); + _M_imag += __z.imag(); + return *this; + } + + // 26.2.5/11 + template<typename _Tp> + template<typename _Up> + complex<_Tp>& + complex<_Tp>::operator-=(const complex<_Up>& __z) + { + _M_real -= __z.real(); + _M_imag -= __z.imag(); + return *this; + } + + // 26.2.5/13 + // XXX: This is a grammar school implementation. + template<typename _Tp> + template<typename _Up> + complex<_Tp>& + complex<_Tp>::operator*=(const complex<_Up>& __z) + { + const _Tp __r = _M_real * __z.real() - _M_imag * __z.imag(); + _M_imag = _M_real * __z.imag() + _M_imag * __z.real(); + _M_real = __r; + return *this; + } + + // 26.2.5/15 + // XXX: This is a grammar school implementation. + template<typename _Tp> + template<typename _Up> + complex<_Tp>& + complex<_Tp>::operator/=(const complex<_Up>& __z) + { + const _Tp __r = _M_real * __z.real() + _M_imag * __z.imag(); + const _Tp __n = std::norm(__z); + _M_imag = (_M_imag * __z.real() - _M_real * __z.imag()) / __n; + _M_real = __r / __n; + return *this; + } + + // Operators: + //@{ + /// Return new complex value @a x plus @a y. + template<typename _Tp> + inline complex<_Tp> + operator+(const complex<_Tp>& __x, const complex<_Tp>& __y) + { + complex<_Tp> __r = __x; + __r += __y; + return __r; + } + + template<typename _Tp> + inline complex<_Tp> + operator+(const complex<_Tp>& __x, const _Tp& __y) + { + complex<_Tp> __r = __x; + __r += __y; + return __r; + } + + template<typename _Tp> + inline complex<_Tp> + operator+(const _Tp& __x, const complex<_Tp>& __y) + { + complex<_Tp> __r = __y; + __r += __x; + return __r; + } + //@} + + //@{ + /// Return new complex value @a x minus @a y. + template<typename _Tp> + inline complex<_Tp> + operator-(const complex<_Tp>& __x, const complex<_Tp>& __y) + { + complex<_Tp> __r = __x; + __r -= __y; + return __r; + } + + template<typename _Tp> + inline complex<_Tp> + operator-(const complex<_Tp>& __x, const _Tp& __y) + { + complex<_Tp> __r = __x; + __r -= __y; + return __r; + } + + template<typename _Tp> + inline complex<_Tp> + operator-(const _Tp& __x, const complex<_Tp>& __y) + { + complex<_Tp> __r(__x, -__y.imag()); + __r -= __y.real(); + return __r; + } + //@} + + //@{ + /// Return new complex value @a x times @a y. + template<typename _Tp> + inline complex<_Tp> + operator*(const complex<_Tp>& __x, const complex<_Tp>& __y) + { + complex<_Tp> __r = __x; + __r *= __y; + return __r; + } + + template<typename _Tp> + inline complex<_Tp> + operator*(const complex<_Tp>& __x, const _Tp& __y) + { + complex<_Tp> __r = __x; + __r *= __y; + return __r; + } + + template<typename _Tp> + inline complex<_Tp> + operator*(const _Tp& __x, const complex<_Tp>& __y) + { + complex<_Tp> __r = __y; + __r *= __x; + return __r; + } + //@} + + //@{ + /// Return new complex value @a x divided by @a y. + template<typename _Tp> + inline complex<_Tp> + operator/(const complex<_Tp>& __x, const complex<_Tp>& __y) + { + complex<_Tp> __r = __x; + __r /= __y; + return __r; + } + + template<typename _Tp> + inline complex<_Tp> + operator/(const complex<_Tp>& __x, const _Tp& __y) + { + complex<_Tp> __r = __x; + __r /= __y; + return __r; + } + + template<typename _Tp> + inline complex<_Tp> + operator/(const _Tp& __x, const complex<_Tp>& __y) + { + complex<_Tp> __r = __x; + __r /= __y; + return __r; + } + //@} + + /// Return @a x. + template<typename _Tp> + inline complex<_Tp> + operator+(const complex<_Tp>& __x) + { return __x; } + + /// Return complex negation of @a x. + template<typename _Tp> + inline complex<_Tp> + operator-(const complex<_Tp>& __x) + { return complex<_Tp>(-__x.real(), -__x.imag()); } + + //@{ + /// Return true if @a x is equal to @a y. + template<typename _Tp> + inline bool + operator==(const complex<_Tp>& __x, const complex<_Tp>& __y) + { return __x.real() == __y.real() && __x.imag() == __y.imag(); } + + template<typename _Tp> + inline bool + operator==(const complex<_Tp>& __x, const _Tp& __y) + { return __x.real() == __y && __x.imag() == _Tp(); } + + template<typename _Tp> + inline bool + operator==(const _Tp& __x, const complex<_Tp>& __y) + { return __x == __y.real() && _Tp() == __y.imag(); } + //@} + + //@{ + /// Return false if @a x is equal to @a y. + template<typename _Tp> + inline bool + operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y) + { return __x.real() != __y.real() || __x.imag() != __y.imag(); } + + template<typename _Tp> + inline bool + operator!=(const complex<_Tp>& __x, const _Tp& __y) + { return __x.real() != __y || __x.imag() != _Tp(); } + + template<typename _Tp> + inline bool + operator!=(const _Tp& __x, const complex<_Tp>& __y) + { return __x != __y.real() || _Tp() != __y.imag(); } + //@} + + /// Extraction operator for complex values. + template<typename _Tp, typename _CharT, class _Traits> + basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x) + { + _Tp __re_x, __im_x; + _CharT __ch; + __is >> __ch; + if (__ch == '(') + { + __is >> __re_x >> __ch; + if (__ch == ',') + { + __is >> __im_x >> __ch; + if (__ch == ')') + __x = complex<_Tp>(__re_x, __im_x); + else + __is.setstate(ios_base::failbit); + } + else if (__ch == ')') + __x = __re_x; + else + __is.setstate(ios_base::failbit); + } + else + { + __is.putback(__ch); + __is >> __re_x; + __x = __re_x; + } + return __is; + } + + /// Insertion operator for complex values. + template<typename _Tp, typename _CharT, class _Traits> + basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x) + { + basic_ostringstream<_CharT, _Traits> __s; + __s.flags(__os.flags()); + __s.imbue(__os.getloc()); + __s.precision(__os.precision()); + __s << '(' << __x.real() << ',' << __x.imag() << ')'; + return __os << __s.str(); + } + + // Values +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template<typename _Tp> + inline _Tp + real(const complex<_Tp>& __z) + { return __z.real(); } + + template<typename _Tp> + inline _Tp + imag(const complex<_Tp>& __z) + { return __z.imag(); } +#else + template<typename _Tp> + inline _Tp& + real(complex<_Tp>& __z) + { return __z.real(); } + + template<typename _Tp> + inline const _Tp& + real(const complex<_Tp>& __z) + { return __z.real(); } + + template<typename _Tp> + inline _Tp& + imag(complex<_Tp>& __z) + { return __z.imag(); } + + template<typename _Tp> + inline const _Tp& + imag(const complex<_Tp>& __z) + { return __z.imag(); } +#endif + + // 26.2.7/3 abs(__z): Returns the magnitude of __z. + template<typename _Tp> + inline _Tp + __complex_abs(const complex<_Tp>& __z) + { + _Tp __x = __z.real(); + _Tp __y = __z.imag(); + const _Tp __s = std::max(abs(__x), abs(__y)); + if (__s == _Tp()) // well ... + return __s; + __x /= __s; + __y /= __s; + 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 + 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 magnitude of __z. + // As defined, norm() is -not- a norm is the common mathematical + // sens used in numerics. The helper class _Norm_helper<> tries to + // distinguish between builtin floating point and the rest, so as + // to deliver an answer as close as possible to the real value. + template<bool> + struct _Norm_helper + { + template<typename _Tp> + static inline _Tp _S_do_it(const complex<_Tp>& __z) + { + const _Tp __x = __z.real(); + const _Tp __y = __z.imag(); + return __x * __x + __y * __y; + } + }; + + template<> + struct _Norm_helper<true> + { + template<typename _Tp> + static inline _Tp _S_do_it(const complex<_Tp>& __z) + { + _Tp __res = std::abs(__z); + return __res * __res; + } + }; + + template<typename _Tp> + inline _Tp + norm(const complex<_Tp>& __z) + { + return _Norm_helper<__is_floating<_Tp>::__value + && !_GLIBCXX_FAST_MATH>::_S_do_it(__z); + } + + template<typename _Tp> + inline complex<_Tp> + polar(const _Tp& __rho, const _Tp& __theta) + { return complex<_Tp>(__rho * cos(__theta), __rho * sin(__theta)); } + + template<typename _Tp> + inline complex<_Tp> + conj(const complex<_Tp>& __z) + { 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> + __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> + __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> + 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> + exp(const complex<_Tp>& __z) { return __complex_exp(__z); } +#endif + + // 26.2.8/5 log(__z): Returns the natural complex logarithm 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> + __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> + __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> + __complex_sqrt(const complex<_Tp>& __z) + { + _Tp __x = __z.real(); + _Tp __y = __z.imag(); + + if (__x == _Tp()) + { + _Tp __t = sqrt(abs(__y) / 2); + return complex<_Tp>(__t, __y < _Tp() ? -__t : __t); + } + else + { + _Tp __t = sqrt(2 * (std::abs(__z) + abs(__x))); + _Tp __u = __t / 2; + return __x > _Tp() + ? complex<_Tp>(__u, __y / __t) + : complex<_Tp>(abs(__y) / __t, __y < _Tp() ? -__u : __u); + } + } + +#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> + 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> + __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. +#ifndef __GXX_EXPERIMENTAL_CXX0X__ + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 844. complex pow return type is ambiguous. + template<typename _Tp> + inline complex<_Tp> + pow(const complex<_Tp>& __z, int __n) + { return std::__pow_helper(__z, __n); } +#endif + + 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); + + complex<_Tp> __t = std::log(__x); + return std::polar(exp(__y * __t.real()), __y * __t.imag()); + } + + 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 __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> + pow(const _Tp& __x, const complex<_Tp>& __y) + { + return __x > _Tp() ? std::polar(pow(__x, __y.real()), + __y.imag() * log(__x)) + : std::pow(complex<_Tp>(__x), __y); + } + + // 26.2.3 complex specializations + // complex<float> specialization + template<> + struct complex<float> + { + typedef float value_type; + typedef __complex__ float _ComplexT; + + complex(_ComplexT __z) : _M_value(__z) { } + + complex(float __r = 0.0f, float __i = 0.0f) + { + __real__ _M_value = __r; + __imag__ _M_value = __i; + } + + explicit complex(const complex<double>&); + explicit complex(const complex<long double>&); + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 387. std::complex over-encapsulated. + float real() const + { return __real__ _M_value; } + + float imag() const + { return __imag__ _M_value; } +#else + float& real() + { return __real__ _M_value; } + + const float& real() const + { return __real__ _M_value; } + + float& imag() + { return __imag__ _M_value; } + + const float& imag() const + { return __imag__ _M_value; } +#endif + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 387. std::complex over-encapsulated. + void real(float __val) + { __real__ _M_value = __val; } + + void imag(float __val) + { __imag__ _M_value = __val; } + + complex<float>& + operator=(float __f) + { + __real__ _M_value = __f; + __imag__ _M_value = 0.0f; + return *this; + } + + complex<float>& + operator+=(float __f) + { + __real__ _M_value += __f; + return *this; + } + + complex<float>& + operator-=(float __f) + { + __real__ _M_value -= __f; + return *this; + } + + complex<float>& + operator*=(float __f) + { + _M_value *= __f; + return *this; + } + + complex<float>& + operator/=(float __f) + { + _M_value /= __f; + return *this; + } + + // Let the compiler synthesize 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>& __z) + { + __real__ _M_value = __z.real(); + __imag__ _M_value = __z.imag(); + return *this; + } + + template<typename _Tp> + complex<float>& + operator+=(const complex<_Tp>& __z) + { + __real__ _M_value += __z.real(); + __imag__ _M_value += __z.imag(); + return *this; + } + + template<class _Tp> + complex<float>& + operator-=(const complex<_Tp>& __z) + { + __real__ _M_value -= __z.real(); + __imag__ _M_value -= __z.imag(); + return *this; + } + + template<class _Tp> + complex<float>& + operator*=(const complex<_Tp>& __z) + { + _ComplexT __t; + __real__ __t = __z.real(); + __imag__ __t = __z.imag(); + _M_value *= __t; + return *this; + } + + template<class _Tp> + complex<float>& + operator/=(const complex<_Tp>& __z) + { + _ComplexT __t; + __real__ __t = __z.real(); + __imag__ __t = __z.imag(); + _M_value /= __t; + return *this; + } + + const _ComplexT& __rep() const { return _M_value; } + + private: + _ComplexT _M_value; + }; + + // 26.2.3 complex specializations + // complex<double> specialization + template<> + struct complex<double> + { + typedef double value_type; + typedef __complex__ double _ComplexT; + + complex(_ComplexT __z) : _M_value(__z) { } + + complex(double __r = 0.0, double __i = 0.0) + { + __real__ _M_value = __r; + __imag__ _M_value = __i; + } + + complex(const complex<float>& __z) + : _M_value(__z.__rep()) { } + + explicit complex(const complex<long double>&); + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 387. std::complex over-encapsulated. + double real() const + { return __real__ _M_value; } + + double imag() const + { return __imag__ _M_value; } +#else + double& real() + { return __real__ _M_value; } + + const double& real() const + { return __real__ _M_value; } + + double& imag() + { return __imag__ _M_value; } + + const double& imag() const + { return __imag__ _M_value; } +#endif + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 387. std::complex over-encapsulated. + void real(double __val) + { __real__ _M_value = __val; } + + void imag(double __val) + { __imag__ _M_value = __val; } + + complex<double>& + operator=(double __d) + { + __real__ _M_value = __d; + __imag__ _M_value = 0.0; + return *this; + } + + complex<double>& + operator+=(double __d) + { + __real__ _M_value += __d; + return *this; + } + + complex<double>& + operator-=(double __d) + { + __real__ _M_value -= __d; + return *this; + } + + complex<double>& + operator*=(double __d) + { + _M_value *= __d; + return *this; + } + + complex<double>& + operator/=(double __d) + { + _M_value /= __d; + return *this; + } + + // The compiler will synthesize this, efficiently. + // complex& operator=(const complex&); + + template<typename _Tp> + complex<double>& + operator=(const complex<_Tp>& __z) + { + __real__ _M_value = __z.real(); + __imag__ _M_value = __z.imag(); + return *this; + } + + template<typename _Tp> + complex<double>& + operator+=(const complex<_Tp>& __z) + { + __real__ _M_value += __z.real(); + __imag__ _M_value += __z.imag(); + return *this; + } + + template<typename _Tp> + complex<double>& + operator-=(const complex<_Tp>& __z) + { + __real__ _M_value -= __z.real(); + __imag__ _M_value -= __z.imag(); + return *this; + } + + template<typename _Tp> + complex<double>& + operator*=(const complex<_Tp>& __z) + { + _ComplexT __t; + __real__ __t = __z.real(); + __imag__ __t = __z.imag(); + _M_value *= __t; + return *this; + } + + template<typename _Tp> + complex<double>& + operator/=(const complex<_Tp>& __z) + { + _ComplexT __t; + __real__ __t = __z.real(); + __imag__ __t = __z.imag(); + _M_value /= __t; + return *this; + } + + const _ComplexT& __rep() const { return _M_value; } + + private: + _ComplexT _M_value; + }; + + // 26.2.3 complex specializations + // complex<long double> specialization + template<> + struct complex<long double> + { + typedef long double value_type; + typedef __complex__ long double _ComplexT; + + complex(_ComplexT __z) : _M_value(__z) { } + + complex(long double __r = 0.0L, long double __i = 0.0L) + { + __real__ _M_value = __r; + __imag__ _M_value = __i; + } + + complex(const complex<float>& __z) + : _M_value(__z.__rep()) { } + + complex(const complex<double>& __z) + : _M_value(__z.__rep()) { } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 387. std::complex over-encapsulated. + long double real() const + { return __real__ _M_value; } + + long double imag() const + { return __imag__ _M_value; } +#else + long double& real() + { return __real__ _M_value; } + + const long double& real() const + { return __real__ _M_value; } + + long double& imag() + { return __imag__ _M_value; } + + const long double& imag() const + { return __imag__ _M_value; } +#endif + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 387. std::complex over-encapsulated. + void real(long double __val) + { __real__ _M_value = __val; } + + void imag(long double __val) + { __imag__ _M_value = __val; } + + complex<long double>& + operator=(long double __r) + { + __real__ _M_value = __r; + __imag__ _M_value = 0.0L; + return *this; + } + + complex<long double>& + operator+=(long double __r) + { + __real__ _M_value += __r; + return *this; + } + + complex<long double>& + operator-=(long double __r) + { + __real__ _M_value -= __r; + return *this; + } + + complex<long double>& + operator*=(long double __r) + { + _M_value *= __r; + return *this; + } + + complex<long double>& + operator/=(long double __r) + { + _M_value /= __r; + return *this; + } + + // The compiler knows how to do this efficiently + // complex& operator=(const complex&); + + template<typename _Tp> + complex<long double>& + operator=(const complex<_Tp>& __z) + { + __real__ _M_value = __z.real(); + __imag__ _M_value = __z.imag(); + return *this; + } + + template<typename _Tp> + complex<long double>& + operator+=(const complex<_Tp>& __z) + { + __real__ _M_value += __z.real(); + __imag__ _M_value += __z.imag(); + return *this; + } + + template<typename _Tp> + complex<long double>& + operator-=(const complex<_Tp>& __z) + { + __real__ _M_value -= __z.real(); + __imag__ _M_value -= __z.imag(); + return *this; + } + + template<typename _Tp> + complex<long double>& + operator*=(const complex<_Tp>& __z) + { + _ComplexT __t; + __real__ __t = __z.real(); + __imag__ __t = __z.imag(); + _M_value *= __t; + return *this; + } + + template<typename _Tp> + complex<long double>& + operator/=(const complex<_Tp>& __z) + { + _ComplexT __t; + __real__ __t = __z.real(); + __imag__ __t = __z.imag(); + _M_value /= __t; + return *this; + } + + const _ComplexT& __rep() const { return _M_value; } + + private: + _ComplexT _M_value; + }; + + // These bits have to be at the end of this file, so that the + // specializations have all been defined. + inline + complex<float>::complex(const complex<double>& __z) + : _M_value(__z.__rep()) { } + + inline + complex<float>::complex(const complex<long double>& __z) + : _M_value(__z.__rep()) { } + + inline + complex<double>::complex(const complex<long double>& __z) + : _M_value(__z.__rep()) { } + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. + // NB: This syntax is a GNU extension. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template istream& operator>>(istream&, complex<float>&); + extern template ostream& operator<<(ostream&, const complex<float>&); + extern template istream& operator>>(istream&, complex<double>&); + extern template ostream& operator<<(ostream&, const complex<double>&); + extern template istream& operator>>(istream&, complex<long double>&); + extern template ostream& operator<<(ostream&, const complex<long double>&); + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template wistream& operator>>(wistream&, complex<float>&); + extern template wostream& operator<<(wostream&, const complex<float>&); + extern template wistream& operator>>(wistream&, complex<double>&); + extern template wostream& operator<<(wostream&, const complex<double>&); + extern template wistream& operator>>(wistream&, complex<long double>&); + extern template wostream& operator<<(wostream&, const complex<long double>&); +#endif +#endif + + // @} group complex_numbers + +_GLIBCXX_END_NAMESPACE + +_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) + + // See ext/type_traits.h for the primary template. + template<typename _Tp, typename _Up> + struct __promote_2<std::complex<_Tp>, _Up> + { + public: + typedef std::complex<typename __promote_2<_Tp, _Up>::__type> __type; + }; + + template<typename _Tp, typename _Up> + struct __promote_2<_Tp, std::complex<_Up> > + { + public: + typedef std::complex<typename __promote_2<_Tp, _Up>::__type> __type; + }; + + template<typename _Tp, typename _Up> + struct __promote_2<std::complex<_Tp>, std::complex<_Up> > + { + public: + typedef std::complex<typename __promote_2<_Tp, _Up>::__type> __type; + }; + +_GLIBCXX_END_NAMESPACE + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +# if defined(_GLIBCXX_INCLUDE_AS_TR1) +# error C++0x header cannot be included from TR1 header +# endif +# if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# include <tr1_impl/complex> +# else +# define _GLIBCXX_INCLUDE_AS_CXX0X +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 +# define _GLIBCXX_END_NAMESPACE_TR1 +# define _GLIBCXX_TR1 +# include <tr1_impl/complex> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_CXX0X +# endif + +_GLIBCXX_BEGIN_NAMESPACE(std) + + // Forward declarations. + // DR 781. + template<typename _Tp> std::complex<_Tp> proj(const std::complex<_Tp>&); + + template<typename _Tp> + std::complex<_Tp> + __complex_proj(const std::complex<_Tp>& __z) + { + const _Tp __den = (__z.real() * __z.real() + + __z.imag() * __z.imag() + _Tp(1.0)); + + return std::complex<_Tp>((_Tp(2.0) * __z.real()) / __den, + (_Tp(2.0) * __z.imag()) / __den); + } + +#if _GLIBCXX_USE_C99_COMPLEX + inline __complex__ float + __complex_proj(__complex__ float __z) + { return __builtin_cprojf(__z); } + + inline __complex__ double + __complex_proj(__complex__ double __z) + { return __builtin_cproj(__z); } + + inline __complex__ long double + __complex_proj(const __complex__ long double& __z) + { return __builtin_cprojl(__z); } + + template<typename _Tp> + inline std::complex<_Tp> + proj(const std::complex<_Tp>& __z) + { return __complex_proj(__z.__rep()); } +#else + template<typename _Tp> + inline std::complex<_Tp> + proj(const std::complex<_Tp>& __z) + { return __complex_proj(__z); } +#endif + + template<typename _Tp> + inline std::complex<typename __gnu_cxx::__promote<_Tp>::__type> + proj(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return std::proj(std::complex<__type>(__x)); + } + +_GLIBCXX_END_NAMESPACE + +#endif + +#endif /* _GLIBCXX_COMPLEX */ diff --git a/gcc-4.4.3/libstdc++-v3/include/std/condition_variable b/gcc-4.4.3/libstdc++-v3/include/std/condition_variable new file mode 100644 index 000000000..64f2bb771 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/condition_variable @@ -0,0 +1,225 @@ +// <condition_variable> -*- C++ -*- + +// Copyright (C) 2008, 2009 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file condition_variable + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_CONDITION_VARIABLE +#define _GLIBCXX_CONDITION_VARIABLE 1 + +#pragma GCC system_header + +#ifndef __GXX_EXPERIMENTAL_CXX0X__ +# include <c++0x_warning.h> +#else + +#include <chrono> +#include <mutex> // unique_lock + +#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) + +namespace std +{ + /** + * @defgroup condition_variables Condition Variables + * @ingroup concurrency + * + * Classes for condition_variable support. + * @{ + */ + + /// condition_variable + class condition_variable + { + typedef chrono::system_clock __clock_t; + typedef __gthread_cond_t __native_type; + __native_type _M_cond; + + public: + typedef __native_type* native_handle_type; + + condition_variable(); + ~condition_variable(); + + condition_variable(const condition_variable&) = delete; + condition_variable& operator=(const condition_variable&) = delete; + + void + notify_one(); + + void + notify_all(); + + void + wait(unique_lock<mutex>& __lock); + + template<typename _Predicate> + void + wait(unique_lock<mutex>& __lock, _Predicate __p) + { + while (!__p()) + wait(__lock); + } + + template<typename _Duration> + bool + wait_until(unique_lock<mutex>& __lock, + const chrono::time_point<__clock_t, _Duration>& __atime) + { return __wait_until_impl(__lock, __atime); } + + template<typename _Clock, typename _Duration> + bool + wait_until(unique_lock<mutex>& __lock, + const chrono::time_point<_Clock, _Duration>& __atime) + { + // DR 887 - Sync unknown clock to known clock. + typename _Clock::time_point __c_entry = _Clock::now(); + __clock_t::time_point __s_entry = __clock_t::now(); + chrono::nanoseconds __delta = __atime - __c_entry; + __clock_t::time_point __s_atime = __s_entry + __delta; + + return __wait_until_impl(__lock, __s_atime); + } + + template<typename _Clock, typename _Duration, typename _Predicate> + bool + wait_until(unique_lock<mutex>& __lock, + const chrono::time_point<_Clock, _Duration>& __atime, + _Predicate __p) + { + while (!__p()) + if (!wait_until(__lock, __atime)) + return __p(); + + return true; + } + + template<typename _Rep, typename _Period> + bool + wait_for(unique_lock<mutex>& __lock, + const chrono::duration<_Rep, _Period>& __rtime) + { return wait_until(__lock, __clock_t::now() + __rtime); } + + template<typename _Rep, typename _Period, typename _Predicate> + bool + wait_for(unique_lock<mutex>& __lock, + const chrono::duration<_Rep, _Period>& __rtime, + _Predicate __p) + { return wait_until(__lock, __clock_t::now() + __rtime, std::move(__p)); } + + native_handle_type + native_handle() + { return &_M_cond; } + + private: + template<typename _Clock, typename _Duration> + bool + __wait_until_impl(unique_lock<mutex>& __lock, + const chrono::time_point<_Clock, _Duration>& __atime) + { + chrono::time_point<__clock_t, chrono::seconds> __s = + chrono::time_point_cast<chrono::seconds>(__atime); + + chrono::nanoseconds __ns = + chrono::duration_cast<chrono::nanoseconds>(__atime - __s); + + __gthread_time_t __ts = + { + static_cast<std::time_t>(__s.time_since_epoch().count()), + static_cast<long>(__ns.count()) + }; + + __gthread_cond_timedwait(&_M_cond, __lock.mutex()->native_handle(), + &__ts); + + return _Clock::now() < __atime; + } + }; + + /// condition_variable_any + // Like above, only mutex may not have try_lock. + class condition_variable_any + { + typedef __gthread_cond_t __native_type; + __native_type _M_cond; + + public: + typedef __native_type* native_handle_type; + + condition_variable_any(); + ~condition_variable_any(); + + condition_variable_any(const condition_variable_any&) = delete; + condition_variable_any& operator=(const condition_variable_any&) = delete; + + void + notify_one(); + + void + notify_all(); + + template<typename _Lock> + void + wait(_Lock& __lock); + + template<typename _Lock, typename _Predicate> + void + wait(_Lock& __lock, _Predicate __p); + + template<typename _Lock, typename _Clock, typename _Duration> + bool + wait_until(_Lock& __lock, + const chrono::time_point<_Clock, _Duration>& __atime); + + template<typename _Lock, typename _Clock, + typename _Duration, typename _Predicate> + bool + wait_until(_Lock& __lock, + const chrono::time_point<_Clock, _Duration>& __atime, + _Predicate __p); + + template<typename _Lock, typename _Rep, typename _Period> + bool + wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __rtime); + + template<typename _Lock, typename _Rep, + typename _Period, typename _Predicate> + bool + wait_for(_Lock& __lock, + const chrono::duration<_Rep, _Period>& __rtime, _Predicate __p); + + native_handle_type + native_handle() + { return &_M_cond; } + }; + + // @} group condition_variables +} + +#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1 + +#endif // __GXX_EXPERIMENTAL_CXX0X__ + +#endif // _GLIBCXX_CONDITION_VARIABLE diff --git a/gcc-4.4.3/libstdc++-v3/include/std/deque b/gcc-4.4.3/libstdc++-v3/include/std/deque new file mode 100644 index 000000000..8f64b005c --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/deque @@ -0,0 +1,75 @@ +// <deque> -*- C++ -*- + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 +// 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file include/deque + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_DEQUE +#define _GLIBCXX_DEQUE 1 + +#pragma GCC system_header + +#include <bits/stl_algobase.h> +#include <bits/allocator.h> +#include <bits/stl_construct.h> +#include <bits/stl_uninitialized.h> +#include <bits/stl_deque.h> + +#ifndef _GLIBCXX_EXPORT_TEMPLATE +# include <bits/deque.tcc> +#endif + +#ifdef _GLIBCXX_DEBUG +# include <debug/deque> +#endif + +#endif /* _GLIBCXX_DEQUE */ diff --git a/gcc-4.4.3/libstdc++-v3/include/std/forward_list b/gcc-4.4.3/libstdc++-v3/include/std/forward_list new file mode 100644 index 000000000..40a0812c0 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/forward_list @@ -0,0 +1,46 @@ +// <forward_list> -*- C++ -*- + +// Copyright (C) 2008, 2009 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file forward_list + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_FORWARD_LIST +#define _GLIBCXX_FORWARD_LIST 1 + +#pragma GCC system_header + +#ifndef __GXX_EXPERIMENTAL_CXX0X__ +# include <c++0x_warning.h> +#else + +#include <bits/forward_list.h> + +#ifndef _GLIBCXX_EXPORT_TEMPLATE +# include <bits/forward_list.tcc> +#endif + +#endif // __GXX_EXPERIMENTAL_CXX0X__ + +#endif // _GLIBCXX_FORWARD_LIST diff --git a/gcc-4.4.3/libstdc++-v3/include/std/fstream b/gcc-4.4.3/libstdc++-v3/include/std/fstream new file mode 100644 index 000000000..88c1d1488 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/fstream @@ -0,0 +1,918 @@ +// File based streams -*- C++ -*- + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, +// 2006, 2007, 2008, 2009 +// 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file fstream + * This is a Standard C++ Library header. + */ + +// +// ISO C++ 14882: 27.8 File-based streams +// + +#ifndef _GLIBCXX_FSTREAM +#define _GLIBCXX_FSTREAM 1 + +#pragma GCC system_header + +#include <istream> +#include <ostream> +#include <bits/codecvt.h> +#include <cstdio> // For BUFSIZ +#include <bits/basic_file.h> // For __basic_file, __c_lock +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +#include <string> // For std::string overloads. +#endif + +_GLIBCXX_BEGIN_NAMESPACE(std) + + // [27.8.1.1] template class basic_filebuf + /** + * @brief The actual work of input and output (for files). + * @ingroup io + * + * This class associates both its input and output sequence with an + * external disk file, and maintains a joint file position for both + * sequences. Many of its semantics are described in terms of similar + * behavior in the Standard C Library's @c FILE streams. + */ + // Requirements on traits_type, specific to this class: + // traits_type::pos_type must be fpos<traits_type::state_type> + // traits_type::off_type must be streamoff + // traits_type::state_type must be Assignable and DefaultConstructible, + // and traits_type::state_type() must be the initial state for codecvt. + template<typename _CharT, typename _Traits> + class basic_filebuf : public basic_streambuf<_CharT, _Traits> + { + public: + // Types: + typedef _CharT char_type; + typedef _Traits traits_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + + 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. + __c_lock _M_lock; + + // External buffer. + __file_type _M_file; + + /// Place to stash in || out || in | out settings for current filebuf. + ios_base::openmode _M_mode; + + // Beginning state type for codecvt. + __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. + __state_type _M_state_cur; + + // Not used for output. During input, the state that corresponds + // to eback() and _M_ext_buf. + __state_type _M_state_last; + + /// Pointer to the beginning of internal buffer. + char_type* _M_buf; + + /** + * Actual size of internal buffer. This number is equal to the size + * of the put area + 1 position, reserved for the overflow char of + * a full area. + */ + size_t _M_buf_size; + + // Set iff _M_buf is allocated memory from _M_allocate_internal_buffer. + bool _M_buf_allocated; + + /** + * _M_reading == false && _M_writing == false for 'uncommitted' mode; + * _M_reading == true for 'read' mode; + * _M_writing == true for 'write' mode; + * + * NB: _M_reading == true && _M_writing == true is unused. + */ + bool _M_reading; + bool _M_writing; + + //@{ + /** + * Necessary bits for putback buffer management. + * + * @note pbacks of over one character are not currently supported. + */ + char_type _M_pback; + char_type* _M_pback_cur_save; + char_type* _M_pback_end_save; + bool _M_pback_init; + //@} + + // Cached codecvt facet. + const __codecvt_type* _M_codecvt; + + /** + * Buffer for external characters. Used for input when + * codecvt::always_noconv() == false. When valid, this corresponds + * to eback(). + */ + char* _M_ext_buf; + + /** + * Size of buffer held by _M_ext_buf. + */ + streamsize _M_ext_buf_size; + + /** + * Pointers into the buffer held by _M_ext_buf that delimit a + * subsequence of bytes that have been read but not yet converted. + * When valid, _M_ext_next corresponds to egptr(). + */ + const char* _M_ext_next; + char* _M_ext_end; + + /** + * Initializes pback buffers, and moves normal buffers to safety. + * Assumptions: + * _M_in_cur has already been moved back + */ + void + _M_create_pback() + { + if (!_M_pback_init) + { + _M_pback_cur_save = this->gptr(); + _M_pback_end_save = this->egptr(); + this->setg(&_M_pback, &_M_pback, &_M_pback + 1); + _M_pback_init = true; + } + } + + /** + * Deactivates pback buffer contents, and restores normal buffer. + * Assumptions: + * The pback buffer has only moved forward. + */ + void + _M_destroy_pback() throw() + { + if (_M_pback_init) + { + // Length _M_in_cur moved in the pback buffer. + _M_pback_cur_save += this->gptr() != this->eback(); + this->setg(_M_buf, _M_pback_cur_save, _M_pback_end_save); + _M_pback_init = false; + } + } + + public: + // Constructors/destructor: + /** + * @brief Does not open any files. + * + * The default constructor initializes the parent class using its + * own default ctor. + */ + basic_filebuf(); + + /** + * @brief The destructor closes the file first. + */ + virtual + ~basic_filebuf() + { this->close(); } + + // Members: + /** + * @brief Returns true if the external file is open. + */ + bool + is_open() const throw() + { return _M_file.is_open(); } + + /** + * @brief Opens an external file. + * @param s The name of the file. + * @param mode The open mode flags. + * @return @c this on success, NULL on failure + * + * If a file is already open, this function immediately fails. + * Otherwise it tries to open the file named @a s using the flags + * given in @a mode. + * + * Table 92, adapted here, gives the relation between openmode + * combinations and the equivalent fopen() flags. + * (NB: lines app, in|out|app, in|app, binary|app, binary|in|out|app, + * and binary|in|app per DR 596) + * +---------------------------------------------------------+ + * | ios_base Flag combination stdio equivalent | + * |binary in out trunc app | + * +---------------------------------------------------------+ + * | + "w" | + * | + + "a" | + * | + "a" | + * | + + "w" | + * | + "r" | + * | + + "r+" | + * | + + + "w+" | + * | + + + "a+" | + * | + + "a+" | + * +---------------------------------------------------------+ + * | + + "wb" | + * | + + + "ab" | + * | + + "ab" | + * | + + + "wb" | + * | + + "rb" | + * | + + + "r+b" | + * | + + + + "w+b" | + * | + + + + "a+b" | + * | + + + "a+b" | + * +---------------------------------------------------------+ + */ + __filebuf_type* + open(const char* __s, ios_base::openmode __mode); + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** + * @brief Opens an external file. + * @param s The name of the file. + * @param mode The open mode flags. + * @return @c this on success, NULL on failure + */ + __filebuf_type* + open(const std::string& __s, ios_base::openmode __mode) + { return open(__s.c_str(), __mode); } +#endif + + /** + * @brief Closes the currently associated file. + * @return @c this on success, NULL on failure + * + * If no file is currently open, this function immediately fails. + * + * If a "put buffer area" exists, @c overflow(eof) is called to flush + * all the characters. The file is then closed. + * + * If any operations fail, this function also fails. + */ + __filebuf_type* + close(); + + protected: + void + _M_allocate_internal_buffer(); + + void + _M_destroy_internal_buffer() throw(); + + // [27.8.1.4] overridden virtual functions + virtual streamsize + showmanyc(); + + // Stroustrup, 1998, p. 628 + // underflow() and uflow() functions are called to get the next + // character from the real input source when the buffer is empty. + // Buffered input uses underflow() + + virtual int_type + underflow(); + + virtual int_type + pbackfail(int_type __c = _Traits::eof()); + + // Stroustrup, 1998, p 648 + // The overflow() function is called to transfer characters to the + // real output destination when the buffer is full. A call to + // overflow(c) outputs the contents of the buffer plus the + // character c. + // 27.5.2.4.5 + // Consume some sequence of the characters in the pending sequence. + virtual int_type + overflow(int_type __c = _Traits::eof()); + + // Convert internal byte sequence to external, char-based + // sequence via codecvt. + bool + _M_convert_to_external(char_type*, streamsize); + + /** + * @brief Manipulates the buffer. + * @param s Pointer to a buffer area. + * @param n Size of @a s. + * @return @c this + * + * If no file has been opened, and both @a s and @a n are zero, then + * the stream becomes unbuffered. Otherwise, @c s is used as a + * buffer; see + * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch25s02.html + * for more. + */ + virtual __streambuf_type* + setbuf(char_type* __s, streamsize __n); + + virtual pos_type + seekoff(off_type __off, ios_base::seekdir __way, + ios_base::openmode __mode = ios_base::in | ios_base::out); + + virtual pos_type + seekpos(pos_type __pos, + ios_base::openmode __mode = ios_base::in | ios_base::out); + + // Common code for seekoff and seekpos + pos_type + _M_seek(off_type __off, ios_base::seekdir __way, __state_type __state); + + virtual int + sync(); + + virtual void + imbue(const locale& __loc); + + virtual streamsize + xsgetn(char_type* __s, streamsize __n); + + virtual streamsize + xsputn(const char_type* __s, streamsize __n); + + // Flushes output buffer, then writes unshift sequence. + bool + _M_terminate_output(); + + /** + * This function sets the pointers of the internal buffer, both get + * and put areas. Typically: + * + * __off == egptr() - eback() upon underflow/uflow ('read' mode); + * __off == 0 upon overflow ('write' mode); + * __off == -1 upon open, setbuf, seekoff/pos ('uncommitted' mode). + * + * NB: epptr() - pbase() == _M_buf_size - 1, since _M_buf_size + * reflects the actual allocated memory and the last cell is reserved + * for the overflow char of a full put area. + */ + void + _M_set_buffer(streamsize __off) + { + const bool __testin = _M_mode & ios_base::in; + const bool __testout = _M_mode & ios_base::out; + + if (__testin && __off > 0) + this->setg(_M_buf, _M_buf, _M_buf + __off); + else + this->setg(_M_buf, _M_buf, _M_buf); + + if (__testout && __off == 0 && _M_buf_size > 1 ) + this->setp(_M_buf, _M_buf + _M_buf_size - 1); + else + this->setp(NULL, NULL); + } + }; + + // [27.8.1.5] Template class basic_ifstream + /** + * @brief Controlling input for files. + * @ingroup io + * + * This class supports reading from named files, using the inherited + * functions from std::basic_istream. To control the associated + * sequence, an instance of std::basic_filebuf is used, which this page + * refers to as @c sb. + */ + template<typename _CharT, typename _Traits> + class basic_ifstream : public basic_istream<_CharT, _Traits> + { + public: + // Types: + typedef _CharT char_type; + typedef _Traits traits_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + + // Non-standard types: + typedef basic_filebuf<char_type, traits_type> __filebuf_type; + typedef basic_istream<char_type, traits_type> __istream_type; + + private: + __filebuf_type _M_filebuf; + + public: + // Constructors/Destructors: + /** + * @brief Default constructor. + * + * Initializes @c sb using its default constructor, and passes + * @c &sb to the base class initializer. Does not open any files + * (you haven't given it a filename to open). + */ + basic_ifstream() : __istream_type(), _M_filebuf() + { this->init(&_M_filebuf); } + + /** + * @brief Create an input file stream. + * @param s Null terminated string specifying the filename. + * @param mode Open file in specified mode (see std::ios_base). + * + * @c ios_base::in is automatically included in @a mode. + * + * Tip: When using std::string to hold the filename, you must use + * .c_str() before passing it to this constructor. + */ + explicit + basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in) + : __istream_type(), _M_filebuf() + { + this->init(&_M_filebuf); + this->open(__s, __mode); + } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** + * @brief Create an input file stream. + * @param s std::string specifying the filename. + * @param mode Open file in specified mode (see std::ios_base). + * + * @c ios_base::in is automatically included in @a mode. + */ + explicit + basic_ifstream(const std::string& __s, + ios_base::openmode __mode = ios_base::in) + : __istream_type(), _M_filebuf() + { + this->init(&_M_filebuf); + this->open(__s, __mode); + } +#endif + + /** + * @brief The destructor does nothing. + * + * The file is closed by the filebuf object, not the formatting + * stream. + */ + ~basic_ifstream() + { } + + // Members: + /** + * @brief Accessing the underlying buffer. + * @return The current basic_filebuf buffer. + * + * This hides both signatures of std::basic_ios::rdbuf(). + */ + __filebuf_type* + rdbuf() const + { return const_cast<__filebuf_type*>(&_M_filebuf); } + + /** + * @brief Wrapper to test for an open file. + * @return @c rdbuf()->is_open() + */ + bool + is_open() + { return _M_filebuf.is_open(); } + + // _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. + * @param s The name of the file. + * @param mode The open mode flags. + * + * Calls @c std::basic_filebuf::open(s,mode|in). If that function + * fails, @c failbit is set in the stream's error state. + * + * Tip: When using std::string to hold the filename, you must use + * .c_str() before passing it to this constructor. + */ + void + open(const char* __s, ios_base::openmode __mode = ios_base::in) + { + 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(); + } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** + * @brief Opens an external file. + * @param s The name of the file. + * @param mode The open mode flags. + * + * Calls @c std::basic_filebuf::open(s,mode|in). If that function + * fails, @c failbit is set in the stream's error state. + */ + void + open(const std::string& __s, ios_base::openmode __mode = ios_base::in) + { + 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(); + } +#endif + + /** + * @brief Close the file. + * + * Calls @c std::basic_filebuf::close(). If that function + * fails, @c failbit is set in the stream's error state. + */ + void + close() + { + if (!_M_filebuf.close()) + this->setstate(ios_base::failbit); + } + }; + + + // [27.8.1.8] Template class basic_ofstream + /** + * @brief Controlling output for files. + * @ingroup io + * + * This class supports reading from named files, using the inherited + * functions from std::basic_ostream. To control the associated + * sequence, an instance of std::basic_filebuf is used, which this page + * refers to as @c sb. + */ + template<typename _CharT, typename _Traits> + class basic_ofstream : public basic_ostream<_CharT,_Traits> + { + public: + // Types: + typedef _CharT char_type; + typedef _Traits traits_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + + // Non-standard types: + typedef basic_filebuf<char_type, traits_type> __filebuf_type; + typedef basic_ostream<char_type, traits_type> __ostream_type; + + private: + __filebuf_type _M_filebuf; + + public: + // Constructors: + /** + * @brief Default constructor. + * + * Initializes @c sb using its default constructor, and passes + * @c &sb to the base class initializer. Does not open any files + * (you haven't given it a filename to open). + */ + basic_ofstream(): __ostream_type(), _M_filebuf() + { this->init(&_M_filebuf); } + + /** + * @brief Create an output file stream. + * @param s Null terminated string specifying the filename. + * @param mode Open file in specified mode (see std::ios_base). + * + * @c ios_base::out|ios_base::trunc is automatically included in + * @a mode. + * + * Tip: When using std::string to hold the filename, you must use + * .c_str() before passing it to this constructor. + */ + explicit + basic_ofstream(const char* __s, + ios_base::openmode __mode = ios_base::out|ios_base::trunc) + : __ostream_type(), _M_filebuf() + { + this->init(&_M_filebuf); + this->open(__s, __mode); + } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** + * @brief Create an output file stream. + * @param s std::string specifying the filename. + * @param mode Open file in specified mode (see std::ios_base). + * + * @c ios_base::out|ios_base::trunc is automatically included in + * @a mode. + */ + explicit + basic_ofstream(const std::string& __s, + ios_base::openmode __mode = ios_base::out|ios_base::trunc) + : __ostream_type(), _M_filebuf() + { + this->init(&_M_filebuf); + this->open(__s, __mode); + } +#endif + + /** + * @brief The destructor does nothing. + * + * The file is closed by the filebuf object, not the formatting + * stream. + */ + ~basic_ofstream() + { } + + // Members: + /** + * @brief Accessing the underlying buffer. + * @return The current basic_filebuf buffer. + * + * This hides both signatures of std::basic_ios::rdbuf(). + */ + __filebuf_type* + rdbuf() const + { return const_cast<__filebuf_type*>(&_M_filebuf); } + + /** + * @brief Wrapper to test for an open file. + * @return @c rdbuf()->is_open() + */ + bool + is_open() + { return _M_filebuf.is_open(); } + + // _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. + * @param s The name of the file. + * @param mode The open mode flags. + * + * Calls @c std::basic_filebuf::open(s,mode|out|trunc). If that + * function fails, @c failbit is set in the stream's error state. + * + * Tip: When using std::string to hold the filename, you must use + * .c_str() before passing it to this constructor. + */ + void + open(const char* __s, + ios_base::openmode __mode = ios_base::out | ios_base::trunc) + { + 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(); + } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** + * @brief Opens an external file. + * @param s The name of the file. + * @param mode The open mode flags. + * + * Calls @c std::basic_filebuf::open(s,mode|out|trunc). If that + * function fails, @c failbit is set in the stream's error state. + */ + void + open(const std::string& __s, + ios_base::openmode __mode = ios_base::out | ios_base::trunc) + { + 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(); + } +#endif + + /** + * @brief Close the file. + * + * Calls @c std::basic_filebuf::close(). If that function + * fails, @c failbit is set in the stream's error state. + */ + void + close() + { + if (!_M_filebuf.close()) + this->setstate(ios_base::failbit); + } + }; + + + // [27.8.1.11] Template class basic_fstream + /** + * @brief Controlling input and output for files. + * @ingroup io + * + * This class supports reading from and writing to named files, using + * the inherited functions from std::basic_iostream. To control the + * associated sequence, an instance of std::basic_filebuf is used, which + * this page refers to as @c sb. + */ + template<typename _CharT, typename _Traits> + class basic_fstream : public basic_iostream<_CharT, _Traits> + { + public: + // Types: + typedef _CharT char_type; + typedef _Traits traits_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + + // Non-standard types: + typedef basic_filebuf<char_type, traits_type> __filebuf_type; + typedef basic_ios<char_type, traits_type> __ios_type; + typedef basic_iostream<char_type, traits_type> __iostream_type; + + private: + __filebuf_type _M_filebuf; + + public: + // Constructors/destructor: + /** + * @brief Default constructor. + * + * Initializes @c sb using its default constructor, and passes + * @c &sb to the base class initializer. Does not open any files + * (you haven't given it a filename to open). + */ + basic_fstream() + : __iostream_type(), _M_filebuf() + { this->init(&_M_filebuf); } + + /** + * @brief Create an input/output file stream. + * @param s Null terminated string specifying the filename. + * @param mode Open file in specified mode (see std::ios_base). + * + * Tip: When using std::string to hold the filename, you must use + * .c_str() before passing it to this constructor. + */ + explicit + basic_fstream(const char* __s, + ios_base::openmode __mode = ios_base::in | ios_base::out) + : __iostream_type(NULL), _M_filebuf() + { + this->init(&_M_filebuf); + this->open(__s, __mode); + } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** + * @brief Create an input/output file stream. + * @param s Null terminated string specifying the filename. + * @param mode Open file in specified mode (see std::ios_base). + */ + explicit + basic_fstream(const std::string& __s, + ios_base::openmode __mode = ios_base::in | ios_base::out) + : __iostream_type(NULL), _M_filebuf() + { + this->init(&_M_filebuf); + this->open(__s, __mode); + } +#endif + + /** + * @brief The destructor does nothing. + * + * The file is closed by the filebuf object, not the formatting + * stream. + */ + ~basic_fstream() + { } + + // Members: + /** + * @brief Accessing the underlying buffer. + * @return The current basic_filebuf buffer. + * + * This hides both signatures of std::basic_ios::rdbuf(). + */ + __filebuf_type* + rdbuf() const + { return const_cast<__filebuf_type*>(&_M_filebuf); } + + /** + * @brief Wrapper to test for an open file. + * @return @c rdbuf()->is_open() + */ + bool + is_open() + { return _M_filebuf.is_open(); } + + // _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. + * @param s The name of the file. + * @param mode The open mode flags. + * + * Calls @c std::basic_filebuf::open(s,mode). If that + * function fails, @c failbit is set in the stream's error state. + * + * Tip: When using std::string to hold the filename, you must use + * .c_str() before passing it to this constructor. + */ + void + open(const char* __s, + ios_base::openmode __mode = ios_base::in | ios_base::out) + { + 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(); + } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** + * @brief Opens an external file. + * @param s The name of the file. + * @param mode The open mode flags. + * + * Calls @c std::basic_filebuf::open(s,mode). If that + * function fails, @c failbit is set in the stream's error state. + */ + void + open(const std::string& __s, + ios_base::openmode __mode = ios_base::in | ios_base::out) + { + 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(); + } +#endif + + /** + * @brief Close the file. + * + * Calls @c std::basic_filebuf::close(). If that function + * fails, @c failbit is set in the stream's error state. + */ + void + close() + { + if (!_M_filebuf.close()) + this->setstate(ios_base::failbit); + } + }; + +_GLIBCXX_END_NAMESPACE + +#ifndef _GLIBCXX_EXPORT_TEMPLATE +# include <bits/fstream.tcc> +#endif + +#endif /* _GLIBCXX_FSTREAM */ diff --git a/gcc-4.4.3/libstdc++-v3/include/std/functional b/gcc-4.4.3/libstdc++-v3/include/std/functional new file mode 100644 index 000000000..8f4f42ceb --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/functional @@ -0,0 +1,78 @@ +// <functional> -*- C++ -*- + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 +// 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/* + * Copyright (c) 1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ + +/** @file include/functional + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_FUNCTIONAL +#define _GLIBCXX_FUNCTIONAL 1 + +#pragma GCC system_header + +#include <bits/c++config.h> +#include <bits/stl_function.h> + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +# if defined(_GLIBCXX_INCLUDE_AS_TR1) +# error C++0x header cannot be included from TR1 header +# endif +# include <typeinfo> +# include <new> +# include <tuple> +# include <type_traits> +# include <bits/stringfwd.h> +# include <bits/functional_hash.h> +# include <ext/type_traits.h> +# if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# include <tr1_impl/functional> +# else +# define _GLIBCXX_INCLUDE_AS_CXX0X +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 +# define _GLIBCXX_END_NAMESPACE_TR1 +# define _GLIBCXX_TR1 +# include <tr1_impl/functional> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_CXX0X +# endif +#endif + +#endif // _GLIBCXX_FUNCTIONAL diff --git a/gcc-4.4.3/libstdc++-v3/include/std/iomanip b/gcc-4.4.3/libstdc++-v3/include/std/iomanip new file mode 100644 index 000000000..873c76f17 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/iomanip @@ -0,0 +1,296 @@ +// Standard stream manipulators -*- C++ -*- + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +// 2006, 2007, 2009 +// 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file iomanip + * This is a Standard C++ Library header. + */ + +// +// ISO C++ 14882: 27.6.3 Standard manipulators +// + +#ifndef _GLIBCXX_IOMANIP +#define _GLIBCXX_IOMANIP 1 + +#pragma GCC system_header + +#include <bits/c++config.h> +#include <iosfwd> +#include <bits/ios_base.h> + +_GLIBCXX_BEGIN_NAMESPACE(std) + + // [27.6.3] standard manipulators + // Also see DR 183. + + struct _Resetiosflags { ios_base::fmtflags _M_mask; }; + + /** + * @brief Manipulator for @c setf. + * @param mask A format flags mask. + * + * Sent to a stream object, this manipulator resets the specified flags, + * via @e stream.setf(0,mask). + */ + inline _Resetiosflags + resetiosflags(ios_base::fmtflags __mask) + { + _Resetiosflags __x; + __x._M_mask = __mask; + return __x; + } + + template<typename _CharT, typename _Traits> + inline basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __is, _Resetiosflags __f) + { + __is.setf(ios_base::fmtflags(0), __f._M_mask); + return __is; + } + + template<typename _CharT, typename _Traits> + inline basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, _Resetiosflags __f) + { + __os.setf(ios_base::fmtflags(0), __f._M_mask); + return __os; + } + + + struct _Setiosflags { ios_base::fmtflags _M_mask; }; + + /** + * @brief Manipulator for @c setf. + * @param mask A format flags mask. + * + * Sent to a stream object, this manipulator sets the format flags + * to @a mask. + */ + inline _Setiosflags + setiosflags(ios_base::fmtflags __mask) + { + _Setiosflags __x; + __x._M_mask = __mask; + return __x; + } + + template<typename _CharT, typename _Traits> + inline basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __is, _Setiosflags __f) + { + __is.setf(__f._M_mask); + return __is; + } + + template<typename _CharT, typename _Traits> + inline basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, _Setiosflags __f) + { + __os.setf(__f._M_mask); + return __os; + } + + + struct _Setbase { int _M_base; }; + + /** + * @brief Manipulator for @c setf. + * @param base A numeric base. + * + * Sent to a stream object, this manipulator changes the + * @c ios_base::basefield flags to @c oct, @c dec, or @c hex when @a base + * is 8, 10, or 16, accordingly, and to 0 if @a base is any other value. + */ + inline _Setbase + setbase(int __base) + { + _Setbase __x; + __x._M_base = __base; + return __x; + } + + template<typename _CharT, typename _Traits> + inline basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __is, _Setbase __f) + { + __is.setf(__f._M_base == 8 ? ios_base::oct : + __f._M_base == 10 ? ios_base::dec : + __f._M_base == 16 ? ios_base::hex : + ios_base::fmtflags(0), ios_base::basefield); + return __is; + } + + template<typename _CharT, typename _Traits> + inline basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, _Setbase __f) + { + __os.setf(__f._M_base == 8 ? ios_base::oct : + __f._M_base == 10 ? ios_base::dec : + __f._M_base == 16 ? ios_base::hex : + ios_base::fmtflags(0), ios_base::basefield); + return __os; + } + + + template<typename _CharT> + struct _Setfill { _CharT _M_c; }; + + /** + * @brief Manipulator for @c fill. + * @param c The new fill character. + * + * Sent to a stream object, this manipulator calls @c fill(c) for that + * object. + */ + template<typename _CharT> + inline _Setfill<_CharT> + setfill(_CharT __c) + { + _Setfill<_CharT> __x; + __x._M_c = __c; + return __x; + } + + template<typename _CharT, typename _Traits> + inline basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __is, _Setfill<_CharT> __f) + { + __is.fill(__f._M_c); + return __is; + } + + template<typename _CharT, typename _Traits> + inline basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, _Setfill<_CharT> __f) + { + __os.fill(__f._M_c); + return __os; + } + + + struct _Setprecision { int _M_n; }; + + /** + * @brief Manipulator for @c precision. + * @param n The new precision. + * + * Sent to a stream object, this manipulator calls @c precision(n) for + * that object. + */ + inline _Setprecision + setprecision(int __n) + { + _Setprecision __x; + __x._M_n = __n; + return __x; + } + + template<typename _CharT, typename _Traits> + inline basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __is, _Setprecision __f) + { + __is.precision(__f._M_n); + return __is; + } + + template<typename _CharT, typename _Traits> + inline basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, _Setprecision __f) + { + __os.precision(__f._M_n); + return __os; + } + + + struct _Setw { int _M_n; }; + + /** + * @brief Manipulator for @c width. + * @param n The new width. + * + * Sent to a stream object, this manipulator calls @c width(n) for + * that object. + */ + inline _Setw + setw(int __n) + { + _Setw __x; + __x._M_n = __n; + return __x; + } + + template<typename _CharT, typename _Traits> + inline basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __is, _Setw __f) + { + __is.width(__f._M_n); + return __is; + } + + template<typename _CharT, typename _Traits> + inline basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, _Setw __f) + { + __os.width(__f._M_n); + return __os; + } + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. + // NB: This syntax is a GNU extension. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template ostream& operator<<(ostream&, _Setfill<char>); + extern template ostream& operator<<(ostream&, _Setiosflags); + extern template ostream& operator<<(ostream&, _Resetiosflags); + extern template ostream& operator<<(ostream&, _Setbase); + extern template ostream& operator<<(ostream&, _Setprecision); + extern template ostream& operator<<(ostream&, _Setw); + extern template istream& operator>>(istream&, _Setfill<char>); + extern template istream& operator>>(istream&, _Setiosflags); + extern template istream& operator>>(istream&, _Resetiosflags); + extern template istream& operator>>(istream&, _Setbase); + extern template istream& operator>>(istream&, _Setprecision); + extern template istream& operator>>(istream&, _Setw); + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template wostream& operator<<(wostream&, _Setfill<wchar_t>); + extern template wostream& operator<<(wostream&, _Setiosflags); + extern template wostream& operator<<(wostream&, _Resetiosflags); + extern template wostream& operator<<(wostream&, _Setbase); + extern template wostream& operator<<(wostream&, _Setprecision); + extern template wostream& operator<<(wostream&, _Setw); + extern template wistream& operator>>(wistream&, _Setfill<wchar_t>); + extern template wistream& operator>>(wistream&, _Setiosflags); + extern template wistream& operator>>(wistream&, _Resetiosflags); + extern template wistream& operator>>(wistream&, _Setbase); + extern template wistream& operator>>(wistream&, _Setprecision); + extern template wistream& operator>>(wistream&, _Setw); +#endif +#endif + +_GLIBCXX_END_NAMESPACE + +#endif /* _GLIBCXX_IOMANIP */ diff --git a/gcc-4.4.3/libstdc++-v3/include/std/ios b/gcc-4.4.3/libstdc++-v3/include/std/ios new file mode 100644 index 000000000..d561ac663 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/ios @@ -0,0 +1,47 @@ +// Iostreams base classes -*- C++ -*- + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +// 2005, 2006, 2007, 2009 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file ios + * This is a Standard C++ Library header. + */ + +// +// ISO C++ 14882: 27.4 Iostreams base classes +// + +#ifndef _GLIBCXX_IOS +#define _GLIBCXX_IOS 1 + +#pragma GCC system_header + +#include <iosfwd> +#include <exception> // For ios_base::failure +#include <bits/char_traits.h> // For char_traits, streamoff, streamsize, fpos +#include <bits/localefwd.h> // For class locale +#include <bits/ios_base.h> // For ios_base declarations. +#include <streambuf> +#include <bits/basic_ios.h> + +#endif /* _GLIBCXX_IOS */ diff --git a/gcc-4.4.3/libstdc++-v3/include/std/iosfwd b/gcc-4.4.3/libstdc++-v3/include/std/iosfwd new file mode 100644 index 000000000..9bba0ab6b --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/iosfwd @@ -0,0 +1,160 @@ +// Forwarding declarations -*- C++ -*- + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, +// 2006, 2007, 2009 +// 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file iosfwd + * This is a Standard C++ Library header. + */ + +// +// ISO C++ 14882: 27.2 Forward declarations +// + +#ifndef _GLIBCXX_IOSFWD +#define _GLIBCXX_IOSFWD 1 + +#pragma GCC system_header + +#include <bits/c++config.h> +#include <bits/stringfwd.h> // For string forward declarations. +#include <bits/postypes.h> + +_GLIBCXX_BEGIN_NAMESPACE(std) + + template<typename _CharT, typename _Traits = char_traits<_CharT> > + class basic_ios; + + template<typename _CharT, typename _Traits = char_traits<_CharT> > + class basic_streambuf; + + template<typename _CharT, typename _Traits = char_traits<_CharT> > + class basic_istream; + + template<typename _CharT, typename _Traits = char_traits<_CharT> > + class basic_ostream; + + template<typename _CharT, typename _Traits = char_traits<_CharT> > + class basic_iostream; + + template<typename _CharT, typename _Traits = char_traits<_CharT>, + typename _Alloc = allocator<_CharT> > + class basic_stringbuf; + + template<typename _CharT, typename _Traits = char_traits<_CharT>, + typename _Alloc = allocator<_CharT> > + class basic_istringstream; + + template<typename _CharT, typename _Traits = char_traits<_CharT>, + typename _Alloc = allocator<_CharT> > + class basic_ostringstream; + + template<typename _CharT, typename _Traits = char_traits<_CharT>, + typename _Alloc = allocator<_CharT> > + class basic_stringstream; + + template<typename _CharT, typename _Traits = char_traits<_CharT> > + class basic_filebuf; + + template<typename _CharT, typename _Traits = char_traits<_CharT> > + class basic_ifstream; + + template<typename _CharT, typename _Traits = char_traits<_CharT> > + class basic_ofstream; + + template<typename _CharT, typename _Traits = char_traits<_CharT> > + class basic_fstream; + + template<typename _CharT, typename _Traits = char_traits<_CharT> > + class istreambuf_iterator; + + template<typename _CharT, typename _Traits = char_traits<_CharT> > + class ostreambuf_iterator; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // Not included. (??? Apparently no LWG number?) + class ios_base; + + /** + * @defgroup io I/O + * + * Nearly all of the I/O classes are parameterized on the type of + * characters they read and write. (The major exception is ios_base at + * the top of the hierarchy.) This is a change from pre-Standard + * streams, which were not templates. + * + * For ease of use and compatibility, all of the basic_* I/O-related + * classes are given typedef names for both of the builtin character + * widths (wide and narrow). The typedefs are the same as the + * pre-Standard names, for example: + * + * @code + * typedef basic_ifstream<char> ifstream; + * @endcode + * + * Because properly forward-declaring these classes can be difficult, you + * should not do it yourself. Instead, include the <iosfwd> + * header, which contains only declarations of all the I/O classes as + * well as the typedefs. Trying to forward-declare the typedefs + * themselves (e.g., "class ostream;") is not valid ISO C++. + * + * For more specific declarations, see + * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch24.html + * + * @{ + */ + typedef basic_ios<char> ios; ///< @isiosfwd + typedef basic_streambuf<char> streambuf; ///< @isiosfwd + typedef basic_istream<char> istream; ///< @isiosfwd + typedef basic_ostream<char> ostream; ///< @isiosfwd + typedef basic_iostream<char> iostream; ///< @isiosfwd + typedef basic_stringbuf<char> stringbuf; ///< @isiosfwd + typedef basic_istringstream<char> istringstream; ///< @isiosfwd + typedef basic_ostringstream<char> ostringstream; ///< @isiosfwd + typedef basic_stringstream<char> stringstream; ///< @isiosfwd + typedef basic_filebuf<char> filebuf; ///< @isiosfwd + typedef basic_ifstream<char> ifstream; ///< @isiosfwd + typedef basic_ofstream<char> ofstream; ///< @isiosfwd + typedef basic_fstream<char> fstream; ///< @isiosfwd + +#ifdef _GLIBCXX_USE_WCHAR_T + typedef basic_ios<wchar_t> wios; ///< @isiosfwd + typedef basic_streambuf<wchar_t> wstreambuf; ///< @isiosfwd + typedef basic_istream<wchar_t> wistream; ///< @isiosfwd + typedef basic_ostream<wchar_t> wostream; ///< @isiosfwd + typedef basic_iostream<wchar_t> wiostream; ///< @isiosfwd + typedef basic_stringbuf<wchar_t> wstringbuf; ///< @isiosfwd + typedef basic_istringstream<wchar_t> wistringstream; ///< @isiosfwd + typedef basic_ostringstream<wchar_t> wostringstream; ///< @isiosfwd + typedef basic_stringstream<wchar_t> wstringstream; ///< @isiosfwd + typedef basic_filebuf<wchar_t> wfilebuf; ///< @isiosfwd + typedef basic_ifstream<wchar_t> wifstream; ///< @isiosfwd + typedef basic_ofstream<wchar_t> wofstream; ///< @isiosfwd + typedef basic_fstream<wchar_t> wfstream; ///< @isiosfwd +#endif + /** @} */ + +_GLIBCXX_END_NAMESPACE + +#endif /* _GLIBCXX_IOSFWD */ diff --git a/gcc-4.4.3/libstdc++-v3/include/std/iostream b/gcc-4.4.3/libstdc++-v3/include/std/iostream new file mode 100644 index 000000000..e14c4f366 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/iostream @@ -0,0 +1,76 @@ +// Standard iostream objects -*- C++ -*- + +// Copyright (C) 1997, 1998, 1999, 2001, 2002, 2005, 2008, 2009 +// 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file iostream + * This is a Standard C++ Library header. + */ + +// +// ISO C++ 14882: 27.3 Standard iostream objects +// + +#ifndef _GLIBCXX_IOSTREAM +#define _GLIBCXX_IOSTREAM 1 + +#pragma GCC system_header + +#include <bits/c++config.h> +#include <ostream> +#include <istream> + +_GLIBCXX_BEGIN_NAMESPACE(std) + + /** + * @name Standard Stream Objects + * + * The <iostream> header declares the eight <em>standard stream + * objects</em>. For other declarations, see + * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch24.html + * and the @link iosfwd I/O forward declarations @endlink + * + * They are required by default to cooperate with the global C library's + * @c FILE streams, and to be available during program startup and + * termination. For more information, see the HOWTO linked to above. + */ + //@{ + extern istream cin; ///< Linked to standard input + extern ostream cout; ///< Linked to standard output + extern ostream cerr; ///< Linked to standard error (unbuffered) + extern ostream clog; ///< Linked to standard error (buffered) + +#ifdef _GLIBCXX_USE_WCHAR_T + extern wistream wcin; ///< Linked to standard input + extern wostream wcout; ///< Linked to standard output + extern wostream wcerr; ///< Linked to standard error (unbuffered) + extern wostream wclog; ///< Linked to standard error (buffered) +#endif + //@} + + // For construction of filebuffers for cout, cin, cerr, clog et. al. + static ios_base::Init __ioinit; + +_GLIBCXX_END_NAMESPACE + +#endif /* _GLIBCXX_IOSTREAM */ diff --git a/gcc-4.4.3/libstdc++-v3/include/std/istream b/gcc-4.4.3/libstdc++-v3/include/std/istream new file mode 100644 index 000000000..521be7fd5 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/istream @@ -0,0 +1,833 @@ +// Input streams -*- C++ -*- + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, +// 2006, 2007, 2008, 2009 +// 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +// +// ISO C++ 14882: 27.6.1 Input streams +// + +/** @file istream + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_ISTREAM +#define _GLIBCXX_ISTREAM 1 + +#pragma GCC system_header + +#include <ios> +#include <ostream> + +_GLIBCXX_BEGIN_NAMESPACE(std) + + // [27.6.1.1] Template class basic_istream + /** + * @brief Controlling input. + * @ingroup io + * + * This is the base class for all input streams. It provides text + * formatting of all builtin types, and communicates with any class + * derived from basic_streambuf to do the actual input. + */ + template<typename _CharT, typename _Traits> + class basic_istream : virtual public basic_ios<_CharT, _Traits> + { + public: + // Types (inherited from basic_ios (27.4.4)): + typedef _CharT char_type; + typedef typename _Traits::int_type int_type; + typedef typename _Traits::pos_type pos_type; + typedef typename _Traits::off_type off_type; + typedef _Traits traits_type; + + // Non-standard Types: + typedef basic_streambuf<_CharT, _Traits> __streambuf_type; + typedef basic_ios<_CharT, _Traits> __ios_type; + typedef basic_istream<_CharT, _Traits> __istream_type; + typedef num_get<_CharT, istreambuf_iterator<_CharT, _Traits> > + __num_get_type; + typedef ctype<_CharT> __ctype_type; + + protected: + // Data Members: + /** + * The number of characters extracted in the previous unformatted + * function; see gcount(). + */ + streamsize _M_gcount; + + public: + // [27.6.1.1.1] constructor/destructor + /** + * @brief Base constructor. + * + * This ctor is almost never called by the user directly, rather from + * derived classes' initialization lists, which pass a pointer to + * their own stream buffer. + */ + explicit + basic_istream(__streambuf_type* __sb) + : _M_gcount(streamsize(0)) + { this->init(__sb); } + + /** + * @brief Base destructor. + * + * This does very little apart from providing a virtual base dtor. + */ + virtual + ~basic_istream() + { _M_gcount = streamsize(0); } + + // [27.6.1.1.2] prefix/suffix + class sentry; + friend class sentry; + + // [27.6.1.2] formatted input + // [27.6.1.2.3] basic_istream::operator>> + //@{ + /** + * @brief Interface for manipulators. + * + * Manipulators such as @c std::ws and @c std::dec use these + * functions in constructs like "std::cin >> std::ws". For more + * information, see the iomanip header. + */ + __istream_type& + operator>>(__istream_type& (*__pf)(__istream_type&)) + { return __pf(*this); } + + __istream_type& + operator>>(__ios_type& (*__pf)(__ios_type&)) + { + __pf(*this); + return *this; + } + + __istream_type& + operator>>(ios_base& (*__pf)(ios_base&)) + { + __pf(*this); + return *this; + } + //@} + + // [27.6.1.2.2] arithmetic extractors + /** + * @name Arithmetic Extractors + * + * All the @c operator>> functions (aka <em>formatted input + * functions</em>) have some common behavior. Each starts by + * constructing a temporary object of type std::basic_istream::sentry + * with the second argument (noskipws) set to false. This has several + * effects, concluding with the setting of a status flag; see the + * sentry documentation for more. + * + * If the sentry status is good, the function tries to extract + * whatever data is appropriate for the type of the argument. + * + * If an exception is thrown during extraction, ios_base::badbit + * will be turned on in the stream's error state without causing an + * ios_base::failure to be thrown. The original exception will then + * be rethrown. + */ + //@{ + /** + * @brief Basic arithmetic extractors + * @param A variable of builtin type. + * @return @c *this if successful + * + * These functions use the stream's current locale (specifically, the + * @c num_get facet) to parse the input data. + */ + __istream_type& + operator>>(bool& __n) + { return _M_extract(__n); } + + __istream_type& + operator>>(short& __n); + + __istream_type& + operator>>(unsigned short& __n) + { return _M_extract(__n); } + + __istream_type& + operator>>(int& __n); + + __istream_type& + operator>>(unsigned int& __n) + { return _M_extract(__n); } + + __istream_type& + operator>>(long& __n) + { return _M_extract(__n); } + + __istream_type& + operator>>(unsigned long& __n) + { return _M_extract(__n); } + +#ifdef _GLIBCXX_USE_LONG_LONG + __istream_type& + operator>>(long long& __n) + { return _M_extract(__n); } + + __istream_type& + operator>>(unsigned long long& __n) + { return _M_extract(__n); } +#endif + + __istream_type& + operator>>(float& __f) + { return _M_extract(__f); } + + __istream_type& + operator>>(double& __f) + { return _M_extract(__f); } + + __istream_type& + operator>>(long double& __f) + { return _M_extract(__f); } + + __istream_type& + operator>>(void*& __p) + { return _M_extract(__p); } + + /** + * @brief Extracting into another streambuf. + * @param sb A pointer to a streambuf + * + * This function behaves like one of the basic arithmetic extractors, + * in that it also constructs a sentry object and has the same error + * handling behavior. + * + * If @a sb is NULL, the stream will set failbit in its error state. + * + * Characters are extracted from this stream and inserted into the + * @a sb streambuf until one of the following occurs: + * + * - the input stream reaches end-of-file, + * - insertion into the output buffer fails (in this case, the + * character that would have been inserted is not extracted), or + * - an exception occurs (and in this case is caught) + * + * If the function inserts no characters, failbit is set. + */ + __istream_type& + operator>>(__streambuf_type* __sb); + //@} + + // [27.6.1.3] unformatted input + /** + * @brief Character counting + * @return The number of characters extracted by the previous + * unformatted input function dispatched for this stream. + */ + streamsize + gcount() const + { return _M_gcount; } + + /** + * @name Unformatted Input Functions + * + * All the unformatted input functions have some common behavior. + * Each starts by constructing a temporary object of type + * std::basic_istream::sentry with the second argument (noskipws) + * set to true. This has several effects, concluding with the + * setting of a status flag; see the sentry documentation for more. + * + * If the sentry status is good, the function tries to extract + * whatever data is appropriate for the type of the argument. + * + * The number of characters extracted is stored for later retrieval + * by gcount(). + * + * If an exception is thrown during extraction, ios_base::badbit + * will be turned on in the stream's error state without causing an + * ios_base::failure to be thrown. The original exception will then + * be rethrown. + */ + //@{ + /** + * @brief Simple extraction. + * @return A character, or eof(). + * + * Tries to extract a character. If none are available, sets failbit + * and returns traits::eof(). + */ + int_type + get(); + + /** + * @brief Simple extraction. + * @param c The character in which to store data. + * @return *this + * + * Tries to extract a character and store it in @a c. If none are + * available, sets failbit and returns traits::eof(). + * + * @note This function is not overloaded on signed char and + * unsigned char. + */ + __istream_type& + get(char_type& __c); + + /** + * @brief Simple multiple-character extraction. + * @param s Pointer to an array. + * @param n Maximum number of characters to store in @a s. + * @param delim A "stop" character. + * @return *this + * + * Characters are extracted and stored into @a s until one of the + * following happens: + * + * - @c n-1 characters are stored + * - the input sequence reaches EOF + * - the next character equals @a delim, in which case the character + * is not extracted + * + * If no characters are stored, failbit is set in the stream's error + * state. + * + * In any case, a null character is stored into the next location in + * the array. + * + * @note This function is not overloaded on signed char and + * unsigned char. + */ + __istream_type& + get(char_type* __s, streamsize __n, char_type __delim); + + /** + * @brief Simple multiple-character extraction. + * @param s Pointer to an array. + * @param n Maximum number of characters to store in @a s. + * @return *this + * + * Returns @c get(s,n,widen('\n')). + */ + __istream_type& + get(char_type* __s, streamsize __n) + { return this->get(__s, __n, this->widen('\n')); } + + /** + * @brief Extraction into another streambuf. + * @param sb A streambuf in which to store data. + * @param delim A "stop" character. + * @return *this + * + * Characters are extracted and inserted into @a sb until one of the + * following happens: + * + * - the input sequence reaches EOF + * - insertion into the output buffer fails (in this case, the + * character that would have been inserted is not extracted) + * - the next character equals @a delim (in this case, the character + * is not extracted) + * - an exception occurs (and in this case is caught) + * + * If no characters are stored, failbit is set in the stream's error + * state. + */ + __istream_type& + get(__streambuf_type& __sb, char_type __delim); + + /** + * @brief Extraction into another streambuf. + * @param sb A streambuf in which to store data. + * @return *this + * + * Returns @c get(sb,widen('\n')). + */ + __istream_type& + get(__streambuf_type& __sb) + { return this->get(__sb, this->widen('\n')); } + + /** + * @brief String extraction. + * @param s A character array in which to store the data. + * @param n Maximum number of characters to extract. + * @param delim A "stop" character. + * @return *this + * + * Extracts and stores characters into @a s until one of the + * following happens. Note that these criteria are required to be + * tested in the order listed here, to allow an input line to exactly + * fill the @a s array without setting failbit. + * + * -# the input sequence reaches end-of-file, in which case eofbit + * is set in the stream error state + * -# the next character equals @c delim, in which case the character + * is extracted (and therefore counted in @c gcount()) but not stored + * -# @c n-1 characters are stored, in which case failbit is set + * in the stream error state + * + * If no characters are extracted, failbit is set. (An empty line of + * input should therefore not cause failbit to be set.) + * + * In any case, a null character is stored in the next location in + * the array. + */ + __istream_type& + getline(char_type* __s, streamsize __n, char_type __delim); + + /** + * @brief String extraction. + * @param s A character array in which to store the data. + * @param n Maximum number of characters to extract. + * @return *this + * + * Returns @c getline(s,n,widen('\n')). + */ + __istream_type& + getline(char_type* __s, streamsize __n) + { return this->getline(__s, __n, this->widen('\n')); } + + /** + * @brief Discarding characters + * @param n Number of characters to discard. + * @param delim A "stop" character. + * @return *this + * + * Extracts characters and throws them away until one of the + * following happens: + * - if @a n @c != @c std::numeric_limits<int>::max(), @a n + * characters are extracted + * - the input sequence reaches end-of-file + * - the next character equals @a delim (in this case, the character + * is extracted); note that this condition will never occur if + * @a delim equals @c traits::eof(). + * + * 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(); + + __istream_type& + ignore(streamsize __n); + + __istream_type& + ignore(streamsize __n, int_type __delim); + + /** + * @brief Looking ahead in the stream + * @return The next character, or eof(). + * + * If, after constructing the sentry object, @c good() is false, + * returns @c traits::eof(). Otherwise reads but does not extract + * the next input character. + */ + int_type + peek(); + + /** + * @brief Extraction without delimiters. + * @param s A character array. + * @param n Maximum number of characters to store. + * @return *this + * + * If the stream state is @c good(), extracts characters and stores + * them into @a s until one of the following happens: + * - @a n characters are stored + * - the input sequence reaches end-of-file, in which case the error + * state is set to @c failbit|eofbit. + * + * @note This function is not overloaded on signed char and + * unsigned char. + */ + __istream_type& + read(char_type* __s, streamsize __n); + + /** + * @brief Extraction until the buffer is exhausted, but no more. + * @param s A character array. + * @param n Maximum number of characters to store. + * @return The number of characters extracted. + * + * Extracts characters and stores them into @a s depending on the + * number of characters remaining in the streambuf's buffer, + * @c rdbuf()->in_avail(), called @c A here: + * - if @c A @c == @c -1, sets eofbit and extracts no characters + * - if @c A @c == @c 0, extracts no characters + * - if @c A @c > @c 0, extracts @c min(A,n) + * + * The goal is to empty the current buffer, and to not request any + * more from the external input sequence controlled by the streambuf. + */ + streamsize + readsome(char_type* __s, streamsize __n); + + /** + * @brief Unextracting a single character. + * @param c The character to push back into the input stream. + * @return *this + * + * If @c rdbuf() is not null, calls @c rdbuf()->sputbackc(c). + * + * If @c rdbuf() is null or if @c sputbackc() fails, sets badbit in + * the error state. + * + * @note Since no characters are extracted, the next call to + * @c gcount() will return 0, as required by DR 60. + */ + __istream_type& + putback(char_type __c); + + /** + * @brief Unextracting the previous character. + * @return *this + * + * If @c rdbuf() is not null, calls @c rdbuf()->sungetc(c). + * + * If @c rdbuf() is null or if @c sungetc() fails, sets badbit in + * the error state. + * + * @note Since no characters are extracted, the next call to + * @c gcount() will return 0, as required by DR 60. + */ + __istream_type& + unget(); + + /** + * @brief Synchronizing the stream buffer. + * @return 0 on success, -1 on failure + * + * If @c rdbuf() is a null pointer, returns -1. + * + * Otherwise, calls @c rdbuf()->pubsync(), and if that returns -1, + * sets badbit and returns -1. + * + * Otherwise, returns 0. + * + * @note This function does not count the number of characters + * extracted, if any, and therefore does not affect the next + * call to @c gcount(). + */ + int + sync(); + + /** + * @brief Getting the current read position. + * @return A file position object. + * + * If @c fail() is not false, returns @c pos_type(-1) to indicate + * failure. Otherwise returns @c rdbuf()->pubseekoff(0,cur,in). + * + * @note This function does not count the number of characters + * extracted, if any, and therefore does not affect the next + * call to @c gcount(). + */ + pos_type + tellg(); + + /** + * @brief Changing the current read position. + * @param pos A file position object. + * @return *this + * + * If @c fail() is not true, calls @c rdbuf()->pubseekpos(pos). If + * that function fails, sets failbit. + * + * @note This function does not count the number of characters + * extracted, if any, and therefore does not affect the next + * call to @c gcount(). + */ + __istream_type& + seekg(pos_type); + + /** + * @brief Changing the current read position. + * @param off A file offset object. + * @param dir The direction in which to seek. + * @return *this + * + * If @c fail() is not true, calls @c rdbuf()->pubseekoff(off,dir). + * If that function fails, sets failbit. + * + * @note This function does not count the number of characters + * extracted, if any, and therefore does not affect the next + * call to @c gcount(). + */ + __istream_type& + seekg(off_type, ios_base::seekdir); + //@} + + protected: + basic_istream() + : _M_gcount(streamsize(0)) + { this->init(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. + * + * Objects of this class are created before all of the standard + * extractors are run. It is responsible for "exception-safe prefix and + * suffix operations," although only prefix actions are currently required + * by the standard. + */ + template<typename _CharT, typename _Traits> + class basic_istream<_CharT, _Traits>::sentry + { + public: + /// Easy access to dependant types. + typedef _Traits traits_type; + typedef basic_streambuf<_CharT, _Traits> __streambuf_type; + typedef basic_istream<_CharT, _Traits> __istream_type; + typedef typename __istream_type::__ctype_type __ctype_type; + typedef typename _Traits::int_type __int_type; + + /** + * @brief The constructor performs all the work. + * @param is The input stream to guard. + * @param noskipws Whether to consume whitespace or not. + * + * If the stream state is good (@a is.good() is true), then the + * following actions are performed, otherwise the sentry state is + * false ("not okay") and failbit is set in the stream state. + * + * The sentry's preparatory actions are: + * + * -# if the stream is tied to an output stream, @c is.tie()->flush() + * is called to synchronize the output sequence + * -# if @a noskipws is false, and @c ios_base::skipws is set in + * @c is.flags(), the sentry extracts and discards whitespace + * characters from the stream. The currently imbued locale is + * used to determine whether each character is whitespace. + * + * If the stream state is still good, then the sentry state becomes + * true ("okay"). + */ + explicit + sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false); + + /** + * @brief Quick status checking. + * @return The sentry state. + * + * For ease of use, sentries may be converted to booleans. The + * return value is that of the sentry state (true == okay). + */ + operator bool() const + { return _M_ok; } + + private: + bool _M_ok; + }; + + // [27.6.1.2.3] character extraction templates + //@{ + /** + * @brief Character extractors + * @param in An input stream. + * @param c A character reference. + * @return in + * + * Behaves like one of the formatted arithmetic extractors described in + * std::basic_istream. After constructing a sentry object with good + * status, this function extracts a character (if one is available) and + * stores it in @a c. Otherwise, sets failbit in the input stream. + */ + template<typename _CharT, typename _Traits> + basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c); + + template<class _Traits> + inline basic_istream<char, _Traits>& + operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c) + { return (__in >> reinterpret_cast<char&>(__c)); } + + template<class _Traits> + inline basic_istream<char, _Traits>& + operator>>(basic_istream<char, _Traits>& __in, signed char& __c) + { return (__in >> reinterpret_cast<char&>(__c)); } + //@} + + //@{ + /** + * @brief Character string extractors + * @param in An input stream. + * @param s A pointer to a character array. + * @return in + * + * Behaves like one of the formatted arithmetic extractors described in + * std::basic_istream. After constructing a sentry object with good + * status, this function extracts up to @c n characters and stores them + * into the array starting at @a s. @c n is defined as: + * + * - if @c width() is greater than zero, @c n is width() + * - otherwise @c n is "the number of elements of the largest array of + * @c char_type that can store a terminating @c eos." [27.6.1.2.3]/6 + * + * Characters are extracted and stored until one of the following happens: + * - @c n-1 characters are stored + * - EOF is reached + * - the next character is whitespace according to the current locale + * - the next character is a null byte (i.e., @c charT() ) + * + * @c width(0) is then called for the input stream. + * + * If no characters are extracted, sets failbit. + */ + template<typename _CharT, typename _Traits> + basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s); + + // Explicit specialization declaration, defined in src/istream.cc. + template<> + basic_istream<char>& + operator>>(basic_istream<char>& __in, char* __s); + + template<class _Traits> + inline basic_istream<char, _Traits>& + operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s) + { return (__in >> reinterpret_cast<char*>(__s)); } + + template<class _Traits> + inline basic_istream<char, _Traits>& + operator>>(basic_istream<char, _Traits>& __in, signed char* __s) + { return (__in >> reinterpret_cast<char*>(__s)); } + //@} + + // 27.6.1.5 Template class basic_iostream + /** + * @brief Merging istream and ostream capabilities. + * @ingroup io + * + * This class multiply inherits from the input and output stream classes + * simply to provide a single interface. + */ + template<typename _CharT, typename _Traits> + class basic_iostream + : public basic_istream<_CharT, _Traits>, + public basic_ostream<_CharT, _Traits> + { + public: + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 271. basic_iostream missing typedefs + // Types (inherited): + typedef _CharT char_type; + typedef typename _Traits::int_type int_type; + typedef typename _Traits::pos_type pos_type; + typedef typename _Traits::off_type off_type; + typedef _Traits traits_type; + + // Non-standard Types: + typedef basic_istream<_CharT, _Traits> __istream_type; + typedef basic_ostream<_CharT, _Traits> __ostream_type; + + /** + * @brief Constructor does nothing. + * + * Both of the parent classes are initialized with the same + * streambuf pointer passed to this constructor. + */ + explicit + basic_iostream(basic_streambuf<_CharT, _Traits>* __sb) + : __istream_type(__sb), __ostream_type(__sb) { } + + /** + * @brief Destructor does nothing. + */ + virtual + ~basic_iostream() { } + + protected: + basic_iostream() + : __istream_type(), __ostream_type() { } + }; + + // [27.6.1.4] standard basic_istream manipulators + /** + * @brief Quick and easy way to eat whitespace + * + * This manipulator extracts whitespace characters, stopping when the + * next character is non-whitespace, or when the input sequence is empty. + * If the sequence is empty, @c eofbit is set in the stream, but not + * @c failbit. + * + * The current locale is used to distinguish whitespace characters. + * + * Example: + * @code + * MyClass mc; + * + * std::cin >> std::ws >> mc; + * @endcode + * will skip leading whitespace before calling operator>> on cin and your + * object. Note that the same effect can be achieved by creating a + * std::basic_istream::sentry inside your definition of operator>>. + */ + template<typename _CharT, typename _Traits> + basic_istream<_CharT, _Traits>& + ws(basic_istream<_CharT, _Traits>& __is); + +_GLIBCXX_END_NAMESPACE + +#ifndef _GLIBCXX_EXPORT_TEMPLATE +# include <bits/istream.tcc> +#endif + +#endif /* _GLIBCXX_ISTREAM */ diff --git a/gcc-4.4.3/libstdc++-v3/include/std/iterator b/gcc-4.4.3/libstdc++-v3/include/std/iterator new file mode 100644 index 000000000..a15bdf974 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/iterator @@ -0,0 +1,70 @@ +// <iterator> -*- C++ -*- + +// Copyright (C) 2001, 2002, 2009 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file include/iterator + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_ITERATOR +#define _GLIBCXX_ITERATOR 1 + +#pragma GCC system_header + +#include <bits/c++config.h> +#include <cstddef> +#include <bits/stl_iterator_base_types.h> +#include <bits/stl_iterator_base_funcs.h> +#include <bits/stl_iterator.h> +#include <ostream> +#include <istream> +#include <bits/stream_iterator.h> +#include <bits/streambuf_iterator.h> + +#endif /* _GLIBCXX_ITERATOR */ diff --git a/gcc-4.4.3/libstdc++-v3/include/std/limits b/gcc-4.4.3/libstdc++-v3/include/std/limits new file mode 100644 index 000000000..41bf806d5 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/limits @@ -0,0 +1,1256 @@ +// The template and inlines for the numeric_limits classes. -*- C++ -*- + +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, +// 2008, 2009 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file limits + * This is a Standard C++ Library header. + */ + +// Note: this is not a conforming implementation. +// Written by Gabriel Dos Reis <gdr@codesourcery.com> + +// +// ISO 14882:1998 +// 18.2.1 +// + +#ifndef _GLIBCXX_NUMERIC_LIMITS +#define _GLIBCXX_NUMERIC_LIMITS 1 + +#pragma GCC system_header + +#include <bits/c++config.h> + +// +// The numeric_limits<> traits document implementation-defined aspects +// of fundamental arithmetic data types (integers and floating points). +// From Standard C++ point of view, there are 13 such types: +// * integers +// bool (1) +// char, signed char, unsigned char (3) +// short, unsigned short (2) +// int, unsigned (2) +// long, unsigned long (2) +// +// * floating points +// float (1) +// double (1) +// long double (1) +// +// GNU C++ understands (where supported by the host C-library) +// * integer +// long long, unsigned long long (2) +// +// which brings us to 15 fundamental arithmetic data types in GNU C++. +// +// +// Since a numeric_limits<> is a bit tricky to get right, we rely on +// an interface composed of macros which should be defined in config/os +// or config/cpu when they differ from the generic (read arbitrary) +// definitions given here. +// + +// These values can be overridden in the target configuration file. +// The default values are appropriate for many 32-bit targets. + +// GCC only intrinsically supports modulo integral types. The only remaining +// integral exceptional values is division by zero. Only targets that do not +// signal division by zero in some "hard to ignore" way should use false. +#ifndef __glibcxx_integral_traps +# define __glibcxx_integral_traps true +#endif + +// float +// + +// Default values. Should be overridden in configuration files if necessary. + +#ifndef __glibcxx_float_has_denorm_loss +# define __glibcxx_float_has_denorm_loss false +#endif +#ifndef __glibcxx_float_traps +# define __glibcxx_float_traps false +#endif +#ifndef __glibcxx_float_tinyness_before +# define __glibcxx_float_tinyness_before false +#endif + +// double + +// Default values. Should be overridden in configuration files if necessary. + +#ifndef __glibcxx_double_has_denorm_loss +# define __glibcxx_double_has_denorm_loss false +#endif +#ifndef __glibcxx_double_traps +# define __glibcxx_double_traps false +#endif +#ifndef __glibcxx_double_tinyness_before +# define __glibcxx_double_tinyness_before false +#endif + +// long double + +// Default values. Should be overridden in configuration files if necessary. + +#ifndef __glibcxx_long_double_has_denorm_loss +# define __glibcxx_long_double_has_denorm_loss false +#endif +#ifndef __glibcxx_long_double_traps +# define __glibcxx_long_double_traps false +#endif +#ifndef __glibcxx_long_double_tinyness_before +# define __glibcxx_long_double_tinyness_before false +#endif + +// You should not need to define any macros below this point. + +#define __glibcxx_signed(T) ((T)(-1) < 0) + +#define __glibcxx_min(T) \ + (__glibcxx_signed (T) ? (T)1 << __glibcxx_digits (T) : (T)0) + +#define __glibcxx_max(T) \ + (__glibcxx_signed (T) ? \ + (((((T)1 << (__glibcxx_digits (T) - 1)) - 1) << 1) + 1) : ~(T)0) + +#define __glibcxx_digits(T) \ + (sizeof(T) * __CHAR_BIT__ - __glibcxx_signed (T)) + +// The fraction 643/2136 approximates log10(2) to 7 significant digits. +#define __glibcxx_digits10(T) \ + (__glibcxx_digits (T) * 643 / 2136) + + +_GLIBCXX_BEGIN_NAMESPACE(std) + + /** + * @brief Describes the rounding style for floating-point types. + * + * This is used in the std::numeric_limits class. + */ + enum float_round_style + { + round_indeterminate = -1, ///< Self-explanatory. + round_toward_zero = 0, ///< Self-explanatory. + round_to_nearest = 1, ///< To the nearest representable value. + round_toward_infinity = 2, ///< Self-explanatory. + round_toward_neg_infinity = 3 ///< Self-explanatory. + }; + + /** + * @brief Describes the denormalization for floating-point types. + * + * These values represent the presence or absence of a variable number + * of exponent bits. This type is used in the std::numeric_limits class. + */ + enum float_denorm_style + { + /// Indeterminate at compile time whether denormalized values are allowed. + denorm_indeterminate = -1, + /// The type does not allow denormalized values. + denorm_absent = 0, + /// The type allows denormalized values. + denorm_present = 1 + }; + + /** + * @brief Part of std::numeric_limits. + * + * The @c static @c const members are usable as integral constant + * expressions. + * + * @note This is a separate class for purposes of efficiency; you + * should only access these members as part of an instantiation + * of the std::numeric_limits class. + */ + struct __numeric_limits_base + { + /** This will be true for all fundamental types (which have + specializations), and false for everything else. */ + static const bool is_specialized = false; + + /** The number of @c radix digits that be represented without change: for + integer types, the number of non-sign bits in the mantissa; for + floating types, the number of @c radix digits in the mantissa. */ + static const int digits = 0; + /** The number of base 10 digits that can be represented without change. */ + static const int digits10 = 0; + /** True if the type is signed. */ + static const bool is_signed = false; + /** True if the type is integer. + * Is this supposed to be "if the type is integral"? + */ + static const bool is_integer = false; + /** True if the type uses an exact representation. "All integer types are + exact, but not all exact types are integer. For example, rational and + fixed-exponent representations are exact but not integer." + [18.2.1.2]/15 */ + static const bool is_exact = false; + /** For integer types, specifies the base of the representation. For + floating types, specifies the base of the exponent representation. */ + static const int radix = 0; + + /** The minimum negative integer such that @c radix raised to the power of + (one less than that integer) is a normalized floating point number. */ + static const int min_exponent = 0; + /** The minimum negative integer such that 10 raised to that power is in + the range of normalized floating point numbers. */ + static const int min_exponent10 = 0; + /** The maximum positive integer such that @c radix raised to the power of + (one less than that integer) is a representable finite floating point + number. */ + static const int max_exponent = 0; + /** The maximum positive integer such that 10 raised to that power is in + the range of representable finite floating point numbers. */ + static const int max_exponent10 = 0; + + /** True if the type has a representation for positive infinity. */ + static const bool has_infinity = false; + /** True if the type has a representation for a quiet (non-signaling) + "Not a Number." */ + static const bool has_quiet_NaN = false; + /** True if the type has a representation for a signaling + "Not a Number." */ + static const bool has_signaling_NaN = false; + /** See std::float_denorm_style for more information. */ + static const float_denorm_style has_denorm = denorm_absent; + /** "True if loss of accuracy is detected as a denormalization loss, + rather than as an inexact result." [18.2.1.2]/42 */ + static const bool has_denorm_loss = false; + + /** True if-and-only-if the type adheres to the IEC 559 standard, also + known as IEEE 754. (Only makes sense for floating point types.) */ + static const bool is_iec559 = false; + /** "True if the set of values representable by the type is finite. All + built-in types are bounded, this member would be false for arbitrary + precision types." [18.2.1.2]/54 */ + static const bool is_bounded = false; + /** True if the type is @e modulo, that is, if it is possible to add two + positive numbers and have a result that wraps around to a third number + that is less. Typically false for floating types, true for unsigned + integers, and true for signed integers. */ + static const bool is_modulo = false; + + /** True if trapping is implemented for this type. */ + static const bool traps = false; + /** True if tininess is detected before rounding. (see IEC 559) */ + static const bool tinyness_before = false; + /** See std::float_round_style for more information. This is only + meaningful for floating types; integer types will all be + round_toward_zero. */ + static const float_round_style round_style = round_toward_zero; + }; + + /** + * @brief Properties of fundamental types. + * + * This class allows a program to obtain information about the + * representation of a fundamental type on a given platform. For + * non-fundamental types, the functions will return 0 and the data + * members will all be @c false. + * + * _GLIBCXX_RESOLVE_LIB_DEFECTS: DRs 201 and 184 (hi Gaby!) are + * noted, but not incorporated in this documented (yet). + */ + template<typename _Tp> + struct numeric_limits : public __numeric_limits_base + { + /** The minimum finite value, or for floating types with + denormalization, the minimum positive normalized value. */ + static _Tp min() throw() { return static_cast<_Tp>(0); } + /** The maximum finite value. */ + static _Tp max() throw() { return static_cast<_Tp>(0); } + /** The @e machine @e epsilon: the difference between 1 and the least + value greater than 1 that is representable. */ + static _Tp epsilon() throw() { return static_cast<_Tp>(0); } + /** The maximum rounding error measurement (see LIA-1). */ + static _Tp round_error() throw() { return static_cast<_Tp>(0); } + /** The representation of positive infinity, if @c has_infinity. */ + static _Tp infinity() throw() { return static_cast<_Tp>(0); } + /** The representation of a quiet "Not a Number," if @c has_quiet_NaN. */ + static _Tp quiet_NaN() throw() { return static_cast<_Tp>(0); } + /** The representation of a signaling "Not a Number," if + @c has_signaling_NaN. */ + static _Tp signaling_NaN() throw() { return static_cast<_Tp>(0); } + /** The minimum positive denormalized value. For types where + @c has_denorm is false, this is the minimum positive normalized + value. */ + static _Tp denorm_min() throw() { return static_cast<_Tp>(0); } + }; + + // Now there follow 15 explicit specializations. Yes, 15. Make sure + // you get the count right. + + /// numeric_limits<bool> specialization. + template<> + struct numeric_limits<bool> + { + static const bool is_specialized = true; + + static bool min() throw() + { return false; } + static bool max() throw() + { return true; } + + static const int digits = 1; + static const int digits10 = 0; + static const bool is_signed = false; + static const bool is_integer = true; + static const bool is_exact = true; + static const int radix = 2; + static bool epsilon() throw() + { return false; } + static bool round_error() throw() + { return false; } + + static const int min_exponent = 0; + static const int min_exponent10 = 0; + static const int max_exponent = 0; + static const int max_exponent10 = 0; + + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const float_denorm_style has_denorm = denorm_absent; + static const bool has_denorm_loss = false; + + static bool infinity() throw() + { return false; } + static bool quiet_NaN() throw() + { return false; } + static bool signaling_NaN() throw() + { return false; } + static bool denorm_min() throw() + { return false; } + + static const bool is_iec559 = false; + static const bool is_bounded = true; + static const bool is_modulo = false; + + // It is not clear what it means for a boolean type to trap. + // This is a DR on the LWG issue list. Here, I use integer + // promotion semantics. + static const bool traps = __glibcxx_integral_traps; + static const bool tinyness_before = false; + static const float_round_style round_style = round_toward_zero; + }; + + /// numeric_limits<char> specialization. + template<> + struct numeric_limits<char> + { + static const bool is_specialized = true; + + static char min() throw() + { return __glibcxx_min(char); } + static char max() throw() + { return __glibcxx_max(char); } + + static const int digits = __glibcxx_digits (char); + static const int digits10 = __glibcxx_digits10 (char); + static const bool is_signed = __glibcxx_signed (char); + static const bool is_integer = true; + static const bool is_exact = true; + static const int radix = 2; + static char epsilon() throw() + { return 0; } + static char round_error() throw() + { return 0; } + + static const int min_exponent = 0; + static const int min_exponent10 = 0; + static const int max_exponent = 0; + static const int max_exponent10 = 0; + + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const float_denorm_style has_denorm = denorm_absent; + static const bool has_denorm_loss = false; + + static char infinity() throw() + { return char(); } + static char quiet_NaN() throw() + { return char(); } + static char signaling_NaN() throw() + { return char(); } + static char denorm_min() throw() + { return static_cast<char>(0); } + + static const bool is_iec559 = false; + static const bool is_bounded = true; + static const bool is_modulo = true; + + static const bool traps = __glibcxx_integral_traps; + static const bool tinyness_before = false; + static const float_round_style round_style = round_toward_zero; + }; + + /// numeric_limits<signed char> specialization. + template<> + struct numeric_limits<signed char> + { + static const bool is_specialized = true; + + static signed char min() throw() + { return -__SCHAR_MAX__ - 1; } + static signed char max() throw() + { return __SCHAR_MAX__; } + + static const int digits = __glibcxx_digits (signed char); + static const int digits10 = __glibcxx_digits10 (signed char); + static const bool is_signed = true; + static const bool is_integer = true; + static const bool is_exact = true; + static const int radix = 2; + static signed char epsilon() throw() + { return 0; } + static signed char round_error() throw() + { return 0; } + + static const int min_exponent = 0; + static const int min_exponent10 = 0; + static const int max_exponent = 0; + static const int max_exponent10 = 0; + + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const float_denorm_style has_denorm = denorm_absent; + static const bool has_denorm_loss = false; + + static signed char infinity() throw() + { return static_cast<signed char>(0); } + static signed char quiet_NaN() throw() + { return static_cast<signed char>(0); } + static signed char signaling_NaN() throw() + { return static_cast<signed char>(0); } + static signed char denorm_min() throw() + { return static_cast<signed char>(0); } + + static const bool is_iec559 = false; + static const bool is_bounded = true; + static const bool is_modulo = true; + + static const bool traps = __glibcxx_integral_traps; + static const bool tinyness_before = false; + static const float_round_style round_style = round_toward_zero; + }; + + /// numeric_limits<unsigned char> specialization. + template<> + struct numeric_limits<unsigned char> + { + static const bool is_specialized = true; + + static unsigned char min() throw() + { return 0; } + static unsigned char max() throw() + { return __SCHAR_MAX__ * 2U + 1; } + + static const int digits = __glibcxx_digits (unsigned char); + static const int digits10 = __glibcxx_digits10 (unsigned char); + static const bool is_signed = false; + static const bool is_integer = true; + static const bool is_exact = true; + static const int radix = 2; + static unsigned char epsilon() throw() + { return 0; } + static unsigned char round_error() throw() + { return 0; } + + static const int min_exponent = 0; + static const int min_exponent10 = 0; + static const int max_exponent = 0; + static const int max_exponent10 = 0; + + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const float_denorm_style has_denorm = denorm_absent; + static const bool has_denorm_loss = false; + + static unsigned char infinity() throw() + { return static_cast<unsigned char>(0); } + static unsigned char quiet_NaN() throw() + { return static_cast<unsigned char>(0); } + static unsigned char signaling_NaN() throw() + { return static_cast<unsigned char>(0); } + static unsigned char denorm_min() throw() + { return static_cast<unsigned char>(0); } + + static const bool is_iec559 = false; + static const bool is_bounded = true; + static const bool is_modulo = true; + + static const bool traps = __glibcxx_integral_traps; + static const bool tinyness_before = false; + static const float_round_style round_style = round_toward_zero; + }; + + /// numeric_limits<wchar_t> specialization. + template<> + struct numeric_limits<wchar_t> + { + static const bool is_specialized = true; + + static wchar_t min() throw() + { return __glibcxx_min (wchar_t); } + static wchar_t max() throw() + { return __glibcxx_max (wchar_t); } + + static const int digits = __glibcxx_digits (wchar_t); + static const int digits10 = __glibcxx_digits10 (wchar_t); + static const bool is_signed = __glibcxx_signed (wchar_t); + static const bool is_integer = true; + static const bool is_exact = true; + static const int radix = 2; + static wchar_t epsilon() throw() + { return 0; } + static wchar_t round_error() throw() + { return 0; } + + static const int min_exponent = 0; + static const int min_exponent10 = 0; + static const int max_exponent = 0; + static const int max_exponent10 = 0; + + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const float_denorm_style has_denorm = denorm_absent; + static const bool has_denorm_loss = false; + + static wchar_t infinity() throw() + { return wchar_t(); } + static wchar_t quiet_NaN() throw() + { return wchar_t(); } + static wchar_t signaling_NaN() throw() + { return wchar_t(); } + static wchar_t denorm_min() throw() + { return wchar_t(); } + + static const bool is_iec559 = false; + static const bool is_bounded = true; + static const bool is_modulo = true; + + static const bool traps = __glibcxx_integral_traps; + static const bool tinyness_before = false; + static const float_round_style round_style = round_toward_zero; + }; + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /// numeric_limits<char16_t> specialization. + template<> + struct numeric_limits<char16_t> + { + static const bool is_specialized = true; + + static char16_t min() throw() + { return __glibcxx_min (char16_t); } + static char16_t max() throw() + { return __glibcxx_max (char16_t); } + + static const int digits = __glibcxx_digits (char16_t); + static const int digits10 = __glibcxx_digits10 (char16_t); + static const bool is_signed = __glibcxx_signed (char16_t); + static const bool is_integer = true; + static const bool is_exact = true; + static const int radix = 2; + static char16_t epsilon() throw() + { return 0; } + static char16_t round_error() throw() + { return 0; } + + static const int min_exponent = 0; + static const int min_exponent10 = 0; + static const int max_exponent = 0; + static const int max_exponent10 = 0; + + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const float_denorm_style has_denorm = denorm_absent; + static const bool has_denorm_loss = false; + + static char16_t infinity() throw() + { return char16_t(); } + static char16_t quiet_NaN() throw() + { return char16_t(); } + static char16_t signaling_NaN() throw() + { return char16_t(); } + static char16_t denorm_min() throw() + { return char16_t(); } + + static const bool is_iec559 = false; + static const bool is_bounded = true; + static const bool is_modulo = true; + + static const bool traps = __glibcxx_integral_traps; + static const bool tinyness_before = false; + static const float_round_style round_style = round_toward_zero; + }; + + /// numeric_limits<char32_t> specialization. + template<> + struct numeric_limits<char32_t> + { + static const bool is_specialized = true; + + static char32_t min() throw() + { return __glibcxx_min (char32_t); } + static char32_t max() throw() + { return __glibcxx_max (char32_t); } + + static const int digits = __glibcxx_digits (char32_t); + static const int digits10 = __glibcxx_digits10 (char32_t); + static const bool is_signed = __glibcxx_signed (char32_t); + static const bool is_integer = true; + static const bool is_exact = true; + static const int radix = 2; + static char32_t epsilon() throw() + { return 0; } + static char32_t round_error() throw() + { return 0; } + + static const int min_exponent = 0; + static const int min_exponent10 = 0; + static const int max_exponent = 0; + static const int max_exponent10 = 0; + + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const float_denorm_style has_denorm = denorm_absent; + static const bool has_denorm_loss = false; + + static char32_t infinity() throw() + { return char32_t(); } + static char32_t quiet_NaN() throw() + { return char32_t(); } + static char32_t signaling_NaN() throw() + { return char32_t(); } + static char32_t denorm_min() throw() + { return char32_t(); } + + static const bool is_iec559 = false; + static const bool is_bounded = true; + static const bool is_modulo = true; + + static const bool traps = __glibcxx_integral_traps; + static const bool tinyness_before = false; + static const float_round_style round_style = round_toward_zero; + }; +#endif + + /// numeric_limits<short> specialization. + template<> + struct numeric_limits<short> + { + static const bool is_specialized = true; + + static short min() throw() + { return -__SHRT_MAX__ - 1; } + static short max() throw() + { return __SHRT_MAX__; } + + static const int digits = __glibcxx_digits (short); + static const int digits10 = __glibcxx_digits10 (short); + static const bool is_signed = true; + static const bool is_integer = true; + static const bool is_exact = true; + static const int radix = 2; + static short epsilon() throw() + { return 0; } + static short round_error() throw() + { return 0; } + + static const int min_exponent = 0; + static const int min_exponent10 = 0; + static const int max_exponent = 0; + static const int max_exponent10 = 0; + + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const float_denorm_style has_denorm = denorm_absent; + static const bool has_denorm_loss = false; + + static short infinity() throw() + { return short(); } + static short quiet_NaN() throw() + { return short(); } + static short signaling_NaN() throw() + { return short(); } + static short denorm_min() throw() + { return short(); } + + static const bool is_iec559 = false; + static const bool is_bounded = true; + static const bool is_modulo = true; + + static const bool traps = __glibcxx_integral_traps; + static const bool tinyness_before = false; + static const float_round_style round_style = round_toward_zero; + }; + + /// numeric_limits<unsigned short> specialization. + template<> + struct numeric_limits<unsigned short> + { + static const bool is_specialized = true; + + static unsigned short min() throw() + { return 0; } + static unsigned short max() throw() + { return __SHRT_MAX__ * 2U + 1; } + + static const int digits = __glibcxx_digits (unsigned short); + static const int digits10 = __glibcxx_digits10 (unsigned short); + static const bool is_signed = false; + static const bool is_integer = true; + static const bool is_exact = true; + static const int radix = 2; + static unsigned short epsilon() throw() + { return 0; } + static unsigned short round_error() throw() + { return 0; } + + static const int min_exponent = 0; + static const int min_exponent10 = 0; + static const int max_exponent = 0; + static const int max_exponent10 = 0; + + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const float_denorm_style has_denorm = denorm_absent; + static const bool has_denorm_loss = false; + + static unsigned short infinity() throw() + { return static_cast<unsigned short>(0); } + static unsigned short quiet_NaN() throw() + { return static_cast<unsigned short>(0); } + static unsigned short signaling_NaN() throw() + { return static_cast<unsigned short>(0); } + static unsigned short denorm_min() throw() + { return static_cast<unsigned short>(0); } + + static const bool is_iec559 = false; + static const bool is_bounded = true; + static const bool is_modulo = true; + + static const bool traps = __glibcxx_integral_traps; + static const bool tinyness_before = false; + static const float_round_style round_style = round_toward_zero; + }; + + /// numeric_limits<int> specialization. + template<> + struct numeric_limits<int> + { + static const bool is_specialized = true; + + static int min() throw() + { return -__INT_MAX__ - 1; } + static int max() throw() + { return __INT_MAX__; } + + static const int digits = __glibcxx_digits (int); + static const int digits10 = __glibcxx_digits10 (int); + static const bool is_signed = true; + static const bool is_integer = true; + static const bool is_exact = true; + static const int radix = 2; + static int epsilon() throw() + { return 0; } + static int round_error() throw() + { return 0; } + + static const int min_exponent = 0; + static const int min_exponent10 = 0; + static const int max_exponent = 0; + static const int max_exponent10 = 0; + + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const float_denorm_style has_denorm = denorm_absent; + static const bool has_denorm_loss = false; + + static int infinity() throw() + { return static_cast<int>(0); } + static int quiet_NaN() throw() + { return static_cast<int>(0); } + static int signaling_NaN() throw() + { return static_cast<int>(0); } + static int denorm_min() throw() + { return static_cast<int>(0); } + + static const bool is_iec559 = false; + static const bool is_bounded = true; + static const bool is_modulo = true; + + static const bool traps = __glibcxx_integral_traps; + static const bool tinyness_before = false; + static const float_round_style round_style = round_toward_zero; + }; + + /// numeric_limits<unsigned int> specialization. + template<> + struct numeric_limits<unsigned int> + { + static const bool is_specialized = true; + + static unsigned int min() throw() + { return 0; } + static unsigned int max() throw() + { return __INT_MAX__ * 2U + 1; } + + static const int digits = __glibcxx_digits (unsigned int); + static const int digits10 = __glibcxx_digits10 (unsigned int); + static const bool is_signed = false; + static const bool is_integer = true; + static const bool is_exact = true; + static const int radix = 2; + static unsigned int epsilon() throw() + { return 0; } + static unsigned int round_error() throw() + { return 0; } + + static const int min_exponent = 0; + static const int min_exponent10 = 0; + static const int max_exponent = 0; + static const int max_exponent10 = 0; + + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const float_denorm_style has_denorm = denorm_absent; + static const bool has_denorm_loss = false; + + static unsigned int infinity() throw() + { return static_cast<unsigned int>(0); } + static unsigned int quiet_NaN() throw() + { return static_cast<unsigned int>(0); } + static unsigned int signaling_NaN() throw() + { return static_cast<unsigned int>(0); } + static unsigned int denorm_min() throw() + { return static_cast<unsigned int>(0); } + + static const bool is_iec559 = false; + static const bool is_bounded = true; + static const bool is_modulo = true; + + static const bool traps = __glibcxx_integral_traps; + static const bool tinyness_before = false; + static const float_round_style round_style = round_toward_zero; + }; + + /// numeric_limits<long> specialization. + template<> + struct numeric_limits<long> + { + static const bool is_specialized = true; + + static long min() throw() + { return -__LONG_MAX__ - 1; } + static long max() throw() + { return __LONG_MAX__; } + + static const int digits = __glibcxx_digits (long); + static const int digits10 = __glibcxx_digits10 (long); + static const bool is_signed = true; + static const bool is_integer = true; + static const bool is_exact = true; + static const int radix = 2; + static long epsilon() throw() + { return 0; } + static long round_error() throw() + { return 0; } + + static const int min_exponent = 0; + static const int min_exponent10 = 0; + static const int max_exponent = 0; + static const int max_exponent10 = 0; + + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const float_denorm_style has_denorm = denorm_absent; + static const bool has_denorm_loss = false; + + static long infinity() throw() + { return static_cast<long>(0); } + static long quiet_NaN() throw() + { return static_cast<long>(0); } + static long signaling_NaN() throw() + { return static_cast<long>(0); } + static long denorm_min() throw() + { return static_cast<long>(0); } + + static const bool is_iec559 = false; + static const bool is_bounded = true; + static const bool is_modulo = true; + + static const bool traps = __glibcxx_integral_traps; + static const bool tinyness_before = false; + static const float_round_style round_style = round_toward_zero; + }; + + /// numeric_limits<unsigned long> specialization. + template<> + struct numeric_limits<unsigned long> + { + static const bool is_specialized = true; + + static unsigned long min() throw() + { return 0; } + static unsigned long max() throw() + { return __LONG_MAX__ * 2UL + 1; } + + static const int digits = __glibcxx_digits (unsigned long); + static const int digits10 = __glibcxx_digits10 (unsigned long); + static const bool is_signed = false; + static const bool is_integer = true; + static const bool is_exact = true; + static const int radix = 2; + static unsigned long epsilon() throw() + { return 0; } + static unsigned long round_error() throw() + { return 0; } + + static const int min_exponent = 0; + static const int min_exponent10 = 0; + static const int max_exponent = 0; + static const int max_exponent10 = 0; + + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const float_denorm_style has_denorm = denorm_absent; + static const bool has_denorm_loss = false; + + static unsigned long infinity() throw() + { return static_cast<unsigned long>(0); } + static unsigned long quiet_NaN() throw() + { return static_cast<unsigned long>(0); } + static unsigned long signaling_NaN() throw() + { return static_cast<unsigned long>(0); } + static unsigned long denorm_min() throw() + { return static_cast<unsigned long>(0); } + + static const bool is_iec559 = false; + static const bool is_bounded = true; + static const bool is_modulo = true; + + static const bool traps = __glibcxx_integral_traps; + static const bool tinyness_before = false; + static const float_round_style round_style = round_toward_zero; + }; + + /// numeric_limits<long long> specialization. + template<> + struct numeric_limits<long long> + { + static const bool is_specialized = true; + + static long long min() throw() + { return -__LONG_LONG_MAX__ - 1; } + static long long max() throw() + { return __LONG_LONG_MAX__; } + + static const int digits = __glibcxx_digits (long long); + static const int digits10 = __glibcxx_digits10 (long long); + static const bool is_signed = true; + static const bool is_integer = true; + static const bool is_exact = true; + static const int radix = 2; + static long long epsilon() throw() + { return 0; } + static long long round_error() throw() + { return 0; } + + static const int min_exponent = 0; + static const int min_exponent10 = 0; + static const int max_exponent = 0; + static const int max_exponent10 = 0; + + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const float_denorm_style has_denorm = denorm_absent; + static const bool has_denorm_loss = false; + + static long long infinity() throw() + { return static_cast<long long>(0); } + static long long quiet_NaN() throw() + { return static_cast<long long>(0); } + static long long signaling_NaN() throw() + { return static_cast<long long>(0); } + static long long denorm_min() throw() + { return static_cast<long long>(0); } + + static const bool is_iec559 = false; + static const bool is_bounded = true; + static const bool is_modulo = true; + + static const bool traps = __glibcxx_integral_traps; + static const bool tinyness_before = false; + static const float_round_style round_style = round_toward_zero; + }; + + /// numeric_limits<unsigned long long> specialization. + template<> + struct numeric_limits<unsigned long long> + { + static const bool is_specialized = true; + + static unsigned long long min() throw() + { return 0; } + static unsigned long long max() throw() + { return __LONG_LONG_MAX__ * 2ULL + 1; } + + static const int digits = __glibcxx_digits (unsigned long long); + static const int digits10 = __glibcxx_digits10 (unsigned long long); + static const bool is_signed = false; + static const bool is_integer = true; + static const bool is_exact = true; + static const int radix = 2; + static unsigned long long epsilon() throw() + { return 0; } + static unsigned long long round_error() throw() + { return 0; } + + static const int min_exponent = 0; + static const int min_exponent10 = 0; + static const int max_exponent = 0; + static const int max_exponent10 = 0; + + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const float_denorm_style has_denorm = denorm_absent; + static const bool has_denorm_loss = false; + + static unsigned long long infinity() throw() + { return static_cast<unsigned long long>(0); } + static unsigned long long quiet_NaN() throw() + { return static_cast<unsigned long long>(0); } + static unsigned long long signaling_NaN() throw() + { return static_cast<unsigned long long>(0); } + static unsigned long long denorm_min() throw() + { return static_cast<unsigned long long>(0); } + + static const bool is_iec559 = false; + static const bool is_bounded = true; + static const bool is_modulo = true; + + static const bool traps = __glibcxx_integral_traps; + static const bool tinyness_before = false; + static const float_round_style round_style = round_toward_zero; + }; + + /// numeric_limits<float> specialization. + template<> + struct numeric_limits<float> + { + static const bool is_specialized = true; + + static float min() throw() + { return __FLT_MIN__; } + static float max() throw() + { return __FLT_MAX__; } + + static const int digits = __FLT_MANT_DIG__; + static const int digits10 = __FLT_DIG__; + static const bool is_signed = true; + static const bool is_integer = false; + static const bool is_exact = false; + static const int radix = __FLT_RADIX__; + static float epsilon() throw() + { return __FLT_EPSILON__; } + static float round_error() throw() + { return 0.5F; } + + static const int min_exponent = __FLT_MIN_EXP__; + static const int min_exponent10 = __FLT_MIN_10_EXP__; + static const int max_exponent = __FLT_MAX_EXP__; + static const int max_exponent10 = __FLT_MAX_10_EXP__; + + static const bool has_infinity = __FLT_HAS_INFINITY__; + 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 + = bool(__FLT_HAS_DENORM__) ? denorm_present : denorm_absent; + static const bool has_denorm_loss = __glibcxx_float_has_denorm_loss; + + static float infinity() throw() + { return __builtin_huge_valf (); } + static float quiet_NaN() throw() + { return __builtin_nanf (""); } + static float signaling_NaN() throw() + { return __builtin_nansf (""); } + static float denorm_min() throw() + { return __FLT_DENORM_MIN__; } + + static const bool is_iec559 + = has_infinity && has_quiet_NaN && has_denorm == denorm_present; + static const bool is_bounded = true; + static const bool is_modulo = false; + + static const bool traps = __glibcxx_float_traps; + static const bool tinyness_before = __glibcxx_float_tinyness_before; + static const float_round_style round_style = round_to_nearest; + }; + +#undef __glibcxx_float_has_denorm_loss +#undef __glibcxx_float_traps +#undef __glibcxx_float_tinyness_before + + /// numeric_limits<double> specialization. + template<> + struct numeric_limits<double> + { + static const bool is_specialized = true; + + static double min() throw() + { return __DBL_MIN__; } + static double max() throw() + { return __DBL_MAX__; } + + static const int digits = __DBL_MANT_DIG__; + static const int digits10 = __DBL_DIG__; + static const bool is_signed = true; + static const bool is_integer = false; + static const bool is_exact = false; + static const int radix = __FLT_RADIX__; + static double epsilon() throw() + { return __DBL_EPSILON__; } + static double round_error() throw() + { return 0.5; } + + static const int min_exponent = __DBL_MIN_EXP__; + static const int min_exponent10 = __DBL_MIN_10_EXP__; + static const int max_exponent = __DBL_MAX_EXP__; + static const int max_exponent10 = __DBL_MAX_10_EXP__; + + static const bool has_infinity = __DBL_HAS_INFINITY__; + 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 + = bool(__DBL_HAS_DENORM__) ? denorm_present : denorm_absent; + static const bool has_denorm_loss = __glibcxx_double_has_denorm_loss; + + static double infinity() throw() + { return __builtin_huge_val(); } + static double quiet_NaN() throw() + { return __builtin_nan (""); } + static double signaling_NaN() throw() + { return __builtin_nans (""); } + static double denorm_min() throw() + { return __DBL_DENORM_MIN__; } + + static const bool is_iec559 + = has_infinity && has_quiet_NaN && has_denorm == denorm_present; + static const bool is_bounded = true; + static const bool is_modulo = false; + + static const bool traps = __glibcxx_double_traps; + static const bool tinyness_before = __glibcxx_double_tinyness_before; + static const float_round_style round_style = round_to_nearest; + }; + +#undef __glibcxx_double_has_denorm_loss +#undef __glibcxx_double_traps +#undef __glibcxx_double_tinyness_before + + /// numeric_limits<long double> specialization. + template<> + struct numeric_limits<long double> + { + static const bool is_specialized = true; + + static long double min() throw() + { return __LDBL_MIN__; } + static long double max() throw() + { return __LDBL_MAX__; } + + static const int digits = __LDBL_MANT_DIG__; + static const int digits10 = __LDBL_DIG__; + static const bool is_signed = true; + static const bool is_integer = false; + static const bool is_exact = false; + static const int radix = __FLT_RADIX__; + static long double epsilon() throw() + { return __LDBL_EPSILON__; } + static long double round_error() throw() + { return 0.5L; } + + static const int min_exponent = __LDBL_MIN_EXP__; + static const int min_exponent10 = __LDBL_MIN_10_EXP__; + static const int max_exponent = __LDBL_MAX_EXP__; + static const int max_exponent10 = __LDBL_MAX_10_EXP__; + + static const bool has_infinity = __LDBL_HAS_INFINITY__; + 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 + = bool(__LDBL_HAS_DENORM__) ? denorm_present : denorm_absent; + static const bool has_denorm_loss + = __glibcxx_long_double_has_denorm_loss; + + static long double infinity() throw() + { return __builtin_huge_vall (); } + static long double quiet_NaN() throw() + { return __builtin_nanl (""); } + static long double signaling_NaN() throw() + { return __builtin_nansl (""); } + static long double denorm_min() throw() + { return __LDBL_DENORM_MIN__; } + + static const bool is_iec559 + = has_infinity && has_quiet_NaN && has_denorm == denorm_present; + static const bool is_bounded = true; + static const bool is_modulo = false; + + static const bool traps = __glibcxx_long_double_traps; + static const bool tinyness_before = __glibcxx_long_double_tinyness_before; + static const float_round_style round_style = round_to_nearest; + }; + +#undef __glibcxx_long_double_has_denorm_loss +#undef __glibcxx_long_double_traps +#undef __glibcxx_long_double_tinyness_before + +_GLIBCXX_END_NAMESPACE + +#undef __glibcxx_signed +#undef __glibcxx_min +#undef __glibcxx_max +#undef __glibcxx_digits +#undef __glibcxx_digits10 + +#endif // _GLIBCXX_NUMERIC_LIMITS diff --git a/gcc-4.4.3/libstdc++-v3/include/std/list b/gcc-4.4.3/libstdc++-v3/include/std/list new file mode 100644 index 000000000..d199802d7 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/list @@ -0,0 +1,74 @@ +// <list> -*- C++ -*- + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 +// 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file include/list + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_LIST +#define _GLIBCXX_LIST 1 + +#pragma GCC system_header + +#include <bits/stl_algobase.h> +#include <bits/allocator.h> +#include <bits/stl_list.h> + +#ifndef _GLIBCXX_EXPORT_TEMPLATE +# include <bits/list.tcc> +#endif + +#ifdef _GLIBCXX_DEBUG +# include <debug/list> +#endif + +#endif /* _GLIBCXX_LIST */ + diff --git a/gcc-4.4.3/libstdc++-v3/include/std/locale b/gcc-4.4.3/libstdc++-v3/include/std/locale new file mode 100644 index 000000000..3504b778c --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/locale @@ -0,0 +1,45 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +// 2006, 2007, 2009 +// 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +// +// ISO C++ 14882: 22.1 Locales +// + +/** @file locale + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_LOCALE +#define _GLIBCXX_LOCALE 1 + +#pragma GCC system_header + +#include <bits/localefwd.h> +#include <bits/locale_classes.h> +#include <bits/locale_facets.h> +#include <bits/locale_facets_nonio.h> + +#endif /* _GLIBCXX_LOCALE */ diff --git a/gcc-4.4.3/libstdc++-v3/include/std/map b/gcc-4.4.3/libstdc++-v3/include/std/map new file mode 100644 index 000000000..159bfb3d0 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/map @@ -0,0 +1,68 @@ +// <map> -*- C++ -*- + +// Copyright (C) 2001, 2002, 2009 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file include/map + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_MAP +#define _GLIBCXX_MAP 1 + +#pragma GCC system_header + +#include <bits/stl_tree.h> +#include <bits/stl_map.h> +#include <bits/stl_multimap.h> + +#ifdef _GLIBCXX_DEBUG +# include <debug/map> +#endif + +#endif /* _GLIBCXX_MAP */ diff --git a/gcc-4.4.3/libstdc++-v3/include/std/memory b/gcc-4.4.3/libstdc++-v3/include/std/memory new file mode 100644 index 000000000..9defd487c --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/memory @@ -0,0 +1,100 @@ +// <memory> -*- C++ -*- + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 +// 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/* + * Copyright (c) 1997-1999 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ + +/** @file include/memory + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_MEMORY +#define _GLIBCXX_MEMORY 1 + +#pragma GCC system_header + +#include <bits/stl_algobase.h> +#include <bits/allocator.h> +#include <bits/stl_construct.h> +#include <bits/stl_uninitialized.h> +#include <bits/stl_tempbuf.h> +#include <bits/stl_raw_storage_iter.h> + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +# if defined(_GLIBCXX_INCLUDE_AS_TR1) +# error C++0x header cannot be included from TR1 header +# endif +# include <exception> // std::exception +# include <typeinfo> // std::type_info in get_deleter +# include <iosfwd> // std::basic_ostream +# include <ext/atomicity.h> +# include <ext/concurrence.h> +# include <bits/functexcept.h> +# include <bits/stl_function.h> // std::less +# include <bits/unique_ptr.h> +# include <debug/debug.h> +# include <type_traits> +# include <functional> +# if _GLIBCXX_DEPRECATED +# include <backward/auto_ptr.h> +# endif +# if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# include <tr1_impl/boost_sp_counted_base.h> +# include <bits/shared_ptr.h> +# else +# define _GLIBCXX_INCLUDE_AS_CXX0X +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 +# define _GLIBCXX_END_NAMESPACE_TR1 +# define _GLIBCXX_TR1 +# include <tr1_impl/boost_sp_counted_base.h> +# include <bits/shared_ptr.h> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_CXX0X +# endif +#else +# include <backward/auto_ptr.h> +#endif + +/** + * @defgroup memory Memory + * @ingroup utilities + * + * Components for memory allocation, deallocation, and management. + */ + +#endif /* _GLIBCXX_MEMORY */ diff --git a/gcc-4.4.3/libstdc++-v3/include/std/mutex b/gcc-4.4.3/libstdc++-v3/include/std/mutex new file mode 100644 index 000000000..62b314b33 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/mutex @@ -0,0 +1,774 @@ +// <mutex> -*- C++ -*- + +// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 +// 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file mutex + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_MUTEX +#define _GLIBCXX_MUTEX 1 + +#pragma GCC system_header + +#ifndef __GXX_EXPERIMENTAL_CXX0X__ +# include <c++0x_warning.h> +#else + +#include <tuple> +#include <cstddef> +#include <chrono> +#include <exception> +#include <type_traits> +#include <functional> +#include <system_error> +#include <bits/functexcept.h> +#include <bits/gthr.h> +#include <bits/move.h> // for std::swap + +#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) + +namespace std +{ + /** + * @defgroup mutexes Mutexes + * @ingroup concurrency + * + * Classes for mutex support. + * @{ + */ + + /// mutex + class mutex + { + typedef __gthread_mutex_t __native_type; + __native_type _M_mutex; + + public: + typedef __native_type* native_handle_type; + + mutex() + { + // XXX EAGAIN, ENOMEM, EPERM, EBUSY(may), EINVAL(may) +#ifdef __GTHREAD_MUTEX_INIT + __native_type __tmp = __GTHREAD_MUTEX_INIT; + _M_mutex = __tmp; +#else + __GTHREAD_MUTEX_INIT_FUNCTION(&_M_mutex); +#endif + } + + mutex(const mutex&) = delete; + mutex& operator=(const mutex&) = delete; + + void + lock() + { + int __e = __gthread_mutex_lock(&_M_mutex); + + // EINVAL, EAGAIN, EBUSY, EINVAL, EDEADLK(may) + if (__e) + __throw_system_error(__e); + } + + bool + try_lock() + { + // XXX EINVAL, EAGAIN, EBUSY + return !__gthread_mutex_trylock(&_M_mutex); + } + + void + unlock() + { + // XXX EINVAL, EAGAIN, EPERM + __gthread_mutex_unlock(&_M_mutex); + } + + native_handle_type + native_handle() + { return &_M_mutex; } + }; + + /// recursive_mutex + class recursive_mutex + { + typedef __gthread_recursive_mutex_t __native_type; + __native_type _M_mutex; + + public: + typedef __native_type* native_handle_type; + + recursive_mutex() + { + // XXX EAGAIN, ENOMEM, EPERM, EBUSY(may), EINVAL(may) +#ifdef __GTHREAD_RECURSIVE_MUTEX_INIT + __native_type __tmp = __GTHREAD_RECURSIVE_MUTEX_INIT; + _M_mutex = __tmp; +#else + __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION(&_M_mutex); +#endif + } + + recursive_mutex(const recursive_mutex&) = delete; + recursive_mutex& operator=(const recursive_mutex&) = delete; + + void + lock() + { + int __e = __gthread_recursive_mutex_lock(&_M_mutex); + + // EINVAL, EAGAIN, EBUSY, EINVAL, EDEADLK(may) + if (__e) + __throw_system_error(__e); + } + + bool + try_lock() + { + // XXX EINVAL, EAGAIN, EBUSY + return !__gthread_recursive_mutex_trylock(&_M_mutex); + } + + void + unlock() + { + // XXX EINVAL, EAGAIN, EBUSY + __gthread_recursive_mutex_unlock(&_M_mutex); + } + + native_handle_type + native_handle() + { return &_M_mutex; } + }; + + /// timed_mutex + class timed_mutex + { + typedef __gthread_mutex_t __native_type; + +#ifdef _GLIBCXX_USE_CLOCK_MONOTONIC + typedef chrono::monotonic_clock __clock_t; +#else + typedef chrono::high_resolution_clock __clock_t; +#endif + + __native_type _M_mutex; + + public: + typedef __native_type* native_handle_type; + + timed_mutex() + { +#ifdef __GTHREAD_MUTEX_INIT + __native_type __tmp = __GTHREAD_MUTEX_INIT; + _M_mutex = __tmp; +#else + __GTHREAD_MUTEX_INIT_FUNCTION(&_M_mutex); +#endif + } + + timed_mutex(const timed_mutex&) = delete; + timed_mutex& operator=(const timed_mutex&) = delete; + + void + lock() + { + int __e = __gthread_mutex_lock(&_M_mutex); + + // EINVAL, EAGAIN, EBUSY, EINVAL, EDEADLK(may) + if (__e) + __throw_system_error(__e); + } + + bool + try_lock() + { + // XXX EINVAL, EAGAIN, EBUSY + return !__gthread_mutex_trylock(&_M_mutex); + } + + template <class _Rep, class _Period> + bool + try_lock_for(const chrono::duration<_Rep, _Period>& __rtime) + { return __try_lock_for_impl(__rtime); } + + template <class _Clock, class _Duration> + bool + try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime) + { + chrono::time_point<_Clock, chrono::seconds> __s = + chrono::time_point_cast<chrono::seconds>(__atime); + + chrono::nanoseconds __ns = + chrono::duration_cast<chrono::nanoseconds>(__atime - __s); + + __gthread_time_t __ts = { + static_cast<std::time_t>(__s.time_since_epoch().count()), + static_cast<long>(__ns.count()) + }; + + return !__gthread_mutex_timedlock(&_M_mutex, &__ts); + } + + void + unlock() + { + // XXX EINVAL, EAGAIN, EBUSY + __gthread_mutex_unlock(&_M_mutex); + } + + native_handle_type + native_handle() + { return &_M_mutex; } + + private: + template<typename _Rep, typename _Period> + typename enable_if< + ratio_less_equal<__clock_t::period, _Period>::value, bool>::type + __try_lock_for_impl(const chrono::duration<_Rep, _Period>& __rtime) + { + __clock_t::time_point __atime = __clock_t::now() + + chrono::duration_cast<__clock_t::duration>(__rtime); + + return try_lock_until(__atime); + } + + template <typename _Rep, typename _Period> + typename enable_if< + !ratio_less_equal<__clock_t::period, _Period>::value, bool>::type + __try_lock_for_impl(const chrono::duration<_Rep, _Period>& __rtime) + { + __clock_t::time_point __atime = __clock_t::now() + + ++chrono::duration_cast<__clock_t::duration>(__rtime); + + return try_lock_until(__atime); + } + }; + + /// recursive_timed_mutex + class recursive_timed_mutex + { + typedef __gthread_recursive_mutex_t __native_type; + +#ifdef _GLIBCXX_USE_CLOCK_MONOTONIC + typedef chrono::monotonic_clock __clock_t; +#else + typedef chrono::high_resolution_clock __clock_t; +#endif + + __native_type _M_mutex; + + public: + typedef __native_type* native_handle_type; + + recursive_timed_mutex() + { + // XXX EAGAIN, ENOMEM, EPERM, EBUSY(may), EINVAL(may) +#ifdef __GTHREAD_RECURSIVE_MUTEX_INIT + __native_type __tmp = __GTHREAD_RECURSIVE_MUTEX_INIT; + _M_mutex = __tmp; +#else + __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION(&_M_mutex); +#endif + } + + recursive_timed_mutex(const recursive_timed_mutex&) = delete; + recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete; + + void + lock() + { + int __e = __gthread_recursive_mutex_lock(&_M_mutex); + + // EINVAL, EAGAIN, EBUSY, EINVAL, EDEADLK(may) + if (__e) + __throw_system_error(__e); + } + + bool + try_lock() + { + // XXX EINVAL, EAGAIN, EBUSY + return !__gthread_recursive_mutex_trylock(&_M_mutex); + } + + template <class _Rep, class _Period> + bool + try_lock_for(const chrono::duration<_Rep, _Period>& __rtime) + { return __try_lock_for_impl(__rtime); } + + template <class _Clock, class _Duration> + bool + try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime) + { + chrono::time_point<_Clock, chrono::seconds> __s = + chrono::time_point_cast<chrono::seconds>(__atime); + + chrono::nanoseconds __ns = + chrono::duration_cast<chrono::nanoseconds>(__atime - __s); + + __gthread_time_t __ts = { + static_cast<std::time_t>(__s.time_since_epoch().count()), + static_cast<long>(__ns.count()) + }; + + return !__gthread_recursive_mutex_timedlock(&_M_mutex, &__ts); + } + + void + unlock() + { + // XXX EINVAL, EAGAIN, EBUSY + __gthread_recursive_mutex_unlock(&_M_mutex); + } + + native_handle_type + native_handle() + { return &_M_mutex; } + + private: + template<typename _Rep, typename _Period> + typename enable_if< + ratio_less_equal<__clock_t::period, _Period>::value, bool>::type + __try_lock_for_impl(const chrono::duration<_Rep, _Period>& __rtime) + { + __clock_t::time_point __atime = __clock_t::now() + + chrono::duration_cast<__clock_t::duration>(__rtime); + + return try_lock_until(__atime); + } + + template <typename _Rep, typename _Period> + typename enable_if< + !ratio_less_equal<__clock_t::period, _Period>::value, bool>::type + __try_lock_for_impl(const chrono::duration<_Rep, _Period>& __rtime) + { + __clock_t::time_point __atime = __clock_t::now() + + ++chrono::duration_cast<__clock_t::duration>(__rtime); + + return try_lock_until(__atime); + } + }; + + /// Do not acquire ownership of the mutex. + struct defer_lock_t { }; + + /// Try to acquire ownership of the mutex without blocking. + struct try_to_lock_t { }; + + /// Assume the calling thread has already obtained mutex ownership + /// and manage it. + struct adopt_lock_t { }; + + extern const defer_lock_t defer_lock; + extern const try_to_lock_t try_to_lock; + extern const adopt_lock_t adopt_lock; + + /** + * @brief Thrown to indicate errors with lock operations. + * + * @ingroup exceptions + */ + class lock_error : public exception + { + public: + virtual const char* + what() const throw(); + }; + + /// @brief Scoped lock idiom. + // Acquire the mutex here with a constructor call, then release with + // the destructor call in accordance with RAII style. + template<typename _Mutex> + class lock_guard + { + public: + typedef _Mutex mutex_type; + + explicit lock_guard(mutex_type& __m) : _M_device(__m) + { _M_device.lock(); } + + lock_guard(mutex_type& __m, adopt_lock_t __a) : _M_device(__m) + { _M_device.lock(); } + + ~lock_guard() + { _M_device.unlock(); } + + lock_guard(const lock_guard&) = delete; + lock_guard& operator=(const lock_guard&) = delete; + + private: + mutex_type& _M_device; + }; + + /// unique_lock + template<typename _Mutex> + class unique_lock + { + public: + typedef _Mutex mutex_type; + + unique_lock() + : _M_device(0), _M_owns(false) + { } + + explicit unique_lock(mutex_type& __m) + : _M_device(&__m), _M_owns(false) + { + lock(); + _M_owns = true; + } + + unique_lock(mutex_type& __m, defer_lock_t) + : _M_device(&__m), _M_owns(false) + { } + + unique_lock(mutex_type& __m, try_to_lock_t) + : _M_device(&__m), _M_owns(_M_device->try_lock()) + { } + + unique_lock(mutex_type& __m, adopt_lock_t) + : _M_device(&__m), _M_owns(true) + { + // XXX calling thread owns mutex + } + + template<typename _Clock, typename _Duration> + unique_lock(mutex_type& __m, + const chrono::time_point<_Clock, _Duration>& __atime) + : _M_device(&__m), _M_owns(_M_device->try_lock_until(__atime)) + { } + + template<typename _Rep, typename _Period> + unique_lock(mutex_type& __m, + const chrono::duration<_Rep, _Period>& __rtime) + : _M_device(&__m), _M_owns(_M_device->try_lock_for(__rtime)) + { } + + ~unique_lock() + { + if (_M_owns) + unlock(); + } + + unique_lock(const unique_lock&) = delete; + unique_lock& operator=(const unique_lock&) = delete; + + unique_lock(unique_lock&& __u) + : _M_device(__u._M_device), _M_owns(__u._M_owns) + { + __u._M_device = 0; + __u._M_owns = false; + } + + unique_lock& operator=(unique_lock&& __u) + { + if(_M_owns) + unlock(); + + unique_lock(std::move(__u)).swap(*this); + + __u._M_device = 0; + __u._M_owns = false; + + return *this; + } + + void + lock() + { + if (!_M_device) + __throw_system_error(int(errc::operation_not_permitted)); + else if (_M_owns) + __throw_system_error(int(errc::resource_deadlock_would_occur)); + else + { + _M_device->lock(); + _M_owns = true; + } + } + + bool + try_lock() + { + if (!_M_device) + __throw_system_error(int(errc::operation_not_permitted)); + else if (_M_owns) + __throw_system_error(int(errc::resource_deadlock_would_occur)); + else + { + _M_owns = _M_device->try_lock(); + return _M_owns; + } + } + + template<typename _Clock, typename _Duration> + bool + try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime) + { + if (!_M_device) + __throw_system_error(int(errc::operation_not_permitted)); + else if (_M_owns) + __throw_system_error(int(errc::resource_deadlock_would_occur)); + else + { + _M_owns = _M_device->try_lock_until(__atime); + return _M_owns; + } + } + + template<typename _Rep, typename _Period> + bool + try_lock_for(const chrono::duration<_Rep, _Period>& __rtime) + { + if (!_M_device) + __throw_system_error(int(errc::operation_not_permitted)); + else if (_M_owns) + __throw_system_error(int(errc::resource_deadlock_would_occur)); + else + { + _M_owns = _M_device->try_lock_for(__rtime); + return _M_owns; + } + } + + void + unlock() + { + if (!_M_owns) + __throw_system_error(int(errc::operation_not_permitted)); + else if (_M_device) + { + _M_device->unlock(); + _M_owns = false; + } + } + + void + swap(unique_lock&& __u) + { + std::swap(_M_device, __u._M_device); + std::swap(_M_owns, __u._M_owns); + } + + mutex_type* + release() + { + mutex_type* __ret = _M_device; + _M_device = 0; + _M_owns = false; + return __ret; + } + + bool + owns_lock() const + { return _M_owns; } + + /* explicit */ operator bool () const + { return owns_lock(); } + + mutex_type* + mutex() const + { return _M_device; } + + private: + mutex_type* _M_device; + bool _M_owns; // XXX use atomic_bool + }; + + template<typename _Mutex> + inline void + swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>& __y) + { __x.swap(__y); } + + template<typename _Mutex> + inline void + swap(unique_lock<_Mutex>&& __x, unique_lock<_Mutex>& __y) + { __x.swap(__y); } + + template<typename _Mutex> + inline void + swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>&& __y) + { __x.swap(__y); } + + template<int _Idx> + struct __unlock_impl + { + template<typename... _Lock> + static void + __do_unlock(tuple<_Lock&...>& __locks) + { + std::get<_Idx>(__locks).unlock(); + __unlock_impl<_Idx - 1>::__do_unlock(__locks); + } + }; + + template<> + struct __unlock_impl<-1> + { + template<typename... _Lock> + static void + __do_unlock(tuple<_Lock&...>&) + { } + }; + + template<int _Idx, bool _Continue = true> + struct __try_lock_impl + { + template<typename... _Lock> + static int + __do_try_lock(tuple<_Lock&...>& __locks) + { + if(std::get<_Idx>(__locks).try_lock()) + { + return __try_lock_impl<_Idx + 1, + _Idx + 2 < sizeof...(_Lock)>::__do_try_lock(__locks); + } + else + { + __unlock_impl<_Idx>::__do_unlock(__locks); + return _Idx; + } + } + }; + + template<int _Idx> + struct __try_lock_impl<_Idx, false> + { + template<typename... _Lock> + static int + __do_try_lock(tuple<_Lock&...>& __locks) + { + if(std::get<_Idx>(__locks).try_lock()) + return -1; + else + { + __unlock_impl<_Idx>::__do_unlock(__locks); + return _Idx; + } + } + }; + + /** @brief Generic try_lock. + * @param __l1 Meets Mutex requirements (try_lock() may throw). + * @param __l2 Meets Mutex requirements (try_lock() may throw). + * @param __l3 Meets Mutex requirements (try_lock() may throw). + * @return Returns -1 if all try_lock() calls return true. Otherwise returns + * a 0-based index corresponding to the argument that returned false. + * @post Either all arguments are locked, or none will be. + * + * Sequentially calls try_lock() on each argument. + */ + template<typename _Lock1, typename _Lock2, typename... _Lock3> + int + try_lock(_Lock1& __l1, _Lock2& __l2, _Lock3&... __l3) + { + tuple<_Lock1&, _Lock2&, _Lock3&...> __locks(__l1, __l2, __l3...); + return __try_lock_impl<0>::__do_try_lock(__locks); + } + + /// lock + template<typename _L1, typename _L2, typename ..._L3> + void + lock(_L1&, _L2&, _L3&...); + + /// once_flag + struct once_flag + { + private: + typedef __gthread_once_t __native_type; + __native_type _M_once; + + public: + once_flag() + { + __native_type __tmp = __GTHREAD_ONCE_INIT; + _M_once = __tmp; + } + + once_flag(const once_flag&) = delete; + once_flag& operator=(const once_flag&) = delete; + + template<typename _Callable, typename... _Args> + friend void + call_once(once_flag& __once, _Callable __f, _Args&&... __args); + }; + +#ifdef _GLIBCXX_HAVE_TLS + extern __thread void* __once_callable; + extern __thread void (*__once_call)(); + + template<typename _Callable> + inline void + __once_call_impl() + { + (*(_Callable*)__once_callable)(); + } +#else + extern function<void()> __once_functor; + + extern void + __set_once_functor_lock_ptr(unique_lock<mutex>*); + + extern mutex& + __get_once_mutex(); +#endif + + extern "C" void __once_proxy(); + + /// call_once + template<typename _Callable, typename... _Args> + void + call_once(once_flag& __once, _Callable __f, _Args&&... __args) + { +#ifdef _GLIBCXX_HAVE_TLS + auto __bound_functor = bind(__f, __args...); + __once_callable = &__bound_functor; + __once_call = &__once_call_impl<decltype(__bound_functor)>; +#else + unique_lock<mutex> __functor_lock(__get_once_mutex()); + __once_functor = bind(__f, __args...); + __set_once_functor_lock_ptr(&__functor_lock); +#endif + + int __e = __gthread_once(&(__once._M_once), &__once_proxy); + +#ifndef _GLIBCXX_HAVE_TLS + if (__functor_lock) + __set_once_functor_lock_ptr(0); +#endif + + if (__e) + __throw_system_error(__e); + } + + // @} group mutexes +} + +#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1 + +#endif // __GXX_EXPERIMENTAL_CXX0X__ + +#endif // _GLIBCXX_MUTEX diff --git a/gcc-4.4.3/libstdc++-v3/include/std/numeric b/gcc-4.4.3/libstdc++-v3/include/std/numeric new file mode 100644 index 000000000..43d76d980 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/numeric @@ -0,0 +1,78 @@ +// <numeric> -*- C++ -*- + +// Copyright (C) 2001, 2002, 2009 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file include/numeric + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_NUMERIC +#define _GLIBCXX_NUMERIC 1 + +#pragma GCC system_header + +#include <bits/c++config.h> +#include <cstddef> +#include <bits/stl_iterator_base_types.h> +#include <bits/stl_numeric.h> + +#ifdef _GLIBCXX_PARALLEL +# include <parallel/numeric> +#endif + +/** + * @defgroup numerics Numerics + * + * Components for performing numeric operations. Includes support for + * for complex number types, random number generation, numeric + * (n-at-a-time) arrays, generalized numeric algorithms, and special + * math functions. + */ + +#endif /* _GLIBCXX_NUMERIC */ diff --git a/gcc-4.4.3/libstdc++-v3/include/std/ostream b/gcc-4.4.3/libstdc++-v3/include/std/ostream new file mode 100644 index 000000000..c49b36fc7 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/ostream @@ -0,0 +1,568 @@ +// Output streams -*- C++ -*- + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, +// 2006, 2007, 2008, 2009 +// 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file ostream + * This is a Standard C++ Library header. + */ + +// +// ISO C++ 14882: 27.6.2 Output streams +// + +#ifndef _GLIBCXX_OSTREAM +#define _GLIBCXX_OSTREAM 1 + +#pragma GCC system_header + +#include <ios> +#include <bits/ostream_insert.h> + +_GLIBCXX_BEGIN_NAMESPACE(std) + + // [27.6.2.1] Template class basic_ostream + /** + * @brief Controlling output. + * @ingroup io + * + * This is the base class for all output streams. It provides text + * formatting of all builtin types, and communicates with any class + * derived from basic_streambuf to do the actual output. + */ + template<typename _CharT, typename _Traits> + class basic_ostream : virtual public basic_ios<_CharT, _Traits> + { + public: + // Types (inherited from basic_ios (27.4.4)): + typedef _CharT char_type; + typedef typename _Traits::int_type int_type; + typedef typename _Traits::pos_type pos_type; + typedef typename _Traits::off_type off_type; + typedef _Traits traits_type; + + // Non-standard Types: + typedef basic_streambuf<_CharT, _Traits> __streambuf_type; + typedef basic_ios<_CharT, _Traits> __ios_type; + typedef basic_ostream<_CharT, _Traits> __ostream_type; + typedef num_put<_CharT, ostreambuf_iterator<_CharT, _Traits> > + __num_put_type; + typedef ctype<_CharT> __ctype_type; + + // [27.6.2.2] constructor/destructor + /** + * @brief Base constructor. + * + * This ctor is almost never called by the user directly, rather from + * derived classes' initialization lists, which pass a pointer to + * their own stream buffer. + */ + explicit + basic_ostream(__streambuf_type* __sb) + { this->init(__sb); } + + /** + * @brief Base destructor. + * + * This does very little apart from providing a virtual base dtor. + */ + virtual + ~basic_ostream() { } + + // [27.6.2.3] prefix/suffix + class sentry; + friend class sentry; + + // [27.6.2.5] formatted output + // [27.6.2.5.3] basic_ostream::operator<< + //@{ + /** + * @brief Interface for manipulators. + * + * Manipulators such as @c std::endl and @c std::hex use these + * functions in constructs like "std::cout << std::endl". For more + * information, see the iomanip header. + */ + __ostream_type& + operator<<(__ostream_type& (*__pf)(__ostream_type&)) + { + // _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 + /** + * @name Arithmetic Inserters + * + * All the @c operator<< functions (aka <em>formatted output + * functions</em>) have some common behavior. Each starts by + * constructing a temporary object of type std::basic_ostream::sentry. + * This can have several effects, concluding with the setting of a + * status flag; see the sentry documentation for more. + * + * If the sentry status is good, the function tries to generate + * whatever data is appropriate for the type of the argument. + * + * If an exception is thrown during insertion, ios_base::badbit + * will be turned on in the stream's error state without causing an + * ios_base::failure to be thrown. The original exception will then + * be rethrown. + */ + //@{ + /** + * @brief Basic arithmetic inserters + * @param A variable of builtin type. + * @return @c *this if successful + * + * These functions use the stream's current locale (specifically, the + * @c num_get facet) to perform numeric formatting. + */ + __ostream_type& + operator<<(long __n) + { return _M_insert(__n); } + + __ostream_type& + operator<<(unsigned long __n) + { return _M_insert(__n); } + + __ostream_type& + operator<<(bool __n) + { return _M_insert(__n); } + + __ostream_type& + operator<<(short __n); + + __ostream_type& + operator<<(unsigned short __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); + + __ostream_type& + operator<<(unsigned int __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) + { return _M_insert(__n); } + + __ostream_type& + operator<<(unsigned long long __n) + { return _M_insert(__n); } +#endif + + __ostream_type& + operator<<(double __f) + { return _M_insert(__f); } + + __ostream_type& + operator<<(float __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) + { return _M_insert(__f); } + + __ostream_type& + operator<<(const void* __p) + { return _M_insert(__p); } + + /** + * @brief Extracting from another streambuf. + * @param sb A pointer to a streambuf + * + * This function behaves like one of the basic arithmetic extractors, + * in that it also constructs a sentry object and has the same error + * handling behavior. + * + * If @a sb is NULL, the stream will set failbit in its error state. + * + * Characters are extracted from @a sb and inserted into @c *this + * until one of the following occurs: + * + * - the input stream reaches end-of-file, + * - insertion into the output sequence fails (in this case, the + * character that would have been inserted is not extracted), or + * - an exception occurs while getting a character from @a sb, which + * sets failbit in the error state + * + * If the function inserts no characters, failbit is set. + */ + __ostream_type& + operator<<(__streambuf_type* __sb); + //@} + + // [27.6.2.6] unformatted output functions + /** + * @name Unformatted Output Functions + * + * All the unformatted output functions have some common behavior. + * Each starts by constructing a temporary object of type + * std::basic_ostream::sentry. This has several effects, concluding + * with the setting of a status flag; see the sentry documentation + * for more. + * + * If the sentry status is good, the function tries to generate + * whatever data is appropriate for the type of the argument. + * + * If an exception is thrown during insertion, ios_base::badbit + * will be turned on in the stream's error state. If badbit is on in + * the stream's exceptions mask, the exception will be rethrown + * without completing its actions. + */ + //@{ + /** + * @brief Simple insertion. + * @param c The character to insert. + * @return *this + * + * Tries to insert @a c. + * + * @note This function is not overloaded on signed char and + * unsigned char. + */ + __ostream_type& + put(char_type __c); + + // Core write functionality, without sentry. + void + _M_write(const char_type* __s, streamsize __n) + { + const streamsize __put = this->rdbuf()->sputn(__s, __n); + if (__put != __n) + this->setstate(ios_base::badbit); + } + + /** + * @brief Character string insertion. + * @param s The array to insert. + * @param n Maximum number of characters to insert. + * @return *this + * + * Characters are copied from @a s and inserted into the stream until + * one of the following happens: + * + * - @a n characters are inserted + * - inserting into the output sequence fails (in this case, badbit + * will be set in the stream's error state) + * + * @note This function is not overloaded on signed char and + * unsigned char. + */ + __ostream_type& + write(const char_type* __s, streamsize __n); + //@} + + /** + * @brief Synchronizing the stream buffer. + * @return *this + * + * If @c rdbuf() is a null pointer, changes nothing. + * + * Otherwise, calls @c rdbuf()->pubsync(), and if that returns -1, + * sets badbit. + */ + __ostream_type& + flush(); + + // [27.6.2.4] seek members + /** + * @brief Getting the current write position. + * @return A file position object. + * + * If @c fail() is not false, returns @c pos_type(-1) to indicate + * failure. Otherwise returns @c rdbuf()->pubseekoff(0,cur,out). + */ + pos_type + tellp(); + + /** + * @brief Changing the current write position. + * @param pos A file position object. + * @return *this + * + * If @c fail() is not true, calls @c rdbuf()->pubseekpos(pos). If + * that function fails, sets failbit. + */ + __ostream_type& + seekp(pos_type); + + /** + * @brief Changing the current write position. + * @param off A file offset object. + * @param dir The direction in which to seek. + * @return *this + * + * If @c fail() is not true, calls @c rdbuf()->pubseekoff(off,dir). + * If that function fails, sets failbit. + */ + __ostream_type& + seekp(off_type, ios_base::seekdir); + + protected: + basic_ostream() + { this->init(0); } + + template<typename _ValueT> + __ostream_type& + _M_insert(_ValueT __v); + }; + + /** + * @brief Performs setup work for output streams. + * + * Objects of this class are created before all of the standard + * inserters are run. It is responsible for "exception-safe prefix and + * suffix operations." + */ + template <typename _CharT, typename _Traits> + class basic_ostream<_CharT, _Traits>::sentry + { + // Data Members: + bool _M_ok; + basic_ostream<_CharT, _Traits>& _M_os; + + public: + /** + * @brief The constructor performs preparatory work. + * @param os The output stream to guard. + * + * If the stream state is good (@a os.good() is true), then if the + * stream is tied to another output stream, @c is.tie()->flush() + * is called to synchronize the output sequences. + * + * If the stream state is still good, then the sentry state becomes + * true ("okay"). + */ + explicit + sentry(basic_ostream<_CharT, _Traits>& __os); + + /** + * @brief Possibly flushes the stream. + * + * If @c ios_base::unitbuf is set in @c os.flags(), and + * @c std::uncaught_exception() is true, the sentry destructor calls + * @c flush() on the output stream. + */ + ~sentry() + { + // XXX MT + if (bool(_M_os.flags() & ios_base::unitbuf) && !uncaught_exception()) + { + // Can't call flush directly or else will get into recursive lock. + if (_M_os.rdbuf() && _M_os.rdbuf()->pubsync() == -1) + _M_os.setstate(ios_base::badbit); + } + } + + /** + * @brief Quick status checking. + * @return The sentry state. + * + * For ease of use, sentries may be converted to booleans. The + * return value is that of the sentry state (true == okay). + */ + operator bool() const + { return _M_ok; } + }; + + // [27.6.2.5.4] character insertion templates + //@{ + /** + * @brief Character inserters + * @param out An output stream. + * @param c A character. + * @return out + * + * Behaves like one of the formatted arithmetic inserters described in + * std::basic_ostream. After constructing a sentry object with good + * status, this function inserts a single character and any required + * padding (as determined by [22.2.2.2.2]). @c out.width(0) is then + * called. + * + * If @a c is of type @c char and the character type of the stream is not + * @c char, the character is widened before insertion. + */ + template<typename _CharT, typename _Traits> + inline basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c) + { return __ostream_insert(__out, &__c, 1); } + + template<typename _CharT, typename _Traits> + inline basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __out, char __c) + { return (__out << __out.widen(__c)); } + + // Specialization + template <class _Traits> + 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> + inline basic_ostream<char, _Traits>& + operator<<(basic_ostream<char, _Traits>& __out, signed char __c) + { return (__out << static_cast<char>(__c)); } + + template<class _Traits> + inline basic_ostream<char, _Traits>& + operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c) + { return (__out << static_cast<char>(__c)); } + //@} + + //@{ + /** + * @brief String inserters + * @param out An output stream. + * @param s A character string. + * @return out + * @pre @a s must be a non-NULL pointer + * + * Behaves like one of the formatted arithmetic inserters described in + * std::basic_ostream. After constructing a sentry object with good + * status, this function inserts @c traits::length(s) characters starting + * at @a s, widened if necessary, followed by any required padding (as + * determined by [22.2.2.2.2]). @c out.width(0) is then called. + */ + template<typename _CharT, typename _Traits> + 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> & + operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s); + + // Partial specializations + template<class _Traits> + 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> + 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> + inline basic_ostream<char, _Traits> & + operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s) + { return (__out << reinterpret_cast<const char*>(__s)); } + //@} + + // [27.6.2.7] standard basic_ostream manipulators + /** + * @brief Write a newline and flush the stream. + * + * This manipulator is often mistakenly used when a simple newline is + * desired, leading to poor buffering performance. See + * http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#2 for more + * on this subject. + */ + template<typename _CharT, typename _Traits> + inline basic_ostream<_CharT, _Traits>& + endl(basic_ostream<_CharT, _Traits>& __os) + { return flush(__os.put(__os.widen('\n'))); } + + /** + * @brief Write a null character into the output sequence. + * + * "Null character" is @c CharT() by definition. For CharT of @c char, + * this correctly writes the ASCII @c NUL character string terminator. + */ + template<typename _CharT, typename _Traits> + inline basic_ostream<_CharT, _Traits>& + ends(basic_ostream<_CharT, _Traits>& __os) + { return __os.put(_CharT()); } + + /** + * @brief Flushes the output stream. + * + * This manipulator simply calls the stream's @c flush() member function. + */ + template<typename _CharT, typename _Traits> + inline basic_ostream<_CharT, _Traits>& + flush(basic_ostream<_CharT, _Traits>& __os) + { return __os.flush(); } + +_GLIBCXX_END_NAMESPACE + +#ifndef _GLIBCXX_EXPORT_TEMPLATE +# include <bits/ostream.tcc> +#endif + +#endif /* _GLIBCXX_OSTREAM */ diff --git a/gcc-4.4.3/libstdc++-v3/include/std/queue b/gcc-4.4.3/libstdc++-v3/include/std/queue new file mode 100644 index 000000000..abf984212 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/queue @@ -0,0 +1,67 @@ +// <queue> -*- C++ -*- + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 +// 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file include/queue + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_QUEUE +#define _GLIBCXX_QUEUE 1 + +#pragma GCC system_header + +#include <deque> +#include <vector> +#include <bits/stl_heap.h> +#include <bits/stl_function.h> +#include <bits/stl_queue.h> + +#endif /* _GLIBCXX_QUEUE */ diff --git a/gcc-4.4.3/libstdc++-v3/include/std/random b/gcc-4.4.3/libstdc++-v3/include/std/random new file mode 100644 index 000000000..1cb968cb5 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/random @@ -0,0 +1,70 @@ +// <random> -*- C++ -*- + +// Copyright (C) 2007, 2008, 2009 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file include/random + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_RANDOM +#define _GLIBCXX_RANDOM 1 + +#pragma GCC system_header + +#ifndef __GXX_EXPERIMENTAL_CXX0X__ +# include <c++0x_warning.h> +#else + +#if defined(_GLIBCXX_INCLUDE_AS_TR1) +# error C++0x header cannot be included from TR1 header +#endif + +#include <cmath> +#include <cstdio> +#include <cstdlib> +#include <string> +#include <iosfwd> +#include <limits> +#include <ext/type_traits.h> +#include <ext/numeric_traits.h> +#include <bits/concept_check.h> +#include <debug/debug.h> +#include <type_traits> + +#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# include <tr1_impl/random> +#else +# define _GLIBCXX_INCLUDE_AS_CXX0X +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 +# define _GLIBCXX_END_NAMESPACE_TR1 +# define _GLIBCXX_TR1 +# include <tr1_impl/random> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_CXX0X +#endif + +#endif // __GXX_EXPERIMENTAL_CXX0X__ + +#endif // _GLIBCXX_RANDOM diff --git a/gcc-4.4.3/libstdc++-v3/include/std/ratio b/gcc-4.4.3/libstdc++-v3/include/std/ratio new file mode 100644 index 000000000..f0e8831c5 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/ratio @@ -0,0 +1,303 @@ +// ratio -*- C++ -*- + +// Copyright (C) 2008, 2009 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file ratio + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_RATIO +#define _GLIBCXX_RATIO 1 + +#pragma GCC system_header + +#ifndef __GXX_EXPERIMENTAL_CXX0X__ +# include <c++0x_warning.h> +#else + +#include <type_traits> +#include <cstdint> + +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 + +namespace std +{ + /** + * @defgroup ratio Rational Arithmetic + * @ingroup utilities + * + * Compile time representation of fininte rational numbers. + * @{ + */ + + template<intmax_t _Pn> + struct __static_sign + : integral_constant<intmax_t, (_Pn < 0) ? -1 : 1> + { }; + + template<intmax_t _Pn> + struct __static_abs + : integral_constant<intmax_t, _Pn * __static_sign<_Pn>::value> + { }; + + template<intmax_t _Pn, intmax_t _Qn> + struct __static_gcd; + + template<intmax_t _Pn, intmax_t _Qn> + struct __static_gcd + : __static_gcd<_Qn, (_Pn % _Qn)> + { }; + + template<intmax_t _Pn> + struct __static_gcd<_Pn, 0> + : integral_constant<intmax_t, __static_abs<_Pn>::value> + { }; + + template<intmax_t _Qn> + struct __static_gcd<0, _Qn> + : integral_constant<intmax_t, __static_abs<_Qn>::value> + { }; + + // Let c = 2^(half # of bits in an intmax_t) + // then we find a1, a0, b1, b0 s.t. N = a1*c + a0, M = b1*c + b0 + // The multiplication of N and M becomes, + // N * M = (a1 * b1)c^2 + (a0 * b1 + b0 * a1)c + a0 * b0 + // Multiplication is safe if each term and the sum of the terms + // is representable by intmax_t. + template<intmax_t _Pn, intmax_t _Qn> + struct __safe_multiply + { + private: + static const uintmax_t __c = uintmax_t(1) << (sizeof(intmax_t) * 4); + + static const uintmax_t __a0 = __static_abs<_Pn>::value % __c; + static const uintmax_t __a1 = __static_abs<_Pn>::value / __c; + static const uintmax_t __b0 = __static_abs<_Qn>::value % __c; + static const uintmax_t __b1 = __static_abs<_Qn>::value / __c; + + static_assert(__a1 == 0 || __b1 == 0, + "overflow in multiplication"); + static_assert(__a0 * __b1 + __b0 * __a1 < (__c >> 1), + "overflow in multiplication"); + static_assert(__b0 * __a0 <= __INTMAX_MAX__, + "overflow in multiplication"); + static_assert((__a0 * __b1 + __b0 * __a1) * __c <= + __INTMAX_MAX__ - __b0 * __a0, "overflow in multiplication"); + + public: + static const intmax_t value = _Pn * _Qn; + }; + + // Helpers for __safe_add + template<intmax_t _Pn, intmax_t _Qn, bool> + struct __add_overflow_check_impl + : integral_constant<bool, (_Pn <= __INTMAX_MAX__ - _Qn)> + { }; + + template<intmax_t _Pn, intmax_t _Qn> + struct __add_overflow_check_impl<_Pn, _Qn, false> + : integral_constant<bool, (_Pn >= -__INTMAX_MAX__ - _Qn)> + { }; + + template<intmax_t _Pn, intmax_t _Qn> + struct __add_overflow_check + : __add_overflow_check_impl<_Pn, _Qn, (_Qn >= 0)> + { }; + + template<intmax_t _Pn, intmax_t _Qn> + struct __safe_add + { + static_assert(__add_overflow_check<_Pn, _Qn>::value != 0, + "overflow in addition"); + + static const intmax_t value = _Pn + _Qn; + }; + + /** + * @brief Provides compile-time rational arithmetic. + * + * This class template represents any finite rational number with a + * numerator and denominator representable by compile-time constants of + * type intmax_t. The ratio is simplified when instantiated. + * + * For example: + * @code + * std::ratio<7,-21>::num == -1; + * std::ratio<7,-21>::den == 3; + * @endcode + * + */ + template<intmax_t _Num, intmax_t _Den = 1> + struct ratio + { + static_assert(_Den != 0, "denominator cannot be zero"); + static_assert(_Num >= -__INTMAX_MAX__ && _Den >= -__INTMAX_MAX__, + "out of range"); + + // Note: sign(N) * abs(N) == N + static const intmax_t num = + _Num * __static_sign<_Den>::value / __static_gcd<_Num, _Den>::value; + + static const intmax_t den = + __static_abs<_Den>::value / __static_gcd<_Num, _Den>::value; + }; + + template<intmax_t _Num, intmax_t _Den> + const intmax_t ratio<_Num, _Den>::num; + + template<intmax_t _Num, intmax_t _Den> + const intmax_t ratio<_Num, _Den>::den; + + /// ratio_add + template<typename _R1, typename _R2> + struct ratio_add + { + private: + static const intmax_t __gcd = + __static_gcd<_R1::den, _R2::den>::value; + + public: + typedef ratio< + __safe_add< + __safe_multiply<_R1::num, (_R2::den / __gcd)>::value, + __safe_multiply<_R2::num, (_R1::den / __gcd)>::value>::value, + __safe_multiply<_R1::den, (_R2::den / __gcd)>::value> type; + }; + + /// ratio_subtract + template<typename _R1, typename _R2> + struct ratio_subtract + { + typedef typename ratio_add< + _R1, + ratio<-_R2::num, _R2::den>>::type type; + }; + + /// ratio_multiply + template<typename _R1, typename _R2> + struct ratio_multiply + { + private: + static const intmax_t __gcd1 = + __static_gcd<_R1::num, _R2::den>::value; + static const intmax_t __gcd2 = + __static_gcd<_R2::num, _R1::den>::value; + + public: + typedef ratio< + __safe_multiply<(_R1::num / __gcd1), + (_R2::num / __gcd2)>::value, + __safe_multiply<(_R1::den / __gcd2), + (_R2::den / __gcd1)>::value> type; + }; + + /// ratio_divide + template<typename _R1, typename _R2> + struct ratio_divide + { + static_assert(_R2::num != 0, "division by 0"); + + typedef typename ratio_multiply< + _R1, + ratio<_R2::den, _R2::num>>::type type; + }; + + /// ratio_equal + template<typename _R1, typename _R2> + struct ratio_equal + : integral_constant<bool, _R1::num == _R2::num && _R1::den == _R2::den> + { }; + + /// ratio_not_equal + template<typename _R1, typename _R2> + struct ratio_not_equal + : integral_constant<bool, !ratio_equal<_R1, _R2>::value> + { }; + + template<typename _R1, typename _R2> + struct __ratio_less_simple_impl + : integral_constant<bool, + (__safe_multiply<_R1::num, _R2::den>::value + < __safe_multiply<_R2::num, _R1::den>::value)> + { }; + + // If the denominators are equal or the signs differ, we can just compare + // numerators, otherwise fallback to the simple cross-multiply method. + template<typename _R1, typename _R2> + struct __ratio_less_impl + : conditional<(_R1::den == _R2::den + || (__static_sign<_R1::num>::value + != __static_sign<_R2::num>::value)), + integral_constant<bool, (_R1::num < _R2::num)>, + __ratio_less_simple_impl<_R1, _R2>>::type + { }; + + /// ratio_less + template<typename _R1, typename _R2> + struct ratio_less + : __ratio_less_impl<_R1, _R2>::type + { }; + + /// ratio_less_equal + template<typename _R1, typename _R2> + struct ratio_less_equal + : integral_constant<bool, !ratio_less<_R2, _R1>::value> + { }; + + /// ratio_greater + template<typename _R1, typename _R2> + struct ratio_greater + : integral_constant<bool, ratio_less<_R2, _R1>::value> + { }; + + /// ratio_greater_equal + template<typename _R1, typename _R2> + struct ratio_greater_equal + : integral_constant<bool, !ratio_less<_R1, _R2>::value> + { }; + + typedef ratio<1, 1000000000000000000> atto; + typedef ratio<1, 1000000000000000> femto; + typedef ratio<1, 1000000000000> pico; + typedef ratio<1, 1000000000> nano; + typedef ratio<1, 1000000> micro; + typedef ratio<1, 1000> milli; + typedef ratio<1, 100> centi; + typedef ratio<1, 10> deci; + typedef ratio< 10, 1> deca; + typedef ratio< 100, 1> hecto; + typedef ratio< 1000, 1> kilo; + typedef ratio< 1000000, 1> mega; + typedef ratio< 1000000000, 1> giga; + typedef ratio< 1000000000000, 1> tera; + typedef ratio< 1000000000000000, 1> peta; + typedef ratio< 1000000000000000000, 1> exa; + + // @} group ratio +} + +#endif //_GLIBCXX_USE_C99_STDINT_TR1 + +#endif //__GXX_EXPERIMENTAL_CXX0X__ + +#endif //_GLIBCXX_RATIO diff --git a/gcc-4.4.3/libstdc++-v3/include/std/regex b/gcc-4.4.3/libstdc++-v3/include/std/regex new file mode 100644 index 000000000..3b25044e5 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/regex @@ -0,0 +1,68 @@ +// <regex> -*- C++ -*- + +// Copyright (C) 2007, 2008, 2009 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file include/regex + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_REGEX +#define _GLIBCXX_REGEX 1 + +#pragma GCC system_header + +#ifndef __GXX_EXPERIMENTAL_CXX0X__ +# include <c++0x_warning.h> +#else + +#if defined(_GLIBCXX_INCLUDE_AS_TR1) +# error C++0x header cannot be included from TR1 header +#endif + +#include <algorithm> +#include <bitset> +#include <iterator> +#include <locale> +#include <stdexcept> +#include <string> +#include <vector> +#include <utility> +#include <sstream> + +#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# include <tr1_impl/regex> +#else +# define _GLIBCXX_INCLUDE_AS_CXX0X +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 +# define _GLIBCXX_END_NAMESPACE_TR1 +# define _GLIBCXX_TR1 +# include <tr1_impl/regex> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_CXX0X +#endif + +#endif // __GXX_EXPERIMENTAL_CXX0X__ + +#endif // _GLIBCXX_REGEX diff --git a/gcc-4.4.3/libstdc++-v3/include/std/set b/gcc-4.4.3/libstdc++-v3/include/std/set new file mode 100644 index 000000000..21e3f5a8a --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/set @@ -0,0 +1,68 @@ +// <set> -*- C++ -*- + +// Copyright (C) 2001, 2002, 2009 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file include/set + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_SET +#define _GLIBCXX_SET 1 + +#pragma GCC system_header + +#include <bits/stl_tree.h> +#include <bits/stl_set.h> +#include <bits/stl_multiset.h> + +#ifdef _GLIBCXX_DEBUG +# include <debug/set> +#endif + +#endif /* _GLIBCXX_SET */ diff --git a/gcc-4.4.3/libstdc++-v3/include/std/sstream b/gcc-4.4.3/libstdc++-v3/include/std/sstream new file mode 100644 index 000000000..f5e3191c4 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/sstream @@ -0,0 +1,576 @@ +// String based streams -*- C++ -*- + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, +// 2006, 2008, 2009 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file sstream + * This is a Standard C++ Library header. + */ + +// +// ISO C++ 14882: 27.7 String-based streams +// + +#ifndef _GLIBCXX_SSTREAM +#define _GLIBCXX_SSTREAM 1 + +#pragma GCC system_header + +#include <istream> +#include <ostream> + +_GLIBCXX_BEGIN_NAMESPACE(std) + + // [27.7.1] template class basic_stringbuf + /** + * @brief The actual work of input and output (for std::string). + * @ingroup io + * + * This class associates either or both of its input and output sequences + * with a sequence of characters, which can be initialized from, or made + * available as, a @c std::basic_string. (Paraphrased from [27.7.1]/1.) + * + * For this class, open modes (of type @c ios_base::openmode) have + * @c in set if the input sequence can be read, and @c out set if the + * output sequence can be written. + */ + template<typename _CharT, typename _Traits, typename _Alloc> + class basic_stringbuf : public basic_streambuf<_CharT, _Traits> + { + public: + // Types: + typedef _CharT char_type; + typedef _Traits traits_type; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 251. basic_stringbuf missing allocator_type + typedef _Alloc allocator_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + + 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: + /// Place to stash in || out || in | out settings for current stringbuf. + ios_base::openmode _M_mode; + + // Data Members: + __string_type _M_string; + + public: + // Constructors: + /** + * @brief Starts with an empty string buffer. + * @param mode Whether the buffer can read, or write, or both. + * + * The default constructor initializes the parent class using its + * own default ctor. + */ + explicit + basic_stringbuf(ios_base::openmode __mode = ios_base::in | ios_base::out) + : __streambuf_type(), _M_mode(__mode), _M_string() + { } + + /** + * @brief Starts with an existing string buffer. + * @param str A string to copy as a starting buffer. + * @param mode Whether the buffer can read, or write, or both. + * + * This constructor initializes the parent class using its + * own default ctor. + */ + explicit + basic_stringbuf(const __string_type& __str, + ios_base::openmode __mode = ios_base::in | ios_base::out) + : __streambuf_type(), _M_mode(), _M_string(__str.data(), __str.size()) + { _M_stringbuf_init(__mode); } + + // Get and set: + /** + * @brief Copying out the string buffer. + * @return A copy of one of the underlying sequences. + * + * "If the buffer is only created in input mode, the underlying + * character sequence is equal to the input sequence; otherwise, it + * is equal to the output sequence." [27.7.1.2]/1 + */ + __string_type + str() const + { + __string_type __ret; + if (this->pptr()) + { + // The current egptr() may not be the actual string end. + if (this->pptr() > this->egptr()) + __ret = __string_type(this->pbase(), this->pptr()); + else + __ret = __string_type(this->pbase(), this->egptr()); + } + else + __ret = _M_string; + return __ret; + } + + /** + * @brief Setting a new buffer. + * @param s The string to use as a new sequence. + * + * Deallocates any previous stored sequence, then copies @a s to + * use as a new one. + */ + void + str(const __string_type& __s) + { + // Cannot use _M_string = __s, since v3 strings are COW. + _M_string.assign(__s.data(), __s.size()); + _M_stringbuf_init(_M_mode); + } + + protected: + // Common initialization code goes here. + void + _M_stringbuf_init(ios_base::openmode __mode) + { + _M_mode = __mode; + __size_type __len = 0; + if (_M_mode & (ios_base::ate | ios_base::app)) + __len = _M_string.size(); + _M_sync(const_cast<char_type*>(_M_string.data()), 0, __len); + } + + 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(); + + virtual int_type + pbackfail(int_type __c = traits_type::eof()); + + virtual int_type + overflow(int_type __c = traits_type::eof()); + + /** + * @brief Manipulates the buffer. + * @param s Pointer to a buffer area. + * @param n Size of @a s. + * @return @c this + * + * If no buffer has already been created, and both @a s and @a n are + * non-zero, then @c s is used as a buffer; see + * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch25s02.html + * for more. + */ + virtual __streambuf_type* + setbuf(char_type* __s, streamsize __n) + { + if (__s && __n >= 0) + { + // This is implementation-defined behavior, and assumes + // that an external char_type array of length __n exists + // and has been pre-allocated. If this is not the case, + // things will quickly blow up. + + // Step 1: Destroy the current internal array. + _M_string.clear(); + + // Step 2: Use the external array. + _M_sync(__s, __n, 0); + } + return this; + } + + virtual pos_type + seekoff(off_type __off, ios_base::seekdir __way, + ios_base::openmode __mode = ios_base::in | ios_base::out); + + 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. + void + _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 = _M_mode & ios_base::in; + if (this->pptr() && this->pptr() > this->egptr()) + { + if (__testin) + this->setg(this->eback(), this->gptr(), this->pptr()); + else + this->setg(this->pptr(), this->pptr(), this->pptr()); + } + } + }; + + + // [27.7.2] Template class basic_istringstream + /** + * @brief Controlling input for std::string. + * @ingroup io + * + * This class supports reading from objects of type std::basic_string, + * using the inherited functions from std::basic_istream. To control + * the associated sequence, an instance of std::basic_stringbuf is used, + * which this page refers to as @c sb. + */ + template<typename _CharT, typename _Traits, typename _Alloc> + class basic_istringstream : public basic_istream<_CharT, _Traits> + { + public: + // Types: + typedef _CharT char_type; + typedef _Traits traits_type; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 251. basic_stringbuf missing allocator_type + typedef _Alloc allocator_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + + // Non-standard types: + typedef basic_string<_CharT, _Traits, _Alloc> __string_type; + typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type; + typedef basic_istream<char_type, traits_type> __istream_type; + + private: + __stringbuf_type _M_stringbuf; + + public: + // Constructors: + /** + * @brief Default constructor starts with an empty string buffer. + * @param mode Whether the buffer can read, or write, or both. + * + * @c ios_base::in is automatically included in @a mode. + * + * Initializes @c sb using @c mode|in, and passes @c &sb to the base + * class initializer. Does not allocate any buffer. + * + * That's a lie. We initialize the base class with NULL, because the + * string class does its own memory management. + */ + explicit + basic_istringstream(ios_base::openmode __mode = ios_base::in) + : __istream_type(), _M_stringbuf(__mode | ios_base::in) + { this->init(&_M_stringbuf); } + + /** + * @brief Starts with an existing string buffer. + * @param str A string to copy as a starting buffer. + * @param mode Whether the buffer can read, or write, or both. + * + * @c ios_base::in is automatically included in @a mode. + * + * Initializes @c sb using @a str and @c mode|in, and passes @c &sb + * to the base class initializer. + * + * That's a lie. We initialize the base class with NULL, because the + * string class does its own memory management. + */ + explicit + basic_istringstream(const __string_type& __str, + ios_base::openmode __mode = ios_base::in) + : __istream_type(), _M_stringbuf(__str, __mode | ios_base::in) + { this->init(&_M_stringbuf); } + + /** + * @brief The destructor does nothing. + * + * The buffer is deallocated by the stringbuf object, not the + * formatting stream. + */ + ~basic_istringstream() + { } + + // Members: + /** + * @brief Accessing the underlying buffer. + * @return The current basic_stringbuf buffer. + * + * This hides both signatures of std::basic_ios::rdbuf(). + */ + __stringbuf_type* + rdbuf() const + { return const_cast<__stringbuf_type*>(&_M_stringbuf); } + + /** + * @brief Copying out the string buffer. + * @return @c rdbuf()->str() + */ + __string_type + str() const + { return _M_stringbuf.str(); } + + /** + * @brief Setting a new buffer. + * @param s The string to use as a new sequence. + * + * Calls @c rdbuf()->str(s). + */ + void + str(const __string_type& __s) + { _M_stringbuf.str(__s); } + }; + + + // [27.7.3] Template class basic_ostringstream + /** + * @brief Controlling output for std::string. + * @ingroup io + * + * This class supports writing to objects of type std::basic_string, + * using the inherited functions from std::basic_ostream. To control + * the associated sequence, an instance of std::basic_stringbuf is used, + * which this page refers to as @c sb. + */ + template <typename _CharT, typename _Traits, typename _Alloc> + class basic_ostringstream : public basic_ostream<_CharT, _Traits> + { + public: + // Types: + typedef _CharT char_type; + typedef _Traits traits_type; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 251. basic_stringbuf missing allocator_type + typedef _Alloc allocator_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + + // Non-standard types: + typedef basic_string<_CharT, _Traits, _Alloc> __string_type; + typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type; + typedef basic_ostream<char_type, traits_type> __ostream_type; + + private: + __stringbuf_type _M_stringbuf; + + public: + // Constructors/destructor: + /** + * @brief Default constructor starts with an empty string buffer. + * @param mode Whether the buffer can read, or write, or both. + * + * @c ios_base::out is automatically included in @a mode. + * + * Initializes @c sb using @c mode|out, and passes @c &sb to the base + * class initializer. Does not allocate any buffer. + * + * That's a lie. We initialize the base class with NULL, because the + * string class does its own memory management. + */ + explicit + basic_ostringstream(ios_base::openmode __mode = ios_base::out) + : __ostream_type(), _M_stringbuf(__mode | ios_base::out) + { this->init(&_M_stringbuf); } + + /** + * @brief Starts with an existing string buffer. + * @param str A string to copy as a starting buffer. + * @param mode Whether the buffer can read, or write, or both. + * + * @c ios_base::out is automatically included in @a mode. + * + * Initializes @c sb using @a str and @c mode|out, and passes @c &sb + * to the base class initializer. + * + * That's a lie. We initialize the base class with NULL, because the + * string class does its own memory management. + */ + explicit + basic_ostringstream(const __string_type& __str, + ios_base::openmode __mode = ios_base::out) + : __ostream_type(), _M_stringbuf(__str, __mode | ios_base::out) + { this->init(&_M_stringbuf); } + + /** + * @brief The destructor does nothing. + * + * The buffer is deallocated by the stringbuf object, not the + * formatting stream. + */ + ~basic_ostringstream() + { } + + // Members: + /** + * @brief Accessing the underlying buffer. + * @return The current basic_stringbuf buffer. + * + * This hides both signatures of std::basic_ios::rdbuf(). + */ + __stringbuf_type* + rdbuf() const + { return const_cast<__stringbuf_type*>(&_M_stringbuf); } + + /** + * @brief Copying out the string buffer. + * @return @c rdbuf()->str() + */ + __string_type + str() const + { return _M_stringbuf.str(); } + + /** + * @brief Setting a new buffer. + * @param s The string to use as a new sequence. + * + * Calls @c rdbuf()->str(s). + */ + void + str(const __string_type& __s) + { _M_stringbuf.str(__s); } + }; + + + // [27.7.4] Template class basic_stringstream + /** + * @brief Controlling input and output for std::string. + * @ingroup io + * + * This class supports reading from and writing to objects of type + * std::basic_string, using the inherited functions from + * std::basic_iostream. To control the associated sequence, an instance + * of std::basic_stringbuf is used, which this page refers to as @c sb. + */ + template <typename _CharT, typename _Traits, typename _Alloc> + class basic_stringstream : public basic_iostream<_CharT, _Traits> + { + public: + // Types: + typedef _CharT char_type; + typedef _Traits traits_type; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 251. basic_stringbuf missing allocator_type + typedef _Alloc allocator_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + + // Non-standard Types: + typedef basic_string<_CharT, _Traits, _Alloc> __string_type; + typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type; + typedef basic_iostream<char_type, traits_type> __iostream_type; + + private: + __stringbuf_type _M_stringbuf; + + public: + // Constructors/destructors + /** + * @brief Default constructor starts with an empty string buffer. + * @param mode Whether the buffer can read, or write, or both. + * + * Initializes @c sb using @c mode, and passes @c &sb to the base + * class initializer. Does not allocate any buffer. + * + * That's a lie. We initialize the base class with NULL, because the + * string class does its own memory management. + */ + explicit + basic_stringstream(ios_base::openmode __m = ios_base::out | ios_base::in) + : __iostream_type(), _M_stringbuf(__m) + { this->init(&_M_stringbuf); } + + /** + * @brief Starts with an existing string buffer. + * @param str A string to copy as a starting buffer. + * @param mode Whether the buffer can read, or write, or both. + * + * Initializes @c sb using @a str and @c mode, and passes @c &sb + * to the base class initializer. + * + * That's a lie. We initialize the base class with NULL, because the + * string class does its own memory management. + */ + explicit + basic_stringstream(const __string_type& __str, + ios_base::openmode __m = ios_base::out | ios_base::in) + : __iostream_type(), _M_stringbuf(__str, __m) + { this->init(&_M_stringbuf); } + + /** + * @brief The destructor does nothing. + * + * The buffer is deallocated by the stringbuf object, not the + * formatting stream. + */ + ~basic_stringstream() + { } + + // Members: + /** + * @brief Accessing the underlying buffer. + * @return The current basic_stringbuf buffer. + * + * This hides both signatures of std::basic_ios::rdbuf(). + */ + __stringbuf_type* + rdbuf() const + { return const_cast<__stringbuf_type*>(&_M_stringbuf); } + + /** + * @brief Copying out the string buffer. + * @return @c rdbuf()->str() + */ + __string_type + str() const + { return _M_stringbuf.str(); } + + /** + * @brief Setting a new buffer. + * @param s The string to use as a new sequence. + * + * Calls @c rdbuf()->str(s). + */ + void + str(const __string_type& __s) + { _M_stringbuf.str(__s); } + }; + +_GLIBCXX_END_NAMESPACE + +#ifndef _GLIBCXX_EXPORT_TEMPLATE +# include <bits/sstream.tcc> +#endif + +#endif /* _GLIBCXX_SSTREAM */ diff --git a/gcc-4.4.3/libstdc++-v3/include/std/stack b/gcc-4.4.3/libstdc++-v3/include/std/stack new file mode 100644 index 000000000..4ee2c72a7 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/stack @@ -0,0 +1,64 @@ +// <stack> -*- C++ -*- + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 +// 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file include/stack + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_STACK +#define _GLIBCXX_STACK 1 + +#pragma GCC system_header + +#include <deque> +#include <bits/stl_stack.h> + +#endif /* _GLIBCXX_STACK */ diff --git a/gcc-4.4.3/libstdc++-v3/include/std/stdexcept b/gcc-4.4.3/libstdc++-v3/include/std/stdexcept new file mode 100644 index 000000000..9f5c9761c --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/stdexcept @@ -0,0 +1,150 @@ +// Standard exception classes -*- C++ -*- + +// Copyright (C) 2001, 2002, 2005, 2007, 2009 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file stdexcept + * This is a Standard C++ Library header. + */ + +// +// ISO C++ 19.1 Exception classes +// + +#ifndef _GLIBCXX_STDEXCEPT +#define _GLIBCXX_STDEXCEPT 1 + +#pragma GCC system_header + +#include <exception> +#include <string> + +_GLIBCXX_BEGIN_NAMESPACE(std) + + /** + * @addtogroup exceptions + * @{ + */ + + /** 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). + * @brief One of two subclasses of exception. + */ + class logic_error : public exception + { + string _M_msg; + + public: + /** Takes a character string describing the error. */ + explicit + logic_error(const string& __arg); + + virtual + ~logic_error() throw(); + + /** Returns a C-style character string describing the general cause of + * the current error (the same string passed to the ctor). */ + virtual const char* + what() const throw(); + }; + + /** Thrown by the library, or by you, to report domain errors (domain in + * the mathematical sense). */ + class domain_error : public logic_error + { + public: + explicit domain_error(const string& __arg); + }; + + /** Thrown to report invalid arguments to functions. */ + class invalid_argument : public logic_error + { + public: + explicit invalid_argument(const string& __arg); + }; + + /** Thrown when an object is constructed that would exceed its maximum + * permitted size (e.g., a basic_string instance). */ + class length_error : public logic_error + { + public: + explicit length_error(const string& __arg); + }; + + /** This represents an argument whose value is not within the expected + * range (e.g., boundary checks in basic_string). */ + class out_of_range : public logic_error + { + public: + explicit out_of_range(const string& __arg); + }; + + /** Runtime errors represent problems outside the scope of a program; + * they cannot be easily predicted and can generally only be caught as + * the program executes. + * @brief One of two subclasses of exception. + */ + class runtime_error : public exception + { + string _M_msg; + + public: + /** Takes a character string describing the error. */ + explicit + runtime_error(const string& __arg); + + virtual + ~runtime_error() throw(); + + /** Returns a C-style character string describing the general cause of + * the current error (the same string passed to the ctor). */ + virtual const char* + what() const throw(); + }; + + /** Thrown to indicate range errors in internal computations. */ + class range_error : public runtime_error + { + public: + explicit range_error(const string& __arg); + }; + + /** Thrown to indicate arithmetic overflow. */ + class overflow_error : public runtime_error + { + public: + explicit overflow_error(const string& __arg); + }; + + /** Thrown to indicate arithmetic underflow. */ + class underflow_error : public runtime_error + { + public: + explicit underflow_error(const string& __arg); + }; + + // @} group exceptions + +_GLIBCXX_END_NAMESPACE + +#endif /* _GLIBCXX_STDEXCEPT */ diff --git a/gcc-4.4.3/libstdc++-v3/include/std/streambuf b/gcc-4.4.3/libstdc++-v3/include/std/streambuf new file mode 100644 index 000000000..790be0ec4 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/streambuf @@ -0,0 +1,799 @@ +// Stream buffer classes -*- C++ -*- + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, +// 2006, 2007, 2008, 2009 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file streambuf + * This is a Standard C++ Library header. + */ + +// +// ISO C++ 14882: 27.5 Stream buffers +// + +#ifndef _GLIBXX_STREAMBUF +#define _GLIBXX_STREAMBUF 1 + +#pragma GCC system_header + +#include <bits/c++config.h> +#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) + + template<typename _CharT, typename _Traits> + streamsize + __copy_streambufs_eof(basic_streambuf<_CharT, _Traits>*, + basic_streambuf<_CharT, _Traits>*, bool&); + + /** + * @brief The actual work of input and output (interface). + * + * This is a base class. Derived stream buffers each control a + * pair of character sequences: one for input, and one for output. + * + * Section [27.5.1] of the standard describes the requirements and + * behavior of stream buffer classes. That section (three paragraphs) + * is reproduced here, for simplicity and accuracy. + * + * -# Stream buffers can impose various constraints on the sequences + * they control. Some constraints are: + * - The controlled input sequence can be not readable. + * - The controlled output sequence can be not writable. + * - The controlled sequences can be associated with the contents of + * other representations for character sequences, such as external + * files. + * - The controlled sequences can support operations @e directly to or + * from associated sequences. + * - The controlled sequences can impose limitations on how the + * program can read characters from a sequence, write characters to + * a sequence, put characters back into an input sequence, or alter + * the stream position. + * . + * -# Each sequence is characterized by three pointers which, if non-null, + * all point into the same @c charT array object. The array object + * represents, at any moment, a (sub)sequence of characters from the + * sequence. Operations performed on a sequence alter the values + * stored in these pointers, perform reads and writes directly to or + * from associated sequences, and alter "the stream position" and + * conversion state as needed to maintain this subsequence relationship. + * The three pointers are: + * - the <em>beginning pointer</em>, or lowest element address in the + * array (called @e xbeg here); + * - the <em>next pointer</em>, or next element address that is a + * current candidate for reading or writing (called @e xnext here); + * - the <em>end pointer</em>, or first element address beyond the + * end of the array (called @e xend here). + * . + * -# The following semantic constraints shall always apply for any set + * of three pointers for a sequence, using the pointer names given + * immediately above: + * - If @e xnext is not a null pointer, then @e xbeg and @e xend shall + * also be non-null pointers into the same @c charT array, as + * described above; otherwise, @e xbeg and @e xend shall also be null. + * - If @e xnext is not a null pointer and @e xnext < @e xend for an + * output sequence, then a <em>write position</em> is available. + * In this case, @e *xnext shall be assignable as the next element + * to write (to put, or to store a character value, into the sequence). + * - If @e xnext is not a null pointer and @e xbeg < @e xnext for an + * input sequence, then a <em>putback position</em> is available. + * In this case, @e xnext[-1] shall have a defined value and is the + * next (preceding) element to store a character that is put back + * into the input sequence. + * - If @e xnext is not a null pointer and @e xnext< @e xend for an + * input sequence, then a <em>read position</em> is available. + * In this case, @e *xnext shall have a defined value and is the + * next element to read (to get, or to obtain a character value, + * from the sequence). + */ + template<typename _CharT, typename _Traits> + class basic_streambuf + { + public: + //@{ + /** + * These are standard types. They permit a standardized way of + * referring to names of (or names dependant on) the template + * parameters, which are specific to the implementation. + */ + typedef _CharT char_type; + typedef _Traits traits_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + //@} + + //@{ + /// This is a non-standard type. + typedef basic_streambuf<char_type, traits_type> __streambuf_type; + //@} + + friend class basic_ios<char_type, traits_type>; + friend class basic_istream<char_type, traits_type>; + friend class basic_ostream<char_type, traits_type>; + friend class istreambuf_iterator<char_type, traits_type>; + friend class ostreambuf_iterator<char_type, traits_type>; + + friend streamsize + __copy_streambufs_eof<>(__streambuf_type*, __streambuf_type*, bool&); + + template<bool _IsMove, typename _CharT2> + friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, + _CharT2*>::__type + __copy_move_a2(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: + //@{ + /** + * This is based on _IO_FILE, just reordered to be more consistent, + * and is intended to be the most minimal abstraction for an + * internal buffer. + * - get == input == read + * - put == output == write + */ + char_type* _M_in_beg; // Start of get area. + char_type* _M_in_cur; // Current read area. + char_type* _M_in_end; // End of get area. + char_type* _M_out_beg; // Start of put area. + char_type* _M_out_cur; // Current put area. + char_type* _M_out_end; // End of put area. + + /// Current locale setting. + locale _M_buf_locale; + + public: + /// Destructor deallocates no buffer space. + virtual + ~basic_streambuf() + { } + + // [27.5.2.2.1] locales + /** + * @brief Entry point for imbue(). + * @param loc The new locale. + * @return The previous locale. + * + * Calls the derived imbue(loc). + */ + locale + pubimbue(const locale &__loc) + { + locale __tmp(this->getloc()); + this->imbue(__loc); + _M_buf_locale = __loc; + return __tmp; + } + + /** + * @brief Locale access. + * @return The current locale in effect. + * + * If pubimbue(loc) has been called, then the most recent @c loc + * is returned. Otherwise the global locale in effect at the time + * of construction is returned. + */ + locale + getloc() const + { return _M_buf_locale; } + + // [27.5.2.2.2] buffer management and positioning + //@{ + /** + * @brief Entry points for derived buffer functions. + * + * The public versions of @c pubfoo dispatch to the protected + * derived @c foo member functions, passing the arguments (if any) + * and returning the result unchanged. + */ + __streambuf_type* + pubsetbuf(char_type* __s, streamsize __n) + { return this->setbuf(__s, __n); } + + pos_type + pubseekoff(off_type __off, ios_base::seekdir __way, + ios_base::openmode __mode = ios_base::in | ios_base::out) + { return this->seekoff(__off, __way, __mode); } + + pos_type + pubseekpos(pos_type __sp, + ios_base::openmode __mode = ios_base::in | ios_base::out) + { return this->seekpos(__sp, __mode); } + + int + pubsync() { return this->sync(); } + //@} + + // [27.5.2.2.3] get area + /** + * @brief Looking ahead into the stream. + * @return The number of characters available. + * + * If a read position is available, returns the number of characters + * available for reading before the buffer must be refilled. + * Otherwise returns the derived @c showmanyc(). + */ + streamsize + in_avail() + { + const streamsize __ret = this->egptr() - this->gptr(); + return __ret ? __ret : this->showmanyc(); + } + + /** + * @brief Getting the next character. + * @return The next character, or eof. + * + * Calls @c sbumpc(), and if that function returns + * @c traits::eof(), so does this function. Otherwise, @c sgetc(). + */ + int_type + snextc() + { + int_type __ret = traits_type::eof(); + if (__builtin_expect(!traits_type::eq_int_type(this->sbumpc(), + __ret), true)) + __ret = this->sgetc(); + return __ret; + } + + /** + * @brief Getting the next character. + * @return The next character, or eof. + * + * If the input read position is available, returns that character + * and increments the read pointer, otherwise calls and returns + * @c uflow(). + */ + int_type + sbumpc() + { + int_type __ret; + if (__builtin_expect(this->gptr() < this->egptr(), true)) + { + __ret = traits_type::to_int_type(*this->gptr()); + this->gbump(1); + } + else + __ret = this->uflow(); + return __ret; + } + + /** + * @brief Getting the next character. + * @return The next character, or eof. + * + * If the input read position is available, returns that character, + * otherwise calls and returns @c underflow(). Does not move the + * read position after fetching the character. + */ + int_type + sgetc() + { + int_type __ret; + if (__builtin_expect(this->gptr() < this->egptr(), true)) + __ret = traits_type::to_int_type(*this->gptr()); + else + __ret = this->underflow(); + return __ret; + } + + /** + * @brief Entry point for xsgetn. + * @param s A buffer area. + * @param n A count. + * + * Returns xsgetn(s,n). The effect is to fill @a s[0] through + * @a s[n-1] with characters from the input sequence, if possible. + */ + streamsize + sgetn(char_type* __s, streamsize __n) + { return this->xsgetn(__s, __n); } + + // [27.5.2.2.4] putback + /** + * @brief Pushing characters back into the input stream. + * @param c The character to push back. + * @return The previous character, if possible. + * + * Similar to sungetc(), but @a c is pushed onto the stream instead + * of "the previous character". If successful, the next character + * fetched from the input stream will be @a c. + */ + int_type + sputbackc(char_type __c) + { + int_type __ret; + const bool __testpos = this->eback() < this->gptr(); + if (__builtin_expect(!__testpos || + !traits_type::eq(__c, this->gptr()[-1]), false)) + __ret = this->pbackfail(traits_type::to_int_type(__c)); + else + { + this->gbump(-1); + __ret = traits_type::to_int_type(*this->gptr()); + } + return __ret; + } + + /** + * @brief Moving backwards in the input stream. + * @return The previous character, if possible. + * + * If a putback position is available, this function decrements the + * input pointer and returns that character. Otherwise, calls and + * returns pbackfail(). The effect is to "unget" the last character + * "gotten". + */ + int_type + sungetc() + { + int_type __ret; + if (__builtin_expect(this->eback() < this->gptr(), true)) + { + this->gbump(-1); + __ret = traits_type::to_int_type(*this->gptr()); + } + else + __ret = this->pbackfail(); + return __ret; + } + + // [27.5.2.2.5] put area + /** + * @brief Entry point for all single-character output functions. + * @param c A character to output. + * @return @a c, if possible. + * + * One of two public output functions. + * + * If a write position is available for the output sequence (i.e., + * the buffer is not full), stores @a c in that position, increments + * the position, and returns @c traits::to_int_type(c). If a write + * position is not available, returns @c overflow(c). + */ + int_type + sputc(char_type __c) + { + int_type __ret; + if (__builtin_expect(this->pptr() < this->epptr(), true)) + { + *this->pptr() = __c; + this->pbump(1); + __ret = traits_type::to_int_type(__c); + } + else + __ret = this->overflow(traits_type::to_int_type(__c)); + return __ret; + } + + /** + * @brief Entry point for all single-character output functions. + * @param s A buffer read area. + * @param n A count. + * + * One of two public output functions. + * + * + * Returns xsputn(s,n). The effect is to write @a s[0] through + * @a s[n-1] to the output sequence, if possible. + */ + streamsize + sputn(const char_type* __s, streamsize __n) + { return this->xsputn(__s, __n); } + + protected: + /** + * @brief Base constructor. + * + * Only called from derived constructors, and sets up all the + * buffer data to zero, including the pointers described in the + * basic_streambuf class description. Note that, as a result, + * - the class starts with no read nor write positions available, + * - this is not an error + */ + basic_streambuf() + : _M_in_beg(0), _M_in_cur(0), _M_in_end(0), + _M_out_beg(0), _M_out_cur(0), _M_out_end(0), + _M_buf_locale(locale()) + { } + + // [27.5.2.3.1] get area access + //@{ + /** + * @brief Access to the get area. + * + * These functions are only available to other protected functions, + * including derived classes. + * + * - eback() returns the beginning pointer for the input sequence + * - gptr() returns the next pointer for the input sequence + * - egptr() returns the end pointer for the input sequence + */ + char_type* + eback() const { return _M_in_beg; } + + char_type* + gptr() const { return _M_in_cur; } + + char_type* + egptr() const { return _M_in_end; } + //@} + + /** + * @brief Moving the read position. + * @param n The delta by which to move. + * + * This just advances the read position without returning any data. + */ + void + gbump(int __n) { _M_in_cur += __n; } + + /** + * @brief Setting the three read area pointers. + * @param gbeg A pointer. + * @param gnext A pointer. + * @param gend A pointer. + * @post @a gbeg == @c eback(), @a gnext == @c gptr(), and + * @a gend == @c egptr() + */ + void + setg(char_type* __gbeg, char_type* __gnext, char_type* __gend) + { + _M_in_beg = __gbeg; + _M_in_cur = __gnext; + _M_in_end = __gend; + } + + // [27.5.2.3.2] put area access + //@{ + /** + * @brief Access to the put area. + * + * These functions are only available to other protected functions, + * including derived classes. + * + * - pbase() returns the beginning pointer for the output sequence + * - pptr() returns the next pointer for the output sequence + * - epptr() returns the end pointer for the output sequence + */ + char_type* + pbase() const { return _M_out_beg; } + + char_type* + pptr() const { return _M_out_cur; } + + char_type* + epptr() const { return _M_out_end; } + //@} + + /** + * @brief Moving the write position. + * @param n The delta by which to move. + * + * This just advances the write position without returning any data. + */ + void + pbump(int __n) { _M_out_cur += __n; } + + /** + * @brief Setting the three write area pointers. + * @param pbeg A pointer. + * @param pend A pointer. + * @post @a pbeg == @c pbase(), @a pbeg == @c pptr(), and + * @a pend == @c epptr() + */ + void + setp(char_type* __pbeg, char_type* __pend) + { + _M_out_beg = _M_out_cur = __pbeg; + _M_out_end = __pend; + } + + // [27.5.2.4] virtual functions + // [27.5.2.4.1] locales + /** + * @brief Changes translations. + * @param loc A new locale. + * + * Translations done during I/O which depend on the current locale + * are changed by this call. The standard adds, "Between invocations + * of this function a class derived from streambuf can safely cache + * results of calls to locale functions and to members of facets + * so obtained." + * + * @note Base class version does nothing. + */ + virtual void + imbue(const locale&) + { } + + // [27.5.2.4.2] buffer management and positioning + /** + * @brief Manipulates the buffer. + * + * Each derived class provides its own appropriate behavior. See + * the next-to-last paragraph of + * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch25s02.html + * for more on this function. + * + * @note Base class version does nothing, returns @c this. + */ + virtual basic_streambuf<char_type,_Traits>* + setbuf(char_type*, streamsize) + { return this; } + + /** + * @brief Alters the stream positions. + * + * Each derived class provides its own appropriate behavior. + * @note Base class version does nothing, returns a @c pos_type + * that represents an invalid stream position. + */ + virtual pos_type + seekoff(off_type, ios_base::seekdir, + ios_base::openmode /*__mode*/ = ios_base::in | ios_base::out) + { return pos_type(off_type(-1)); } + + /** + * @brief Alters the stream positions. + * + * Each derived class provides its own appropriate behavior. + * @note Base class version does nothing, returns a @c pos_type + * that represents an invalid stream position. + */ + virtual pos_type + seekpos(pos_type, + ios_base::openmode /*__mode*/ = ios_base::in | ios_base::out) + { return pos_type(off_type(-1)); } + + /** + * @brief Synchronizes the buffer arrays with the controlled sequences. + * @return -1 on failure. + * + * Each derived class provides its own appropriate behavior, + * including the definition of "failure". + * @note Base class version does nothing, returns zero. + */ + virtual int + sync() { return 0; } + + // [27.5.2.4.3] get area + /** + * @brief Investigating the data available. + * @return An estimate of the number of characters available in the + * input sequence, or -1. + * + * "If it returns a positive value, then successive calls to + * @c underflow() will not return @c traits::eof() until at least that + * number of characters have been supplied. If @c showmanyc() + * returns -1, then calls to @c underflow() or @c uflow() will fail." + * [27.5.2.4.3]/1 + * + * @note Base class version does nothing, returns zero. + * @note The standard adds that "the intention is not only that the + * calls [to underflow or uflow] will not return @c eof() but + * that they will return "immediately". + * @note The standard adds that "the morphemes of @c showmanyc are + * "es-how-many-see", not "show-manic". + */ + virtual streamsize + showmanyc() { return 0; } + + /** + * @brief Multiple character extraction. + * @param s A buffer area. + * @param n Maximum number of characters to assign. + * @return The number of characters assigned. + * + * Fills @a s[0] through @a s[n-1] with characters from the input + * sequence, as if by @c sbumpc(). Stops when either @a n characters + * have been copied, or when @c traits::eof() would be copied. + * + * It is expected that derived classes provide a more efficient + * implementation by overriding this definition. + */ + virtual streamsize + xsgetn(char_type* __s, streamsize __n); + + /** + * @brief Fetches more data from the controlled sequence. + * @return The first character from the <em>pending sequence</em>. + * + * Informally, this function is called when the input buffer is + * exhausted (or does not exist, as buffering need not actually be + * done). If a buffer exists, it is "refilled". In either case, the + * next available character is returned, or @c traits::eof() to + * indicate a null pending sequence. + * + * For a formal definition of the pending sequence, see a good text + * such as Langer & Kreft, or [27.5.2.4.3]/7-14. + * + * A functioning input streambuf can be created by overriding only + * this function (no buffer area will be used). For an example, see + * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch25.html + * + * @note Base class version does nothing, returns eof(). + */ + virtual int_type + underflow() + { return traits_type::eof(); } + + /** + * @brief Fetches more data from the controlled sequence. + * @return The first character from the <em>pending sequence</em>. + * + * Informally, this function does the same thing as @c underflow(), + * and in fact is required to call that function. It also returns + * the new character, like @c underflow() does. However, this + * function also moves the read position forward by one. + */ + virtual int_type + uflow() + { + int_type __ret = traits_type::eof(); + const bool __testeof = traits_type::eq_int_type(this->underflow(), + __ret); + if (!__testeof) + { + __ret = traits_type::to_int_type(*this->gptr()); + this->gbump(1); + } + return __ret; + } + + // [27.5.2.4.4] putback + /** + * @brief Tries to back up the input sequence. + * @param c The character to be inserted back into the sequence. + * @return eof() on failure, "some other value" on success + * @post The constraints of @c gptr(), @c eback(), and @c pptr() + * are the same as for @c underflow(). + * + * @note Base class version does nothing, returns eof(). + */ + virtual int_type + pbackfail(int_type /* __c */ = traits_type::eof()) + { return traits_type::eof(); } + + // Put area: + /** + * @brief Multiple character insertion. + * @param s A buffer area. + * @param n Maximum number of characters to write. + * @return The number of characters written. + * + * Writes @a s[0] through @a s[n-1] to the output sequence, as if + * by @c sputc(). Stops when either @a n characters have been + * copied, or when @c sputc() would return @c traits::eof(). + * + * It is expected that derived classes provide a more efficient + * implementation by overriding this definition. + */ + virtual streamsize + xsputn(const char_type* __s, streamsize __n); + + /** + * @brief Consumes data from the buffer; writes to the + * controlled sequence. + * @param c An additional character to consume. + * @return eof() to indicate failure, something else (usually + * @a c, or not_eof()) + * + * Informally, this function is called when the output buffer is full + * (or does not exist, as buffering need not actually be done). If a + * buffer exists, it is "consumed", with "some effect" on the + * controlled sequence. (Typically, the buffer is written out to the + * sequence verbatim.) In either case, the character @a c is also + * written out, if @a c is not @c eof(). + * + * For a formal definition of this function, see a good text + * such as Langer & Kreft, or [27.5.2.4.5]/3-7. + * + * A functioning output streambuf can be created by overriding only + * this function (no buffer area will be used). + * + * @note Base class version does nothing, returns eof(). + */ + virtual int_type + overflow(int_type /* __c */ = traits_type::eof()) + { return traits_type::eof(); } + +#if _GLIBCXX_DEPRECATED + // Annex D.6 + public: + /** + * @brief Tosses a character. + * + * Advances the read pointer, ignoring the character that would have + * been read. + * + * See http://gcc.gnu.org/ml/libstdc++/2002-05/msg00168.html + */ + void + stossc() + { + if (this->gptr() < this->egptr()) + this->gbump(1); + else + this->uflow(); + } +#endif + + private: + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // Side effect of DR 50. + basic_streambuf(const __streambuf_type& __sb) + : _M_in_beg(__sb._M_in_beg), _M_in_cur(__sb._M_in_cur), + _M_in_end(__sb._M_in_end), _M_out_beg(__sb._M_out_beg), + _M_out_cur(__sb._M_out_cur), _M_out_end(__sb._M_out_cur), + _M_buf_locale(__sb._M_buf_locale) + { } + + __streambuf_type& + operator=(const __streambuf_type&) { return *this; }; + }; + + // 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> +#endif + +#endif /* _GLIBCXX_STREAMBUF */ diff --git a/gcc-4.4.3/libstdc++-v3/include/std/string b/gcc-4.4.3/libstdc++-v3/include/std/string new file mode 100644 index 000000000..8c5949fd0 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/string @@ -0,0 +1,59 @@ +// Components for manipulating sequences of characters -*- C++ -*- + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +// 2005, 2006, 2007, 2009 +// 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file include/string + * This is a Standard C++ Library header. + */ + +// +// ISO C++ 14882: 21 Strings library +// + +#ifndef _GLIBCXX_STRING +#define _GLIBCXX_STRING 1 + +#pragma GCC system_header + +#include <bits/c++config.h> +#include <bits/stringfwd.h> +#include <bits/char_traits.h> // NB: In turn includes stl_algobase.h +#include <bits/allocator.h> +#include <bits/cpp_type_traits.h> +#include <bits/localefwd.h> // For operators >>, <<, and getline. +#include <bits/ostream_insert.h> +#include <bits/stl_iterator_base_types.h> +#include <bits/stl_iterator_base_funcs.h> +#include <bits/stl_iterator.h> +#include <bits/stl_function.h> // For less +#include <ext/numeric_traits.h> +#include <bits/stl_algobase.h> +#include <bits/basic_string.h> + +#ifndef _GLIBCXX_EXPORT_TEMPLATE +# include <bits/basic_string.tcc> +#endif + +#endif /* _GLIBCXX_STRING */ diff --git a/gcc-4.4.3/libstdc++-v3/include/std/system_error b/gcc-4.4.3/libstdc++-v3/include/std/system_error new file mode 100644 index 000000000..02dd2df1e --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/system_error @@ -0,0 +1,353 @@ +// <system_error> -*- C++ -*- + +// Copyright (C) 2007, 2008, 2009 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file system_error + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_SYSTEM_ERROR +#define _GLIBCXX_SYSTEM_ERROR 1 + +#pragma GCC system_header + +#ifndef __GXX_EXPERIMENTAL_CXX0X__ +# include <c++0x_warning.h> +#else + +#include <bits/c++config.h> +#include <bits/error_constants.h> +#include <iosfwd> +#include <stdexcept> + +_GLIBCXX_BEGIN_NAMESPACE(std) + + class error_code; + class error_condition; + class error_category; + class system_error; + + /// is_error_code_enum + template<typename _Tp> + struct is_error_code_enum : public false_type { }; + + /// is_error_condition_enum + template<typename _Tp> + struct is_error_condition_enum : public false_type { }; + + template<> + struct is_error_condition_enum<errc> + : public true_type { }; + + + /// error_category + class error_category + { + protected: + error_category() = default; + + public: + virtual ~error_category() { } + + error_category(const error_category&) = delete; + error_category& operator=(const error_category&) = delete; + + virtual const char* + name() const = 0; + + virtual string + message(int) const = 0; + + virtual error_condition + default_error_condition(int __i) const; + + virtual bool + equivalent(int __i, const error_condition& __cond) const; + + virtual bool + equivalent(const error_code& __code, int __i) const; + + bool + operator<(const error_category& __other) const + { return less<const error_category*>()(this, &__other); } + + bool + operator==(const error_category& __other) const + { return this == &__other; } + + bool + operator!=(const error_category& __other) const + { return this != &__other; } + }; + + // DR 890. + const error_category& system_category(); + const error_category& generic_category(); + + error_code make_error_code(errc); + + /// error_code + // Implementation-specific error identification + struct error_code + { + error_code() + : _M_value(0), _M_cat(&system_category()) { } + + error_code(int __v, const error_category& __cat) + : _M_value(__v), _M_cat(&__cat) { } + + template<typename _ErrorCodeEnum> + error_code(_ErrorCodeEnum __e, + typename enable_if<is_error_code_enum<_ErrorCodeEnum>::value>::type* = 0) + { *this = make_error_code(__e); } + + void + assign(int __v, const error_category& __cat) + { + _M_value = __v; + _M_cat = &__cat; + } + + void + clear() + { assign(0, system_category()); } + + // DR 804. + template<typename _ErrorCodeEnum> + typename enable_if<is_error_code_enum<_ErrorCodeEnum>::value, + error_code&>::type + operator=(_ErrorCodeEnum __e) + { return *this = make_error_code(__e); } + + int + value() const { return _M_value; } + + const error_category& + category() const { return *_M_cat; } + + error_condition + default_error_condition() const; + + string + message() const + { return category().message(value()); } + + // Safe bool idiom. + // explicit operator bool() const throw() + // { return _M_value != 0; } + typedef void (*__bool_type)(); + + static void __not_bool_type() { } + + operator __bool_type() const + { return _M_value != 0 ? &__not_bool_type : false; } + + // DR 804. + private: + int _M_value; + const error_category* _M_cat; + }; + + // 19.4.2.6 non-member functions + inline error_code + make_error_code(errc __e) + { return error_code(static_cast<int>(__e), generic_category()); } + + inline bool + operator<(const error_code& __lhs, const error_code& __rhs) + { + return (__lhs.category() < __rhs.category() + || (__lhs.category() == __rhs.category() + && __lhs.value() < __rhs.value())); + } + + template<typename _CharT, typename _Traits> + basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e) + { return (__os << __e.category().name() << ':' << __e.value()); } + + error_condition make_error_condition(errc); + + /// error_condition + // Portable error identification + struct error_condition + { + error_condition() + : _M_value(0), _M_cat(&generic_category()) { } + + error_condition(int __v, const error_category& __cat) + : _M_value(__v), _M_cat(&__cat) { } + + template<typename _ErrorConditionEnum> + error_condition(_ErrorConditionEnum __e, + typename enable_if<is_error_condition_enum + <_ErrorConditionEnum>::value>::type* = 0) + { *this = make_error_condition(__e); } + + void + assign(int __v, const error_category& __cat) + { + _M_value = __v; + _M_cat = &__cat; + } + + // DR 804. + template<typename _ErrorConditionEnum> + typename enable_if<is_error_condition_enum + <_ErrorConditionEnum>::value, error_condition&>::type + operator=(_ErrorConditionEnum __e) + { return *this = make_error_condition(__e); } + + void + clear() + { assign(0, generic_category()); } + + // 19.4.3.4 observers + int + value() const { return _M_value; } + + const error_category& + category() const { return *_M_cat; } + + string + message() const + { return category().message(value()); } + + // Safe bool idiom. + // explicit operator bool() const throw() + // { return _M_value != 0; } + typedef void (*__bool_type)(); + + static void __not_bool_type() { } + + operator __bool_type() const + { return _M_value != 0 ? &__not_bool_type : false; } + + // DR 804. + private: + int _M_value; + const error_category* _M_cat; + }; + + // 19.4.3.6 non-member functions + inline error_condition + make_error_condition(errc __e) + { return error_condition(static_cast<int>(__e), generic_category()); } + + inline bool + operator<(const error_condition& __lhs, const error_condition& __rhs) + { + return (__lhs.category() < __rhs.category() + || (__lhs.category() == __rhs.category() + && __lhs.value() < __rhs.value())); + } + + // 19.4.4 Comparison operators + inline bool + operator==(const error_code& __lhs, const error_code& __rhs) + { return (__lhs.category() == __rhs.category() + && __lhs.value() == __rhs.value()); } + + inline bool + operator==(const error_code& __lhs, const error_condition& __rhs) + { + return (__lhs.category().equivalent(__lhs.value(), __rhs) + || __rhs.category().equivalent(__lhs, __rhs.value())); + } + + inline bool + operator==(const error_condition& __lhs, const error_code& __rhs) + { + return (__rhs.category().equivalent(__rhs.value(), __lhs) + || __lhs.category().equivalent(__rhs, __lhs.value())); + } + + inline bool + operator==(const error_condition& __lhs, const error_condition& __rhs) + { + return (__lhs.category() == __rhs.category() + && __lhs.value() == __rhs.value()); + } + + inline bool + operator!=(const error_code& __lhs, const error_code& __rhs) + { return !(__lhs == __rhs); } + + inline bool + operator!=(const error_code& __lhs, const error_condition& __rhs) + { return !(__lhs == __rhs); } + + inline bool + operator!=(const error_condition& __lhs, const error_code& __rhs) + { return !(__lhs == __rhs); } + + inline bool + operator!=(const error_condition& __lhs, const error_condition& __rhs) + { return !(__lhs == __rhs); } + + + /** + * @brief Thrown to indicate error code of underlying system. + * + * @ingroup exceptions + */ + class system_error : public std::runtime_error + { + private: + error_code _M_code; + + public: + system_error(error_code __ec = error_code()) + : runtime_error(""), _M_code(__ec) { } + + system_error(error_code __ec, const string& __what) + : runtime_error(__what), _M_code(__ec) { } + + /* + * TODO: Add const char* ctors to all exceptions. + * + * system_error(error_code __ec, const char* __what) + * : runtime_error(__what), _M_code(__ec) { } + * + * system_error(int __v, const error_category& __ecat, const char* __what) + * : runtime_error(__what), _M_code(error_code(__v, __ecat)) { } + */ + + system_error(int __v, const error_category& __ecat) + : runtime_error(""), _M_code(error_code(__v, __ecat)) { } + + system_error(int __v, const error_category& __ecat, const string& __what) + : runtime_error(__what), _M_code(error_code(__v, __ecat)) { } + + virtual ~system_error() throw(); + + const error_code& + code() const throw() { return _M_code; } + }; + +_GLIBCXX_END_NAMESPACE + +#endif // __GXX_EXPERIMENTAL_CXX0X__ + +#endif // _GLIBCXX_SYSTEM_ERROR + diff --git a/gcc-4.4.3/libstdc++-v3/include/std/thread b/gcc-4.4.3/libstdc++-v3/include/std/thread new file mode 100644 index 000000000..6f735a018 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/thread @@ -0,0 +1,284 @@ +// <thread> -*- C++ -*- + +// Copyright (C) 2008, 2009 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file thread + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_THREAD +#define _GLIBCXX_THREAD 1 + +#pragma GCC system_header + +#ifndef __GXX_EXPERIMENTAL_CXX0X__ +# include <c++0x_warning.h> +#else + +#include <chrono> +#include <functional> +#include <memory> +#include <mutex> +#include <condition_variable> +#include <cstddef> +#include <bits/functexcept.h> +#include <bits/gthr.h> + +#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) + +namespace std +{ + /** + * @defgroup threads Threads + * @ingroup concurrency + * + * Classes for thread support. + * @{ + */ + + /// thread + class thread + { + public: + typedef __gthread_t native_handle_type; + struct _Impl_base; + typedef shared_ptr<_Impl_base> __shared_base_type; + + /// thread::id + class id + { + native_handle_type _M_thread; + + public: + id() : _M_thread() { } + + explicit + id(native_handle_type __id) : _M_thread(__id) { } + + private: + friend class thread; + + friend bool + operator==(thread::id __x, thread::id __y) + { return __gthread_equal(__x._M_thread, __y._M_thread); } + + friend bool + operator<(thread::id __x, thread::id __y) + { return __x._M_thread < __y._M_thread; } + + template<class _CharT, class _Traits> + friend basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>&& __out, thread::id __id); + }; + + // Simple base type that the templatized, derived class containing + // an arbitrary functor can be converted to and called. + struct _Impl_base + { + __shared_base_type _M_this_ptr; + + virtual ~_Impl_base() = default; + + virtual void _M_run() = 0; + }; + + template<typename _Callable> + struct _Impl : public _Impl_base + { + _Callable _M_func; + + _Impl(_Callable&& __f) : _M_func(std::forward<_Callable>(__f)) + { } + + void + _M_run() { _M_func(); } + }; + + private: + id _M_id; + + public: + thread() = default; + thread(const thread&) = delete; + + thread(thread&& __t) + { swap(__t); } + + template<typename _Callable> + explicit thread(_Callable __f) + { _M_start_thread(_M_make_routine<_Callable>(__f)); } + + template<typename _Callable, typename... _Args> + thread(_Callable&& __f, _Args&&... __args) + { _M_start_thread(_M_make_routine(std::bind(__f, __args...))); } + + ~thread() + { + if (joinable()) + std::terminate(); + } + + thread& operator=(const thread&) = delete; + + thread& operator=(thread&& __t) + { + if (joinable()) + std::terminate(); + swap(__t); + return *this; + } + + void + swap(thread&& __t) + { std::swap(_M_id, __t._M_id); } + + bool + joinable() const + { return !(_M_id == id()); } + + void + join(); + + void + detach(); + + thread::id + get_id() const + { return _M_id; } + + /** @pre thread is joinable + */ + native_handle_type + native_handle() + { return _M_id._M_thread; } + + // Returns a value that hints at the number of hardware thread contexts. + static unsigned int + hardware_concurrency() + { return 0; } + + private: + void + _M_start_thread(__shared_base_type); + + template<typename _Callable> + shared_ptr<_Impl<_Callable>> + _M_make_routine(_Callable&& __f) + { + // Create and allocate full data structure, not base. + return make_shared<_Impl<_Callable>>(std::forward<_Callable>(__f)); + } + }; + + inline void + swap(thread& __x, thread& __y) + { __x.swap(__y); } + + inline void + swap(thread&& __x, thread& __y) + { __x.swap(__y); } + + inline void + swap(thread& __x, thread&& __y) + { __x.swap(__y); } + + inline bool + operator!=(thread::id __x, thread::id __y) + { return !(__x == __y); } + + inline bool + operator<=(thread::id __x, thread::id __y) + { return !(__y < __x); } + + inline bool + operator>(thread::id __x, thread::id __y) + { return __y < __x; } + + inline bool + operator>=(thread::id __x, thread::id __y) + { return !(__x < __y); } + + template<class _CharT, class _Traits> + inline basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>&& __out, thread::id __id) + { + if (__id == thread::id()) + return __out << "thread::id of a non-executing thread"; + else + return __out << __id._M_thread; + } + + /** @namespace std::this_thread + * @brief ISO C++ 0x entities sub namespace for thread. + * 30.2.2 Namespace this_thread. + */ + namespace this_thread + { + /// get_id + inline thread::id + get_id() { return thread::id(__gthread_self()); } + +#ifdef _GLIBCXX_USE_SCHED_YIELD + /// yield + inline void + yield() + { __gthread_yield(); } +#endif + +#ifdef _GLIBCXX_USE_NANOSLEEP + /// sleep_until + template<typename _Clock, typename _Duration> + inline void + sleep_until(const chrono::time_point<_Clock, _Duration>& __atime) + { sleep_for(__atime - _Clock::now()); } + + /// sleep_for + template<typename _Rep, typename _Period> + inline void + sleep_for(const chrono::duration<_Rep, _Period>& __rtime) + { + chrono::seconds __s = + chrono::duration_cast<chrono::seconds>(__rtime); + + chrono::nanoseconds __ns = + chrono::duration_cast<chrono::nanoseconds>(__rtime - __s); + + __gthread_time_t __ts = + { + static_cast<std::time_t>(__s.count()), + static_cast<long>(__ns.count()) + }; + + ::nanosleep(&__ts, 0); + } +#endif + } + + // @} group threads +} + +#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1 + +#endif // __GXX_EXPERIMENTAL_CXX0X__ + +#endif // _GLIBCXX_THREAD diff --git a/gcc-4.4.3/libstdc++-v3/include/std/tuple b/gcc-4.4.3/libstdc++-v3/include/std/tuple new file mode 100644 index 000000000..c5dbe6bcc --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/tuple @@ -0,0 +1,697 @@ +// <tuple> -*- C++ -*- + +// Copyright (C) 2007, 2008, 2009 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file include/tuple + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_TUPLE +#define _GLIBCXX_TUPLE 1 + +#pragma GCC system_header + +#ifndef __GXX_EXPERIMENTAL_CXX0X__ +# include <c++0x_warning.h> +#else + +#include <utility> + +namespace std +{ + // Adds a const reference to a non-reference type. + template<typename _Tp> + struct __add_c_ref + { typedef const _Tp& type; }; + + template<typename _Tp> + struct __add_c_ref<_Tp&> + { typedef _Tp& type; }; + + // Adds a reference to a non-reference type. + template<typename _Tp> + struct __add_ref + { typedef _Tp& type; }; + + template<typename _Tp> + struct __add_ref<_Tp&> + { typedef _Tp& type; }; + + template<std::size_t _Idx, typename _Head, bool _IsEmpty> + struct _Head_base; + + template<std::size_t _Idx, typename _Head> + struct _Head_base<_Idx, _Head, true> + : public _Head + { + _Head_base() + : _Head() { } + + _Head_base(const _Head& __h) + : _Head(__h) { } + + template<typename _UHead> + _Head_base(_UHead&& __h) + : _Head(std::forward<_UHead>(__h)) { } + + _Head& _M_head() { return *this; } + const _Head& _M_head() const { return *this; } + + void _M_swap_impl(_Head&&) { /* no-op */ } + }; + + template<std::size_t _Idx, typename _Head> + struct _Head_base<_Idx, _Head, false> + { + _Head_base() + : _M_head_impl() { } + + _Head_base(const _Head& __h) + : _M_head_impl(__h) { } + + template<typename _UHead> + _Head_base(_UHead&& __h) + : _M_head_impl(std::forward<_UHead>(__h)) { } + + _Head& _M_head() { return _M_head_impl; } + const _Head& _M_head() const { return _M_head_impl; } + + void + _M_swap_impl(_Head&& __h) + { + using std::swap; + swap(__h, _M_head_impl); + } + + _Head _M_head_impl; + }; + + /** + * Contains the actual implementation of the @c tuple template, stored + * as a recursive inheritance hierarchy from the first element (most + * derived class) to the last (least derived class). The @c Idx + * parameter gives the 0-based index of the element stored at this + * point in the hierarchy; we use it to implement a constant-time + * get() operation. + */ + template<std::size_t _Idx, typename... _Elements> + struct _Tuple_impl; + + /** + * Zero-element tuple implementation. This is the basis case for the + * inheritance recursion. + */ + template<std::size_t _Idx> + struct _Tuple_impl<_Idx> + { + protected: + void _M_swap_impl(_Tuple_impl&&) { /* no-op */ } + }; + + /** + * Recursive tuple implementation. Here we store the @c Head element + * and derive from a @c Tuple_impl containing the remaining elements + * (which contains the @c Tail). + */ + template<std::size_t _Idx, typename _Head, typename... _Tail> + struct _Tuple_impl<_Idx, _Head, _Tail...> + : public _Tuple_impl<_Idx + 1, _Tail...>, + private _Head_base<_Idx, _Head, std::is_empty<_Head>::value> + { + typedef _Tuple_impl<_Idx + 1, _Tail...> _Inherited; + typedef _Head_base<_Idx, _Head, std::is_empty<_Head>::value> _Base; + + _Head& _M_head() { return _Base::_M_head(); } + const _Head& _M_head() const { return _Base::_M_head(); } + + _Inherited& _M_tail() { return *this; } + const _Inherited& _M_tail() const { return *this; } + + _Tuple_impl() + : _Inherited(), _Base() { } + + explicit + _Tuple_impl(const _Head& __head, const _Tail&... __tail) + : _Inherited(__tail...), _Base(__head) { } + + template<typename _UHead, typename... _UTail> + explicit + _Tuple_impl(_UHead&& __head, _UTail&&... __tail) + : _Inherited(std::forward<_UTail>(__tail)...), + _Base(std::forward<_UHead>(__head)) { } + + _Tuple_impl(const _Tuple_impl& __in) + : _Inherited(__in._M_tail()), _Base(__in._M_head()) { } + + _Tuple_impl(_Tuple_impl&& __in) + : _Inherited(std::move<_Inherited&&>(__in._M_tail())), + _Base(std::forward<_Head>(__in._M_head())) { } + + template<typename... _UElements> + _Tuple_impl(const _Tuple_impl<_Idx, _UElements...>& __in) + : _Inherited(__in._M_tail()), _Base(__in._M_head()) { } + + template<typename... _UElements> + _Tuple_impl(_Tuple_impl<_Idx, _UElements...>&& __in) + : _Inherited(std::move<typename _Tuple_impl<_Idx, _UElements...>:: + _Inherited&&>(__in._M_tail())), + _Base(std::forward<typename _Tuple_impl<_Idx, _UElements...>:: + _Base>(__in._M_head())) { } + + _Tuple_impl& + operator=(const _Tuple_impl& __in) + { + _M_head() = __in._M_head(); + _M_tail() = __in._M_tail(); + return *this; + } + + _Tuple_impl& + operator=(_Tuple_impl&& __in) + { + _M_head() = std::move(__in._M_head()); + _M_tail() = std::move(__in._M_tail()); + return *this; + } + + template<typename... _UElements> + _Tuple_impl& + operator=(const _Tuple_impl<_Idx, _UElements...>& __in) + { + _M_head() = __in._M_head(); + _M_tail() = __in._M_tail(); + return *this; + } + + template<typename... _UElements> + _Tuple_impl& + operator=(_Tuple_impl<_Idx, _UElements...>&& __in) + { + _M_head() = std::move(__in._M_head()); + _M_tail() = std::move(__in._M_tail()); + return *this; + } + + protected: + void + _M_swap_impl(_Tuple_impl&& __in) + { + _Base::_M_swap_impl(__in._M_head()); + _Inherited::_M_swap_impl(__in._M_tail()); + } + }; + + /// tuple + template<typename... _Elements> + class tuple : public _Tuple_impl<0, _Elements...> + { + typedef _Tuple_impl<0, _Elements...> _Inherited; + + public: + tuple() + : _Inherited() { } + + explicit + tuple(const _Elements&... __elements) + : _Inherited(__elements...) { } + + template<typename... _UElements> + explicit + tuple(_UElements&&... __elements) + : _Inherited(std::forward<_UElements>(__elements)...) { } + + tuple(const tuple& __in) + : _Inherited(static_cast<const _Inherited&>(__in)) { } + + tuple(tuple&& __in) + : _Inherited(std::move<_Inherited>(__in)) { } + + template<typename... _UElements> + tuple(const tuple<_UElements...>& __in) + : _Inherited(static_cast<const _Tuple_impl<0, _UElements...>&>(__in)) + { } + + template<typename... _UElements> + tuple(tuple<_UElements...>&& __in) + : _Inherited(std::move<_Tuple_impl<0, _UElements...> >(__in)) { } + + // XXX http://gcc.gnu.org/ml/libstdc++/2008-02/msg00047.html + template<typename... _UElements> + tuple(tuple<_UElements...>& __in) + : _Inherited(static_cast<const _Tuple_impl<0, _UElements...>&>(__in)) + { } + + tuple& + operator=(const tuple& __in) + { + static_cast<_Inherited&>(*this) = __in; + return *this; + } + + tuple& + operator=(tuple&& __in) + { + static_cast<_Inherited&>(*this) = std::move(__in); + return *this; + } + + template<typename... _UElements> + tuple& + operator=(const tuple<_UElements...>& __in) + { + static_cast<_Inherited&>(*this) = __in; + return *this; + } + + template<typename... _UElements> + tuple& + operator=(tuple<_UElements...>&& __in) + { + static_cast<_Inherited&>(*this) = std::move(__in); + return *this; + } + + void + swap(tuple&& __in) + { _Inherited::_M_swap_impl(__in); } + }; + + + template<> + class tuple<> + { + public: + void swap(tuple&&) { /* no-op */ } + }; + + /// tuple (2-element), with construction and assignment from a pair. + template<typename _T1, typename _T2> + class tuple<_T1, _T2> : public _Tuple_impl<0, _T1, _T2> + { + typedef _Tuple_impl<0, _T1, _T2> _Inherited; + + public: + tuple() + : _Inherited() { } + + explicit + tuple(const _T1& __a1, const _T2& __a2) + : _Inherited(__a1, __a2) { } + + template<typename _U1, typename _U2> + explicit + tuple(_U1&& __a1, _U2&& __a2) + : _Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { } + + tuple(const tuple& __in) + : _Inherited(static_cast<const _Inherited&>(__in)) { } + + tuple(tuple&& __in) + : _Inherited(std::move<_Inherited>(__in)) { } + + template<typename _U1, typename _U2> + tuple(const tuple<_U1, _U2>& __in) + : _Inherited(static_cast<const _Tuple_impl<0, _U1, _U2>&>(__in)) { } + + template<typename _U1, typename _U2> + tuple(tuple<_U1, _U2>&& __in) + : _Inherited(std::move<_Tuple_impl<0, _U1, _U2> >(__in)) { } + + template<typename _U1, typename _U2> + tuple(const pair<_U1, _U2>& __in) + : _Inherited(__in.first, __in.second) { } + + template<typename _U1, typename _U2> + tuple(pair<_U1, _U2>&& __in) + : _Inherited(std::move(__in.first), std::move(__in.second)) { } + + tuple& + operator=(const tuple& __in) + { + static_cast<_Inherited&>(*this) = __in; + return *this; + } + + tuple& + operator=(tuple&& __in) + { + static_cast<_Inherited&>(*this) = std::move(__in); + return *this; + } + + template<typename _U1, typename _U2> + tuple& + operator=(const tuple<_U1, _U2>& __in) + { + static_cast<_Inherited&>(*this) = __in; + return *this; + } + + template<typename _U1, typename _U2> + tuple& + operator=(tuple<_U1, _U2>&& __in) + { + static_cast<_Inherited&>(*this) = std::move(__in); + return *this; + } + + template<typename _U1, typename _U2> + tuple& + operator=(const pair<_U1, _U2>& __in) + { + this->_M_head() = __in.first; + this->_M_tail()._M_head() = __in.second; + return *this; + } + + template<typename _U1, typename _U2> + tuple& + operator=(pair<_U1, _U2>&& __in) + { + this->_M_head() = std::move(__in.first); + this->_M_tail()._M_head() = std::move(__in.second); + return *this; + } + + void + swap(tuple&& __in) + { + using std::swap; + swap(this->_M_head(), __in._M_head()); + swap(this->_M_tail()._M_head(), __in._M_tail()._M_head()); + } + }; + + + /// Gives the type of the ith element of a given tuple type. + template<std::size_t __i, typename _Tp> + struct tuple_element; + + /** + * Recursive case for tuple_element: strip off the first element in + * the tuple and retrieve the (i-1)th element of the remaining tuple. + */ + template<std::size_t __i, typename _Head, typename... _Tail> + struct tuple_element<__i, tuple<_Head, _Tail...> > + : tuple_element<__i - 1, tuple<_Tail...> > { }; + + /** + * Basis case for tuple_element: The first element is the one we're seeking. + */ + template<typename _Head, typename... _Tail> + struct tuple_element<0, tuple<_Head, _Tail...> > + { + typedef _Head type; + }; + + /// Finds the size of a given tuple type. + template<typename _Tp> + struct tuple_size; + + /// class tuple_size + template<typename... _Elements> + struct tuple_size<tuple<_Elements...> > + { + static const std::size_t value = sizeof...(_Elements); + }; + + template<typename... _Elements> + const std::size_t tuple_size<tuple<_Elements...> >::value; + + template<std::size_t __i, typename _Head, typename... _Tail> + inline typename __add_ref<_Head>::type + __get_helper(_Tuple_impl<__i, _Head, _Tail...>& __t) + { return __t._M_head(); } + + template<std::size_t __i, typename _Head, typename... _Tail> + inline typename __add_c_ref<_Head>::type + __get_helper(const _Tuple_impl<__i, _Head, _Tail...>& __t) + { return __t._M_head(); } + + // Return a reference (const reference) to the ith element of a tuple. + // Any const or non-const ref elements are returned with their original type. + template<std::size_t __i, typename... _Elements> + inline typename __add_ref< + typename tuple_element<__i, tuple<_Elements...> >::type + >::type + get(tuple<_Elements...>& __t) + { return __get_helper<__i>(__t); } + + template<std::size_t __i, typename... _Elements> + inline typename __add_c_ref< + typename tuple_element<__i, tuple<_Elements...> >::type + >::type + get(const tuple<_Elements...>& __t) + { return __get_helper<__i>(__t); } + + // This class helps construct the various comparison operations on tuples + template<std::size_t __check_equal_size, std::size_t __i, std::size_t __j, + typename _Tp, typename _Up> + struct __tuple_compare; + + template<std::size_t __i, std::size_t __j, typename _Tp, typename _Up> + struct __tuple_compare<0, __i, __j, _Tp, _Up> + { + static bool __eq(const _Tp& __t, const _Up& __u) + { + return (get<__i>(__t) == get<__i>(__u) && + __tuple_compare<0, __i + 1, __j, _Tp, _Up>::__eq(__t, __u)); + } + + static bool __less(const _Tp& __t, const _Up& __u) + { + return ((get<__i>(__t) < get<__i>(__u)) + || !(get<__i>(__u) < get<__i>(__t)) && + __tuple_compare<0, __i + 1, __j, _Tp, _Up>::__less(__t, __u)); + } + }; + + template<std::size_t __i, typename _Tp, typename _Up> + struct __tuple_compare<0, __i, __i, _Tp, _Up> + { + static bool __eq(const _Tp&, const _Up&) + { return true; } + + static bool __less(const _Tp&, const _Up&) + { return false; } + }; + + template<typename... _TElements, typename... _UElements> + bool + operator==(const tuple<_TElements...>& __t, + const tuple<_UElements...>& __u) + { + typedef tuple<_TElements...> _Tp; + typedef tuple<_UElements...> _Up; + return (__tuple_compare<tuple_size<_Tp>::value - tuple_size<_Up>::value, + 0, tuple_size<_Tp>::value, _Tp, _Up>::__eq(__t, __u)); + } + + template<typename... _TElements, typename... _UElements> + bool + operator<(const tuple<_TElements...>& __t, + const tuple<_UElements...>& __u) + { + typedef tuple<_TElements...> _Tp; + typedef tuple<_UElements...> _Up; + return (__tuple_compare<tuple_size<_Tp>::value - tuple_size<_Up>::value, + 0, tuple_size<_Tp>::value, _Tp, _Up>::__less(__t, __u)); + } + + template<typename... _TElements, typename... _UElements> + inline bool + operator!=(const tuple<_TElements...>& __t, + const tuple<_UElements...>& __u) + { return !(__t == __u); } + + template<typename... _TElements, typename... _UElements> + inline bool + operator>(const tuple<_TElements...>& __t, + const tuple<_UElements...>& __u) + { return __u < __t; } + + template<typename... _TElements, typename... _UElements> + inline bool + operator<=(const tuple<_TElements...>& __t, + const tuple<_UElements...>& __u) + { return !(__u < __t); } + + template<typename... _TElements, typename... _UElements> + inline bool + operator>=(const tuple<_TElements...>& __t, + const tuple<_UElements...>& __u) + { return !(__t < __u); } + + // NB: DR 705. + template<typename... _Elements> + inline tuple<typename __decay_and_strip<_Elements>::__type...> + make_tuple(_Elements&&... __args) + { + typedef tuple<typename __decay_and_strip<_Elements>::__type...> + __result_type; + return __result_type(std::forward<_Elements>(__args)...); + } + + template<std::size_t...> struct __index_holder { }; + + template<std::size_t __i, typename _IdxHolder, typename... _Elements> + struct __index_holder_impl; + + template<std::size_t __i, std::size_t... _Indexes, typename _IdxHolder, + typename... _Elements> + struct __index_holder_impl<__i, __index_holder<_Indexes...>, + _IdxHolder, _Elements...> + { + typedef typename __index_holder_impl<__i + 1, + __index_holder<_Indexes..., __i>, + _Elements...>::type type; + }; + + template<std::size_t __i, std::size_t... _Indexes> + struct __index_holder_impl<__i, __index_holder<_Indexes...> > + { typedef __index_holder<_Indexes...> type; }; + + template<typename... _Elements> + struct __make_index_holder + : __index_holder_impl<0, __index_holder<>, _Elements...> { }; + + template<typename... _TElements, std::size_t... _TIdx, + typename... _UElements, std::size_t... _UIdx> + inline tuple<_TElements..., _UElements...> + __tuple_cat_helper(const tuple<_TElements...>& __t, + const __index_holder<_TIdx...>&, + const tuple<_UElements...>& __u, + const __index_holder<_UIdx...>&) + { return tuple<_TElements..., _UElements...>(get<_TIdx>(__t)..., + get<_UIdx>(__u)...); } + + template<typename... _TElements, std::size_t... _TIdx, + typename... _UElements, std::size_t... _UIdx> + inline tuple<_TElements..., _UElements...> + __tuple_cat_helper(tuple<_TElements...>&& __t, + const __index_holder<_TIdx...>&, + const tuple<_UElements...>& __u, + const __index_holder<_UIdx...>&) + { return tuple<_TElements..., _UElements...> + (std::move(get<_TIdx>(__t))..., get<_UIdx>(__u)...); } + + template<typename... _TElements, std::size_t... _TIdx, + typename... _UElements, std::size_t... _UIdx> + inline tuple<_TElements..., _UElements...> + __tuple_cat_helper(const tuple<_TElements...>& __t, + const __index_holder<_TIdx...>&, + tuple<_UElements...>&& __u, + const __index_holder<_UIdx...>&) + { return tuple<_TElements..., _UElements...> + (get<_TIdx>(__t)..., std::move(get<_UIdx>(__u))...); } + + template<typename... _TElements, std::size_t... _TIdx, + typename... _UElements, std::size_t... _UIdx> + inline tuple<_TElements..., _UElements...> + __tuple_cat_helper(tuple<_TElements...>&& __t, + const __index_holder<_TIdx...>&, + tuple<_UElements...>&& __u, + const __index_holder<_UIdx...>&) + { return tuple<_TElements..., _UElements...> + (std::move(get<_TIdx>(__t))..., std::move(get<_UIdx>(__u))...); } + + template<typename... _TElements, typename... _UElements> + inline tuple<_TElements..., _UElements...> + tuple_cat(const tuple<_TElements...>& __t, const tuple<_UElements...>& __u) + { + return __tuple_cat_helper(__t, typename + __make_index_holder<_TElements...>::type(), + __u, typename + __make_index_holder<_UElements...>::type()); + } + + template<typename... _TElements, typename... _UElements> + inline tuple<_TElements..., _UElements...> + tuple_cat(tuple<_TElements...>&& __t, const tuple<_UElements...>& __u) + { + return __tuple_cat_helper(std::move(__t), typename + __make_index_holder<_TElements...>::type(), + __u, typename + __make_index_holder<_UElements...>::type()); + } + + template<typename... _TElements, typename... _UElements> + inline tuple<_TElements..., _UElements...> + tuple_cat(const tuple<_TElements...>& __t, tuple<_UElements...>&& __u) + { + return __tuple_cat_helper(__t, typename + __make_index_holder<_TElements...>::type(), + std::move(__u), typename + __make_index_holder<_UElements...>::type()); + } + + template<typename... _TElements, typename... _UElements> + inline tuple<_TElements..., _UElements...> + tuple_cat(tuple<_TElements...>&& __t, tuple<_UElements...>&& __u) + { + return __tuple_cat_helper(std::move(__t), typename + __make_index_holder<_TElements...>::type(), + std::move(__u), typename + __make_index_holder<_UElements...>::type()); + } + + template<typename... _Elements> + inline tuple<_Elements&...> + tie(_Elements&... __args) + { return tuple<_Elements&...>(__args...); } + + template<typename... _Elements> + inline void + swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y) + { __x.swap(__y); } + + template<typename... _Elements> + inline void + swap(tuple<_Elements...>&& __x, tuple<_Elements...>& __y) + { __x.swap(__y); } + + template<typename... _Elements> + inline void + swap(tuple<_Elements...>& __x, tuple<_Elements...>&& __y) + { __x.swap(__y); } + + // A class (and instance) which can be used in 'tie' when an element + // of a tuple is not required + struct _Swallow_assign + { + template<class _Tp> + _Swallow_assign& + operator=(const _Tp&) + { return *this; } + }; + + // TODO: Put this in some kind of shared file. + namespace + { + _Swallow_assign ignore; + }; // anonymous namespace +} + +#endif // __GXX_EXPERIMENTAL_CXX0X__ + +#endif // _GLIBCXX_TUPLE diff --git a/gcc-4.4.3/libstdc++-v3/include/std/type_traits b/gcc-4.4.3/libstdc++-v3/include/std/type_traits new file mode 100644 index 000000000..ce9ee1b06 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/type_traits @@ -0,0 +1,605 @@ +// C++0x type_traits -*- C++ -*- + +// Copyright (C) 2007, 2008, 2009 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file include/type_traits + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_TYPE_TRAITS +#define _GLIBCXX_TYPE_TRAITS 1 + +#pragma GCC system_header + +#ifndef __GXX_EXPERIMENTAL_CXX0X__ +# include <c++0x_warning.h> +#else + +#if defined(_GLIBCXX_INCLUDE_AS_TR1) +# error C++0x header cannot be included from TR1 header +#endif + +#include <cstddef> + +#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# include <tr1_impl/type_traits> +#else +# define _GLIBCXX_INCLUDE_AS_CXX0X +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 +# define _GLIBCXX_END_NAMESPACE_TR1 +# define _GLIBCXX_TR1 +# include <tr1_impl/type_traits> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_CXX0X +#endif + +namespace std +{ + /** @addtogroup metaprogramming + * @{ + */ + + // Primary classification traits. + + /// is_lvalue_reference + template<typename> + struct is_lvalue_reference + : public false_type { }; + + template<typename _Tp> + struct is_lvalue_reference<_Tp&> + : public true_type { }; + + /// is_rvalue_reference + template<typename> + struct is_rvalue_reference + : public false_type { }; + + template<typename _Tp> + struct is_rvalue_reference<_Tp&&> + : public true_type { }; + + // Secondary classification traits. + + /// is_reference + template<typename _Tp> + struct is_reference + : public integral_constant<bool, (is_lvalue_reference<_Tp>::value + || is_rvalue_reference<_Tp>::value)> + { }; + + // Reference transformations. + + /// remove_reference + template<typename _Tp> + struct remove_reference + { typedef _Tp type; }; + + template<typename _Tp> + struct remove_reference<_Tp&> + { typedef _Tp type; }; + + template<typename _Tp> + struct remove_reference<_Tp&&> + { typedef _Tp type; }; + + template<typename _Tp, + bool = !is_reference<_Tp>::value && !is_void<_Tp>::value, + bool = is_rvalue_reference<_Tp>::value> + struct __add_lvalue_reference_helper + { typedef _Tp type; }; + + template<typename _Tp> + struct __add_lvalue_reference_helper<_Tp, true, false> + { typedef _Tp& type; }; + + template<typename _Tp> + struct __add_lvalue_reference_helper<_Tp, false, true> + { typedef typename remove_reference<_Tp>::type& type; }; + + /// add_lvalue_reference + template<typename _Tp> + struct add_lvalue_reference + : public __add_lvalue_reference_helper<_Tp> + { }; + + template<typename _Tp, + bool = !is_reference<_Tp>::value && !is_void<_Tp>::value> + struct __add_rvalue_reference_helper + { typedef _Tp type; }; + + template<typename _Tp> + struct __add_rvalue_reference_helper<_Tp, true> + { typedef _Tp&& type; }; + + /// add_rvalue_reference + template<typename _Tp> + struct add_rvalue_reference + : public __add_rvalue_reference_helper<_Tp> + { }; + + // Scalar properties and transformations. + + template<typename _Tp, + bool = is_integral<_Tp>::value, + bool = is_floating_point<_Tp>::value> + struct __is_signed_helper + : public false_type { }; + + template<typename _Tp> + struct __is_signed_helper<_Tp, false, true> + : public true_type { }; + + template<typename _Tp> + struct __is_signed_helper<_Tp, true, false> + : public integral_constant<bool, _Tp(-1) < _Tp(0)> + { }; + + /// is_signed + template<typename _Tp> + struct is_signed + : public integral_constant<bool, __is_signed_helper<_Tp>::value> + { }; + + /// is_unsigned + template<typename _Tp> + struct is_unsigned + : public integral_constant<bool, (is_arithmetic<_Tp>::value + && !is_signed<_Tp>::value)> + { }; + + // Member introspection. + + /// is_pod + template<typename _Tp> + struct is_pod + : public integral_constant<bool, __is_pod(_Tp)> + { }; + + /// has_trivial_default_constructor + template<typename _Tp> + struct has_trivial_default_constructor + : public integral_constant<bool, __has_trivial_constructor(_Tp)> + { }; + + /// has_trivial_copy_constructor + template<typename _Tp> + struct has_trivial_copy_constructor + : public integral_constant<bool, __has_trivial_copy(_Tp)> + { }; + + /// has_trivial_assign + template<typename _Tp> + struct has_trivial_assign + : public integral_constant<bool, __has_trivial_assign(_Tp)> + { }; + + /// has_trivial_destructor + template<typename _Tp> + struct has_trivial_destructor + : public integral_constant<bool, __has_trivial_destructor(_Tp)> + { }; + + /// has_nothrow_default_constructor + template<typename _Tp> + struct has_nothrow_default_constructor + : public integral_constant<bool, __has_nothrow_constructor(_Tp)> + { }; + + /// has_nothrow_copy_constructor + template<typename _Tp> + struct has_nothrow_copy_constructor + : public integral_constant<bool, __has_nothrow_copy(_Tp)> + { }; + + /// has_nothrow_assign + template<typename _Tp> + struct has_nothrow_assign + : public integral_constant<bool, __has_nothrow_assign(_Tp)> + { }; + + /// is_base_of + template<typename _Base, typename _Derived> + struct is_base_of + : public integral_constant<bool, __is_base_of(_Base, _Derived)> + { }; + + // Relationships between types. + template<typename _From, typename _To> + struct __is_convertible_simple + : public __sfinae_types + { + private: + static __one __test(_To); + static __two __test(...); + static _From __makeFrom(); + + public: + static const bool __value = sizeof(__test(__makeFrom())) == 1; + }; + + template<typename _Tp> + struct __is_int_or_cref + { + typedef typename remove_reference<_Tp>::type __rr_Tp; + static const bool __value = (is_integral<_Tp>::value + || (is_integral<__rr_Tp>::value + && is_const<__rr_Tp>::value + && !is_volatile<__rr_Tp>::value)); + }; + + template<typename _From, typename _To, + bool = (is_void<_From>::value || is_void<_To>::value + || is_function<_To>::value || is_array<_To>::value + // This special case is here only to avoid warnings. + || (is_floating_point<typename + remove_reference<_From>::type>::value + && __is_int_or_cref<_To>::__value))> + struct __is_convertible_helper + { + // "An imaginary lvalue of type From...". + static const bool __value = (__is_convertible_simple<typename + add_lvalue_reference<_From>::type, + _To>::__value); + }; + + template<typename _From, typename _To> + struct __is_convertible_helper<_From, _To, true> + { static const bool __value = (is_void<_To>::value + || (__is_int_or_cref<_To>::__value + && !is_void<_From>::value)); }; + + // XXX FIXME + // The C++0x specifications are different, see N2255. + /// is_convertible + template<typename _From, typename _To> + struct is_convertible + : public integral_constant<bool, + __is_convertible_helper<_From, _To>::__value> + { }; + + template<std::size_t _Len> + struct __aligned_storage_msa + { + union __type + { + unsigned char __data[_Len]; + struct __attribute__((__aligned__)) { } __align; + }; + }; + + /** + * @brief Alignment type. + * + * The value of _Align is a default-alignment which shall be the + * most stringent alignment requirement for any C++ object type + * whose size is no greater than _Len (3.9). The member typedef + * type shall be a POD type suitable for use as uninitialized + * storage for any object whose size is at most _Len and whose + * alignment is a divisor of _Align. + */ + template<std::size_t _Len, std::size_t _Align = + __alignof__(typename __aligned_storage_msa<_Len>::__type)> + struct aligned_storage + { + union type + { + unsigned char __data[_Len]; + struct __attribute__((__aligned__((_Align)))) { } __align; + }; + }; + + + // Define a nested type if some predicate holds. + // Primary template. + /// enable_if + template<bool, typename _Tp = void> + struct enable_if + { }; + + // Partial specialization for true. + template<typename _Tp> + struct enable_if<true, _Tp> + { typedef _Tp type; }; + + + // A conditional expression, but for types. If true, first, if false, second. + // Primary template. + /// conditional + template<bool _Cond, typename _Iftrue, typename _Iffalse> + struct conditional + { typedef _Iftrue type; }; + + // Partial specialization for false. + template<typename _Iftrue, typename _Iffalse> + struct conditional<false, _Iftrue, _Iffalse> + { typedef _Iffalse type; }; + + + // Decay trait for arrays and functions, used for perfect forwarding + // in make_pair, make_tuple, etc. + template<typename _Up, + bool _IsArray = is_array<_Up>::value, + bool _IsFunction = is_function<_Up>::value> + struct __decay_selector; + + // NB: DR 705. + template<typename _Up> + struct __decay_selector<_Up, false, false> + { typedef typename remove_cv<_Up>::type __type; }; + + template<typename _Up> + struct __decay_selector<_Up, true, false> + { typedef typename remove_extent<_Up>::type* __type; }; + + template<typename _Up> + struct __decay_selector<_Up, false, true> + { typedef typename add_pointer<_Up>::type __type; }; + + /// decay + template<typename _Tp> + struct decay + { + private: + typedef typename remove_reference<_Tp>::type __remove_type; + + public: + typedef typename __decay_selector<__remove_type>::__type type; + }; + + + // Utility for constructing identically cv-qualified types. + template<typename _Unqualified, bool _IsConst, bool _IsVol> + struct __cv_selector; + + template<typename _Unqualified> + struct __cv_selector<_Unqualified, false, false> + { typedef _Unqualified __type; }; + + template<typename _Unqualified> + struct __cv_selector<_Unqualified, false, true> + { typedef volatile _Unqualified __type; }; + + template<typename _Unqualified> + struct __cv_selector<_Unqualified, true, false> + { typedef const _Unqualified __type; }; + + template<typename _Unqualified> + struct __cv_selector<_Unqualified, true, true> + { typedef const volatile _Unqualified __type; }; + + template<typename _Qualified, typename _Unqualified, + bool _IsConst = is_const<_Qualified>::value, + bool _IsVol = is_volatile<_Qualified>::value> + struct __match_cv_qualifiers + { + private: + typedef __cv_selector<_Unqualified, _IsConst, _IsVol> __match; + + public: + typedef typename __match::__type __type; + }; + + + // Utility for finding the unsigned versions of signed integral types. + template<typename _Tp> + struct __make_unsigned + { typedef _Tp __type; }; + + template<> + struct __make_unsigned<char> + { typedef unsigned char __type; }; + + template<> + struct __make_unsigned<signed char> + { typedef unsigned char __type; }; + + template<> + struct __make_unsigned<short> + { typedef unsigned short __type; }; + + template<> + struct __make_unsigned<int> + { typedef unsigned int __type; }; + + template<> + struct __make_unsigned<long> + { typedef unsigned long __type; }; + + template<> + struct __make_unsigned<long long> + { typedef unsigned long long __type; }; + + + // Select between integral and enum: not possible to be both. + template<typename _Tp, + bool _IsInt = is_integral<_Tp>::value, + bool _IsEnum = is_enum<_Tp>::value> + struct __make_unsigned_selector; + + template<typename _Tp> + struct __make_unsigned_selector<_Tp, true, false> + { + private: + typedef __make_unsigned<typename remove_cv<_Tp>::type> __unsignedt; + typedef typename __unsignedt::__type __unsigned_type; + typedef __match_cv_qualifiers<_Tp, __unsigned_type> __cv_unsigned; + + public: + typedef typename __cv_unsigned::__type __type; + }; + + template<typename _Tp> + struct __make_unsigned_selector<_Tp, false, true> + { + private: + // With -fshort-enums, an enum may be as small as a char. + typedef unsigned char __smallest; + static const bool __b0 = sizeof(_Tp) <= sizeof(__smallest); + static const bool __b1 = sizeof(_Tp) <= sizeof(unsigned short); + static const bool __b2 = sizeof(_Tp) <= sizeof(unsigned int); + typedef conditional<__b2, unsigned int, unsigned long> __cond2; + typedef typename __cond2::type __cond2_type; + typedef conditional<__b1, unsigned short, __cond2_type> __cond1; + typedef typename __cond1::type __cond1_type; + + public: + typedef typename conditional<__b0, __smallest, __cond1_type>::type __type; + }; + + // Given an integral/enum type, return the corresponding unsigned + // integer type. + // Primary template. + /// make_unsigned + template<typename _Tp> + struct make_unsigned + { typedef typename __make_unsigned_selector<_Tp>::__type type; }; + + // Integral, but don't define. + template<> + struct make_unsigned<bool>; + + + // Utility for finding the signed versions of unsigned integral types. + template<typename _Tp> + struct __make_signed + { typedef _Tp __type; }; + + template<> + struct __make_signed<char> + { typedef signed char __type; }; + + template<> + struct __make_signed<unsigned char> + { typedef signed char __type; }; + + template<> + struct __make_signed<unsigned short> + { typedef signed short __type; }; + + template<> + struct __make_signed<unsigned int> + { typedef signed int __type; }; + + template<> + struct __make_signed<unsigned long> + { typedef signed long __type; }; + + template<> + struct __make_signed<unsigned long long> + { typedef signed long long __type; }; + + + // Select between integral and enum: not possible to be both. + template<typename _Tp, + bool _IsInt = is_integral<_Tp>::value, + bool _IsEnum = is_enum<_Tp>::value> + struct __make_signed_selector; + + template<typename _Tp> + struct __make_signed_selector<_Tp, true, false> + { + private: + typedef __make_signed<typename remove_cv<_Tp>::type> __signedt; + typedef typename __signedt::__type __signed_type; + typedef __match_cv_qualifiers<_Tp, __signed_type> __cv_signed; + + public: + typedef typename __cv_signed::__type __type; + }; + + template<typename _Tp> + struct __make_signed_selector<_Tp, false, true> + { + private: + // With -fshort-enums, an enum may be as small as a char. + typedef signed char __smallest; + static const bool __b0 = sizeof(_Tp) <= sizeof(__smallest); + static const bool __b1 = sizeof(_Tp) <= sizeof(signed short); + static const bool __b2 = sizeof(_Tp) <= sizeof(signed int); + typedef conditional<__b2, signed int, signed long> __cond2; + typedef typename __cond2::type __cond2_type; + typedef conditional<__b1, signed short, __cond2_type> __cond1; + typedef typename __cond1::type __cond1_type; + + public: + typedef typename conditional<__b0, __smallest, __cond1_type>::type __type; + }; + + // Given an integral/enum type, return the corresponding signed + // integer type. + // Primary template. + /// make_signed + template<typename _Tp> + struct make_signed + { typedef typename __make_signed_selector<_Tp>::__type type; }; + + // Integral, but don't define. + template<> + struct make_signed<bool>; + + /// common_type + template<typename... _Tp> + struct common_type; + + template<typename _Tp> + struct common_type<_Tp> + { + static_assert(sizeof(_Tp) > 0, "must be complete type"); + typedef _Tp type; + }; + + template<typename _Tp, typename _Up> + class common_type<_Tp, _Up> + { + static_assert(sizeof(_Tp) > 0, "must be complete type"); + static_assert(sizeof(_Up) > 0, "must be complete type"); + + static _Tp&& __t(); + static _Up&& __u(); + + // HACK: Prevents optimization of ?: in the decltype + // expression when the condition is the literal, "true". + // See, PR36628. + static bool __true_or_false(); + + public: + typedef decltype(__true_or_false() ? __t() : __u()) type; + }; + + template<typename _Tp, typename _Up, typename... _Vp> + struct common_type<_Tp, _Up, _Vp...> + { + typedef typename + common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type; + }; + + // @} group metaprogramming +} + +#endif // __GXX_EXPERIMENTAL_CXX0X__ + +#endif // _GLIBCXX_TYPE_TRAITS + diff --git a/gcc-4.4.3/libstdc++-v3/include/std/unordered_map b/gcc-4.4.3/libstdc++-v3/include/std/unordered_map new file mode 100644 index 000000000..56906d28b --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/unordered_map @@ -0,0 +1,78 @@ +// <unordered_map> -*- C++ -*- + +// Copyright (C) 2007, 2008, 2009 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file include/unordered_map + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_UNORDERED_MAP +#define _GLIBCXX_UNORDERED_MAP 1 + +#pragma GCC system_header + +#ifndef __GXX_EXPERIMENTAL_CXX0X__ +# include <c++0x_warning.h> +#else + +#if defined(_GLIBCXX_INCLUDE_AS_TR1) +# error C++0x header cannot be included from TR1 header +#endif + +#include <utility> +#include <type_traits> +#include <initializer_list> +#include <bits/stl_algobase.h> +#include <bits/allocator.h> +#include <bits/stl_function.h> // equal_to, _Identity, _Select1st +#include <bits/stringfwd.h> +#include <bits/functional_hash.h> +#include <bits/hashtable.h> + +#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# include <tr1_impl/unordered_map> +#else +# define _GLIBCXX_INCLUDE_AS_CXX0X +#if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL) +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace _GLIBCXX_STD_D { +# define _GLIBCXX_END_NAMESPACE_TR1 } +# define _GLIBCXX_TR1 _GLIBCXX_STD_D +#else +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 +# define _GLIBCXX_END_NAMESPACE_TR1 +# define _GLIBCXX_TR1 +#endif +# include <tr1_impl/unordered_map> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_CXX0X +#endif + +#ifdef _GLIBCXX_DEBUG +# include <debug/unordered_map> +#endif + +#endif // __GXX_EXPERIMENTAL_CXX0X__ + +#endif // _GLIBCXX_UNORDERED_MAP diff --git a/gcc-4.4.3/libstdc++-v3/include/std/unordered_set b/gcc-4.4.3/libstdc++-v3/include/std/unordered_set new file mode 100644 index 000000000..880f3bef4 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/unordered_set @@ -0,0 +1,78 @@ +// <unordered_set> -*- C++ -*- + +// Copyright (C) 2007, 2008, 2009 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file include/unordered_set + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_UNORDERED_SET +#define _GLIBCXX_UNORDERED_SET 1 + +#pragma GCC system_header + +#ifndef __GXX_EXPERIMENTAL_CXX0X__ +# include <c++0x_warning.h> +#else + +#if defined(_GLIBCXX_INCLUDE_AS_TR1) +# error C++0x header cannot be included from TR1 header +#endif + +#include <utility> +#include <type_traits> +#include <initializer_list> +#include <bits/stl_algobase.h> +#include <bits/allocator.h> +#include <bits/stl_function.h> // equal_to, _Identity, _Select1st +#include <bits/stringfwd.h> +#include <bits/functional_hash.h> +#include <bits/hashtable.h> + +#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# include <tr1_impl/unordered_set> +#else +# define _GLIBCXX_INCLUDE_AS_CXX0X +#if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL) +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace _GLIBCXX_STD_D { +# define _GLIBCXX_END_NAMESPACE_TR1 } +# define _GLIBCXX_TR1 _GLIBCXX_STD_D +#else +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 +# define _GLIBCXX_END_NAMESPACE_TR1 +# define _GLIBCXX_TR1 +#endif +# include <tr1_impl/unordered_set> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_CXX0X +#endif + +#ifdef _GLIBCXX_DEBUG +# include <debug/unordered_set> +#endif + +#endif // __GXX_EXPERIMENTAL_CXX0X__ + +#endif // _GLIBCXX_UNORDERED_SET diff --git a/gcc-4.4.3/libstdc++-v3/include/std/utility b/gcc-4.4.3/libstdc++-v3/include/std/utility new file mode 100644 index 000000000..1a6d0b1b6 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/utility @@ -0,0 +1,94 @@ +// <utility> -*- C++ -*- + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 +// 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file include/utility + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_UTILITY +#define _GLIBCXX_UTILITY 1 + +#pragma GCC system_header + +#include <bits/c++config.h> +#include <bits/stl_relops.h> +#include <bits/stl_pair.h> + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +# if defined(_GLIBCXX_INCLUDE_AS_TR1) +# error C++0x header cannot be included from TR1 header +# endif +# if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# include <tr1_impl/utility> +# else +# define _GLIBCXX_INCLUDE_AS_CXX0X +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 +# define _GLIBCXX_END_NAMESPACE_TR1 +# define _GLIBCXX_TR1 +# include <tr1_impl/utility> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_CXX0X +# endif +# include <bits/move.h> +# include <initializer_list> +#endif + +/** + * @defgroup utilities Utilities + * + * Components deemed generally useful. Includes pair, tuple, + * forward/move helpers, ratio, function object, metaprogramming and + * type traits, time, date, and memory functions. + */ + +#endif /* _GLIBCXX_UTILITY */ diff --git a/gcc-4.4.3/libstdc++-v3/include/std/valarray b/gcc-4.4.3/libstdc++-v3/include/std/valarray new file mode 100644 index 000000000..43e8d205a --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/valarray @@ -0,0 +1,1087 @@ +// The template and inlines for the -*- C++ -*- valarray class. + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, +// 2006, 2007, 2008, 2009 +// 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file valarray + * 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 + +#pragma GCC system_header + +#include <bits/c++config.h> +#include <cstddef> +#include <cmath> +#include <algorithm> +#include <debug/debug.h> +#include <initializer_list> + +_GLIBCXX_BEGIN_NAMESPACE(std) + + template<class _Clos, typename _Tp> + class _Expr; + + template<typename _Tp1, typename _Tp2> + class _ValArray; + + template<class _Oper, template<class, class> class _Meta, class _Dom> + struct _UnClos; + + template<class _Oper, + template<class, class> class _Meta1, + template<class, class> class _Meta2, + class _Dom1, class _Dom2> + class _BinClos; + + template<template<class, class> class _Meta, class _Dom> + class _SClos; + + template<template<class, class> class _Meta, class _Dom> + class _GClos; + + template<template<class, class> class _Meta, class _Dom> + class _IClos; + + template<template<class, class> class _Meta, class _Dom> + class _ValFunClos; + + template<template<class, class> class _Meta, class _Dom> + class _RefFunClos; + + template<class _Tp> class valarray; // An array of type _Tp + class slice; // BLAS-like slice out of an array + template<class _Tp> class slice_array; + class gslice; // generalized slice out of an array + template<class _Tp> class gslice_array; + template<class _Tp> class mask_array; // masked array + template<class _Tp> class indirect_array; // indirected array + +_GLIBCXX_END_NAMESPACE + +#include <bits/valarray_array.h> +#include <bits/valarray_before.h> + +_GLIBCXX_BEGIN_NAMESPACE(std) + + /** + * @defgroup numeric_arrays Numeric Arrays + * @ingroup numerics + * + * Classes and functions for representing and manipulating arrays of elements. + * @{ + */ + + /** + * @brief Smart array designed to support numeric processing. + * + * A valarray is an array that provides constraints intended to allow for + * effective optimization of numeric array processing by reducing the + * aliasing that can result from pointer representations. It represents a + * one-dimensional array from which different multidimensional subsets can + * be accessed and modified. + * + * @param Tp Type of object in the array. + */ + template<class _Tp> + class valarray + { + template<class _Op> + struct _UnaryOp + { + typedef typename __fun<_Op, _Tp>::result_type __rt; + typedef _Expr<_UnClos<_Op, _ValArray, _Tp>, __rt> _Rt; + }; + public: + typedef _Tp value_type; + + // _lib.valarray.cons_ construct/destroy: + /// Construct an empty array. + valarray(); + + /// Construct an array with @a n elements. + explicit valarray(size_t); + + /// Construct an array with @a n elements initialized to @a t. + valarray(const _Tp&, size_t); + + /// Construct an array initialized to the first @a n elements of @a t. + valarray(const _Tp* __restrict__, size_t); + + /// Copy constructor. + valarray(const valarray&); + + /// Construct an array with the same size and values in @a sa. + valarray(const slice_array<_Tp>&); + + /// Construct an array with the same size and values in @a ga. + valarray(const gslice_array<_Tp>&); + + /// Construct an array with the same size and values in @a ma. + valarray(const mask_array<_Tp>&); + + /// Construct an array with the same size and values in @a ia. + valarray(const indirect_array<_Tp>&); + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /// Construct an array with an initializer_list of values. + valarray(initializer_list<_Tp>); +#endif + + template<class _Dom> + valarray(const _Expr<_Dom, _Tp>& __e); + + ~valarray(); + + // _lib.valarray.assign_ assignment: + /** + * @brief Assign elements to an array. + * + * Assign elements of array to values in @a v. Results are undefined + * if @a v does not have the same size as this array. + * + * @param v Valarray to get values from. + */ + valarray<_Tp>& operator=(const valarray<_Tp>&); + + /** + * @brief Assign elements to a value. + * + * Assign all elements of array to @a t. + * + * @param t Value for elements. + */ + valarray<_Tp>& operator=(const _Tp&); + + /** + * @brief Assign elements to an array subset. + * + * Assign elements of array to values in @a sa. Results are undefined + * if @a sa does not have the same size as this array. + * + * @param sa Array slice to get values from. + */ + valarray<_Tp>& operator=(const slice_array<_Tp>&); + + /** + * @brief Assign elements to an array subset. + * + * Assign elements of array to values in @a ga. Results are undefined + * if @a ga does not have the same size as this array. + * + * @param ga Array slice to get values from. + */ + valarray<_Tp>& operator=(const gslice_array<_Tp>&); + + /** + * @brief Assign elements to an array subset. + * + * Assign elements of array to values in @a ma. Results are undefined + * if @a ma does not have the same size as this array. + * + * @param ma Array slice to get values from. + */ + valarray<_Tp>& operator=(const mask_array<_Tp>&); + + /** + * @brief Assign elements to an array subset. + * + * Assign elements of array to values in @a ia. Results are undefined + * 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>&); + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** + * @brief Assign elements to an initializer_list. + * + * Assign elements of array to values in @a l. Results are undefined + * if @a l does not have the same size as this array. + * + * @param l initializer_list to get values from. + */ + valarray& operator=(initializer_list<_Tp>); +#endif + + template<class _Dom> valarray<_Tp>& + operator= (const _Expr<_Dom, _Tp>&); + + // _lib.valarray.access_ element access: + /** + * Return a reference to the i'th array element. + * + * @param i Index of element to return. + * @return Reference to the i'th element. + */ + _Tp& operator[](size_t); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 389. Const overload of valarray::operator[] returns by value. + const _Tp& operator[](size_t) const; + + // _lib.valarray.sub_ subset operations: + /** + * @brief Return an array subset. + * + * Returns a new valarray containing the elements of the array + * 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; + + /** + * @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 has the same size + * as the input slice. @see slice. + * + * @param s The source slice. + * @return New valarray containing elements in @a s. + */ + slice_array<_Tp> operator[](slice); + + /** + * @brief Return an array subset. + * + * Returns a slice_array referencing the elements of the array + * indicated by the slice argument. @see gslice. + * + * @param s The source slice. + * @return Slice_array referencing elements indicated by @a s. + */ + _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 has + * the same size as the input gslice. @see gslice. + * + * @param s The source gslice. + * @return New valarray containing elements in @a s. + */ + gslice_array<_Tp> operator[](const gslice&); + + /** + * @brief Return an array subset. + * + * Returns a new valarray containing the elements of the array + * indicated by the argument. The input is a valarray of bool which + * represents a bitmask indicating which elements should be copied into + * the new valarray. Each element of the array is added to the return + * valarray if the corresponding element of the argument is true. + * + * @param m The valarray bitmask. + * @return New valarray containing elements indicated by @a m. + */ + valarray<_Tp> operator[](const valarray<bool>&) const; + + /** + * @brief Return a reference to an array subset. + * + * Returns a new mask_array referencing the elements of the array + * indicated by the argument. The input is a valarray of bool which + * represents a bitmask indicating which elements are part of the + * subset. Elements of the array are part of the subset if the + * corresponding element of the argument is true. + * + * @param m The valarray bitmask. + * @return New valarray containing elements indicated by @a m. + */ + mask_array<_Tp> operator[](const valarray<bool>&); + + /** + * @brief Return an array subset. + * + * Returns a new valarray containing the elements of the array + * indicated by the argument. The elements in the argument are + * interpreted as the indices of elements of this valarray to copy to + * the return valarray. + * + * @param i The valarray element index list. + * @return New valarray containing elements in @a s. + */ + _Expr<_IClos<_ValArray, _Tp>, _Tp> + operator[](const valarray<size_t>&) const; + + /** + * @brief Return a reference to an array subset. + * + * Returns an indirect_array referencing the elements of the array + * indicated by the argument. The elements in the argument are + * interpreted as the indices of elements of this valarray to include + * in the subset. The returned indirect_array refers to these + * elements. + * + * @param i The valarray element index list. + * @return Indirect_array referencing elements in @a i. + */ + indirect_array<_Tp> operator[](const valarray<size_t>&); + + // _lib.valarray.unary_ unary operators: + /// Return a new valarray by applying unary + to each element. + typename _UnaryOp<__unary_plus>::_Rt operator+() const; + + /// Return a new valarray by applying unary - to each element. + typename _UnaryOp<__negate>::_Rt operator-() const; + + /// Return a new valarray by applying unary ~ to each element. + typename _UnaryOp<__bitwise_not>::_Rt operator~() const; + + /// Return a new valarray by applying unary ! to each element. + typename _UnaryOp<__logical_not>::_Rt operator!() const; + + // _lib.valarray.cassign_ computed assignment: + /// Multiply each element of array by @a t. + valarray<_Tp>& operator*=(const _Tp&); + + /// Divide each element of array by @a t. + valarray<_Tp>& operator/=(const _Tp&); + + /// Set each element e of array to e % @a t. + valarray<_Tp>& operator%=(const _Tp&); + + /// Add @a t to each element of array. + valarray<_Tp>& operator+=(const _Tp&); + + /// Subtract @a t to each element of array. + valarray<_Tp>& operator-=(const _Tp&); + + /// Set each element e of array to e ^ @a t. + valarray<_Tp>& operator^=(const _Tp&); + + /// Set each element e of array to e & @a t. + valarray<_Tp>& operator&=(const _Tp&); + + /// Set each element e of array to e | @a t. + valarray<_Tp>& operator|=(const _Tp&); + + /// Left shift each element e of array by @a t bits. + valarray<_Tp>& operator<<=(const _Tp&); + + /// Right shift each element e of array by @a t bits. + valarray<_Tp>& operator>>=(const _Tp&); + + /// Multiply elements of array by corresponding elements of @a v. + valarray<_Tp>& operator*=(const valarray<_Tp>&); + + /// Divide elements of array by corresponding elements of @a v. + valarray<_Tp>& operator/=(const valarray<_Tp>&); + + /// Modulo elements of array by corresponding elements of @a v. + valarray<_Tp>& operator%=(const valarray<_Tp>&); + + /// Add corresponding elements of @a v to elements of array. + valarray<_Tp>& operator+=(const valarray<_Tp>&); + + /// Subtract corresponding elements of @a v from elements of array. + valarray<_Tp>& operator-=(const valarray<_Tp>&); + + /// Logical xor corresponding elements of @a v with elements of array. + valarray<_Tp>& operator^=(const valarray<_Tp>&); + + /// Logical or corresponding elements of @a v with elements of array. + valarray<_Tp>& operator|=(const valarray<_Tp>&); + + /// Logical and corresponding elements of @a v with elements of array. + valarray<_Tp>& operator&=(const valarray<_Tp>&); + + /// Left shift elements of array by corresponding elements of @a v. + valarray<_Tp>& operator<<=(const valarray<_Tp>&); + + /// Right shift elements of array by corresponding elements of @a v. + valarray<_Tp>& operator>>=(const valarray<_Tp>&); + + template<class _Dom> + valarray<_Tp>& operator*=(const _Expr<_Dom, _Tp>&); + template<class _Dom> + valarray<_Tp>& operator/=(const _Expr<_Dom, _Tp>&); + template<class _Dom> + valarray<_Tp>& operator%=(const _Expr<_Dom, _Tp>&); + template<class _Dom> + valarray<_Tp>& operator+=(const _Expr<_Dom, _Tp>&); + template<class _Dom> + valarray<_Tp>& operator-=(const _Expr<_Dom, _Tp>&); + template<class _Dom> + valarray<_Tp>& operator^=(const _Expr<_Dom, _Tp>&); + template<class _Dom> + valarray<_Tp>& operator|=(const _Expr<_Dom, _Tp>&); + template<class _Dom> + valarray<_Tp>& operator&=(const _Expr<_Dom, _Tp>&); + template<class _Dom> + valarray<_Tp>& operator<<=(const _Expr<_Dom, _Tp>&); + template<class _Dom> + valarray<_Tp>& operator>>=(const _Expr<_Dom, _Tp>&); + + // _lib.valarray.members_ member functions: + /// Return the number of elements in array. + size_t size() const; + + /** + * @brief Return the sum of all elements in the array. + * + * Accumulates the sum of all elements into a Tp using +=. The order + * of adding the elements is unspecified. + */ + _Tp sum() const; + + /// Return the minimum element using operator<(). + _Tp min() const; + + /// Return the maximum element using operator<(). + _Tp max() 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 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). + * Negative arguments discard elements from the top of the array. + * + * @param n Number of element positions to shift. + * @return New valarray with elements in shifted positions. + */ + valarray<_Tp> shift (int) const; + + /** + * @brief Return a rotated 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) % 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. + * + * Positive arguments shift toward index 0, wrapping around the top. + * Negative arguments shift towards the top, wrapping around to 0. + * + * @param n Number of element positions to rotate. + * @return New valarray with elements in shifted positions. + */ + valarray<_Tp> cshift(int) 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 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; + + /** + * @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 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; + + /** + * @brief Resize array. + * + * Resize this array to @a size and set all elements to @a c. All + * references and iterators are invalidated. + * + * @param size New array size. + * @param c New value for all elements. + */ + void resize(size_t __size, _Tp __c = _Tp()); + + private: + size_t _M_size; + _Tp* __restrict__ _M_data; + + friend class _Array<_Tp>; + }; + + template<typename _Tp> + inline const _Tp& + valarray<_Tp>::operator[](size_t __i) const + { + __glibcxx_requires_subscript(__i); + return _M_data[__i]; + } + + template<typename _Tp> + inline _Tp& + valarray<_Tp>::operator[](size_t __i) + { + __glibcxx_requires_subscript(__i); + return _M_data[__i]; + } + + // @} group numeric_arrays + +_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> + +_GLIBCXX_BEGIN_NAMESPACE(std) + + /** + * @addtogroup numeric_arrays + * @{ + */ + + template<typename _Tp> + inline + valarray<_Tp>::valarray() : _M_size(0), _M_data(0) {} + + template<typename _Tp> + inline + valarray<_Tp>::valarray(size_t __n) + : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n)) + { 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)) + { 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)) + { + _GLIBCXX_DEBUG_ASSERT(__p != 0 || __n == 0); + std::__valarray_copy_construct(__p, __p + __n, _M_data); + } + + template<typename _Tp> + inline + valarray<_Tp>::valarray(const valarray<_Tp>& __v) + : _M_size(__v._M_size), _M_data(__valarray_get_storage<_Tp>(__v._M_size)) + { 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)) + { + 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)) + { + std::__valarray_copy_construct + (__ga._M_array, _Array<size_t>(__ga._M_index), + _Array<_Tp>(_M_data), _M_size); + } + + template<typename _Tp> + inline + valarray<_Tp>::valarray(const mask_array<_Tp>& __ma) + : _M_size(__ma._M_sz), _M_data(__valarray_get_storage<_Tp>(__ma._M_sz)) + { + 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)) + { + std::__valarray_copy_construct + (__ia._M_array, __ia._M_index, _Array<_Tp>(_M_data), _M_size); + } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template<typename _Tp> + inline + valarray<_Tp>::valarray(initializer_list<_Tp> __l) + : _M_size(__l.size()), _M_data(__valarray_get_storage<_Tp>(__l.size())) + { std::__valarray_copy_construct (__l.begin(), __l.end(), _M_data); } +#endif + + 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_construct(__e, _M_size, _Array<_Tp>(_M_data)); } + + template<typename _Tp> + inline + valarray<_Tp>::~valarray() + { + std::__valarray_destroy_elements(_M_data, _M_data + _M_size); + std::__valarray_release_memory(_M_data); + } + + template<typename _Tp> + inline valarray<_Tp>& + valarray<_Tp>::operator=(const valarray<_Tp>& __v) + { + _GLIBCXX_DEBUG_ASSERT(_M_size == __v._M_size); + std::__valarray_copy(__v._M_data, _M_size, _M_data); + return *this; + } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template<typename _Tp> + inline valarray<_Tp>& + valarray<_Tp>::operator=(initializer_list<_Tp> __l) + { + _GLIBCXX_DEBUG_ASSERT(_M_size == __l.size()); + std::__valarray_copy(__l.begin(), __l.size(), _M_data); + return *this; + } +#endif + + template<typename _Tp> + inline valarray<_Tp>& + valarray<_Tp>::operator=(const _Tp& __t) + { + std::__valarray_fill(_M_data, _M_size, __t); + return *this; + } + + template<typename _Tp> + inline valarray<_Tp>& + valarray<_Tp>::operator=(const slice_array<_Tp>& __sa) + { + _GLIBCXX_DEBUG_ASSERT(_M_size == __sa._M_sz); + std::__valarray_copy(__sa._M_array, __sa._M_sz, + __sa._M_stride, _Array<_Tp>(_M_data)); + return *this; + } + + template<typename _Tp> + inline valarray<_Tp>& + valarray<_Tp>::operator=(const gslice_array<_Tp>& __ga) + { + _GLIBCXX_DEBUG_ASSERT(_M_size == __ga._M_index.size()); + std::__valarray_copy(__ga._M_array, _Array<size_t>(__ga._M_index), + _Array<_Tp>(_M_data), _M_size); + return *this; + } + + template<typename _Tp> + inline valarray<_Tp>& + valarray<_Tp>::operator=(const mask_array<_Tp>& __ma) + { + _GLIBCXX_DEBUG_ASSERT(_M_size == __ma._M_sz); + std::__valarray_copy(__ma._M_array, __ma._M_mask, + _Array<_Tp>(_M_data), _M_size); + return *this; + } + + template<typename _Tp> + inline valarray<_Tp>& + valarray<_Tp>::operator=(const indirect_array<_Tp>& __ia) + { + _GLIBCXX_DEBUG_ASSERT(_M_size == __ia._M_sz); + std::__valarray_copy(__ia._M_array, __ia._M_index, + _Array<_Tp>(_M_data), _M_size); + return *this; + } + + template<typename _Tp> template<class _Dom> + inline valarray<_Tp>& + valarray<_Tp>::operator=(const _Expr<_Dom, _Tp>& __e) + { + _GLIBCXX_DEBUG_ASSERT(_M_size == __e.size()); + std::__valarray_copy(__e, _M_size, _Array<_Tp>(_M_data)); + return *this; + } + + template<typename _Tp> + inline _Expr<_SClos<_ValArray,_Tp>, _Tp> + valarray<_Tp>::operator[](slice __s) const + { + typedef _SClos<_ValArray,_Tp> _Closure; + return _Expr<_Closure, _Tp>(_Closure (_Array<_Tp>(_M_data), __s)); + } + + template<typename _Tp> + inline slice_array<_Tp> + valarray<_Tp>::operator[](slice __s) + { return slice_array<_Tp>(_Array<_Tp>(_M_data), __s); } + + template<typename _Tp> + inline _Expr<_GClos<_ValArray,_Tp>, _Tp> + valarray<_Tp>::operator[](const gslice& __gs) const + { + typedef _GClos<_ValArray,_Tp> _Closure; + return _Expr<_Closure, _Tp> + (_Closure(_Array<_Tp>(_M_data), __gs._M_index->_M_index)); + } + + template<typename _Tp> + inline gslice_array<_Tp> + valarray<_Tp>::operator[](const gslice& __gs) + { + return gslice_array<_Tp> + (_Array<_Tp>(_M_data), __gs._M_index->_M_index); + } + + template<typename _Tp> + inline valarray<_Tp> + valarray<_Tp>::operator[](const valarray<bool>& __m) const + { + size_t __s = 0; + size_t __e = __m.size(); + for (size_t __i=0; __i<__e; ++__i) + if (__m[__i]) ++__s; + return valarray<_Tp>(mask_array<_Tp>(_Array<_Tp>(_M_data), __s, + _Array<bool> (__m))); + } + + template<typename _Tp> + inline mask_array<_Tp> + valarray<_Tp>::operator[](const valarray<bool>& __m) + { + size_t __s = 0; + size_t __e = __m.size(); + for (size_t __i=0; __i<__e; ++__i) + if (__m[__i]) ++__s; + return mask_array<_Tp>(_Array<_Tp>(_M_data), __s, _Array<bool>(__m)); + } + + template<typename _Tp> + inline _Expr<_IClos<_ValArray,_Tp>, _Tp> + valarray<_Tp>::operator[](const valarray<size_t>& __i) const + { + typedef _IClos<_ValArray,_Tp> _Closure; + return _Expr<_Closure, _Tp>(_Closure(*this, __i)); + } + + template<typename _Tp> + inline indirect_array<_Tp> + valarray<_Tp>::operator[](const valarray<size_t>& __i) + { + return indirect_array<_Tp>(_Array<_Tp>(_M_data), __i.size(), + _Array<size_t>(__i)); + } + + template<class _Tp> + inline size_t + valarray<_Tp>::size() const + { return _M_size; } + + template<class _Tp> + inline _Tp + valarray<_Tp>::sum() const + { + _GLIBCXX_DEBUG_ASSERT(_M_size > 0); + return std::__valarray_sum(_M_data, _M_data + _M_size); + } + + template<class _Tp> + inline valarray<_Tp> + valarray<_Tp>::shift(int __n) const + { + 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 = int(_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 = -int(_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> + inline valarray<_Tp> + valarray<_Tp>::cshift(int __n) const + { + 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 = int(__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 = -int(-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> + inline void + valarray<_Tp>::resize(size_t __n, _Tp __c) + { + // This complication is so to make valarray<valarray<T> > work + // even though it is not required by the standard. Nobody should + // be saying valarray<valarray<T> > anyway. See the specs. + std::__valarray_destroy_elements(_M_data, _M_data + _M_size); + if (_M_size != __n) + { + std::__valarray_release_memory(_M_data); + _M_size = __n; + _M_data = __valarray_get_storage<_Tp>(__n); + } + std::__valarray_fill_construct(_M_data, _M_data + __n, __c); + } + + template<typename _Tp> + inline _Tp + valarray<_Tp>::min() const + { + _GLIBCXX_DEBUG_ASSERT(_M_size > 0); + return *std::min_element(_M_data, _M_data + _M_size); + } + + template<typename _Tp> + inline _Tp + valarray<_Tp>::max() const + { + _GLIBCXX_DEBUG_ASSERT(_M_size > 0); + return *std::max_element(_M_data, _M_data + _M_size); + } + + template<class _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)); + } + + template<class _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)); + } + +#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)); \ + } + + _DEFINE_VALARRAY_UNARY_OPERATOR(+, __unary_plus) + _DEFINE_VALARRAY_UNARY_OPERATOR(-, __negate) + _DEFINE_VALARRAY_UNARY_OPERATOR(~, __bitwise_not) + _DEFINE_VALARRAY_UNARY_OPERATOR (!, __logical_not) + +#undef _DEFINE_VALARRAY_UNARY_OPERATOR + +#define _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(_Op, _Name) \ + template<class _Tp> \ + inline valarray<_Tp>& \ + valarray<_Tp>::operator _Op##=(const _Tp &__t) \ + { \ + _Array_augmented_##_Name(_Array<_Tp>(_M_data), _M_size, __t); \ + return *this; \ + } \ + \ + template<class _Tp> \ + inline valarray<_Tp>& \ + valarray<_Tp>::operator _Op##=(const valarray<_Tp> &__v) \ + { \ + _GLIBCXX_DEBUG_ASSERT(_M_size == __v._M_size); \ + _Array_augmented_##_Name(_Array<_Tp>(_M_data), _M_size, \ + _Array<_Tp>(__v._M_data)); \ + return *this; \ + } + +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(+, __plus) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(-, __minus) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(*, __multiplies) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(/, __divides) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(%, __modulus) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(^, __bitwise_xor) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(&, __bitwise_and) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(|, __bitwise_or) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(<<, __shift_left) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(>>, __shift_right) + +#undef _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT + +#define _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(_Op, _Name) \ + template<class _Tp> template<class _Dom> \ + inline valarray<_Tp>& \ + valarray<_Tp>::operator _Op##=(const _Expr<_Dom, _Tp>& __e) \ + { \ + _Array_augmented_##_Name(_Array<_Tp>(_M_data), __e, _M_size); \ + return *this; \ + } + +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(+, __plus) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(-, __minus) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(*, __multiplies) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(/, __divides) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(%, __modulus) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(^, __bitwise_xor) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(&, __bitwise_and) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(|, __bitwise_or) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(<<, __shift_left) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(>>, __shift_right) + +#undef _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT + + +#define _DEFINE_BINARY_OPERATOR(_Op, _Name) \ + template<typename _Tp> \ + inline _Expr<_BinClos<_Name, _ValArray, _ValArray, _Tp, _Tp>, \ + 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 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)); \ + } \ + \ + 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, _Rt>(_Closure(__t, __v)); \ + } + +_DEFINE_BINARY_OPERATOR(+, __plus) +_DEFINE_BINARY_OPERATOR(-, __minus) +_DEFINE_BINARY_OPERATOR(*, __multiplies) +_DEFINE_BINARY_OPERATOR(/, __divides) +_DEFINE_BINARY_OPERATOR(%, __modulus) +_DEFINE_BINARY_OPERATOR(^, __bitwise_xor) +_DEFINE_BINARY_OPERATOR(&, __bitwise_and) +_DEFINE_BINARY_OPERATOR(|, __bitwise_or) +_DEFINE_BINARY_OPERATOR(<<, __shift_left) +_DEFINE_BINARY_OPERATOR(>>, __shift_right) +_DEFINE_BINARY_OPERATOR(&&, __logical_and) +_DEFINE_BINARY_OPERATOR(||, __logical_or) +_DEFINE_BINARY_OPERATOR(==, __equal_to) +_DEFINE_BINARY_OPERATOR(!=, __not_equal_to) +_DEFINE_BINARY_OPERATOR(<, __less) +_DEFINE_BINARY_OPERATOR(>, __greater) +_DEFINE_BINARY_OPERATOR(<=, __less_equal) +_DEFINE_BINARY_OPERATOR(>=, __greater_equal) + +#undef _DEFINE_BINARY_OPERATOR + + // @} group numeric_arrays + +_GLIBCXX_END_NAMESPACE + +#endif /* _GLIBCXX_VALARRAY */ diff --git a/gcc-4.4.3/libstdc++-v3/include/std/vector b/gcc-4.4.3/libstdc++-v3/include/std/vector new file mode 100644 index 000000000..114665b6c --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/std/vector @@ -0,0 +1,77 @@ +// <vector> -*- C++ -*- + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 +// 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file include/vector + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_VECTOR +#define _GLIBCXX_VECTOR 1 + +#pragma GCC system_header + +#include <bits/stl_algobase.h> +#include <bits/allocator.h> +#include <bits/stl_construct.h> +#include <bits/stl_uninitialized.h> +#include <bits/stl_vector.h> +#include <bits/stl_bvector.h> + +#ifndef _GLIBCXX_EXPORT_TEMPLATE +# include <bits/vector.tcc> +#endif + +#ifdef _GLIBCXX_DEBUG +# include <debug/vector> +#endif + +#endif /* _GLIBCXX_VECTOR */ + |