OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc/trunk/gnu-stable/gcc-4.5.1/libstdc++-v3/include/tr1_impl
    from Rev 816 to Rev 826
    Reverse comparison

Rev 816 → Rev 826

/cfenv
0,0 → 1,70
// TR1 cfenv -*- 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 tr1_impl/cfenv
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
 
#if _GLIBCXX_USE_C99_FENV_TR1
 
#undef feclearexcept
#undef fegetexceptflag
#undef feraiseexcept
#undef fesetexceptflag
#undef fetestexcept
#undef fegetround
#undef fesetround
#undef fegetenv
#undef feholdexcept
#undef fesetenv
#undef feupdateenv
 
namespace std
{
_GLIBCXX_BEGIN_NAMESPACE_TR1
 
// types
using ::fenv_t;
using ::fexcept_t;
 
// functions
using ::feclearexcept;
using ::fegetexceptflag;
using ::feraiseexcept;
using ::fesetexceptflag;
using ::fetestexcept;
 
using ::fegetround;
using ::fesetround;
 
using ::fegetenv;
using ::feholdexcept;
using ::fesetenv;
using ::feupdateenv;
_GLIBCXX_END_NAMESPACE_TR1
}
 
#endif
/cinttypes
0,0 → 1,64
// TR1 cinttypes -*- 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 tr1_impl/cinttypes
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
 
#if _GLIBCXX_USE_C99_INTTYPES_TR1
 
namespace std
{
_GLIBCXX_BEGIN_NAMESPACE_TR1
 
// types
using ::imaxdiv_t;
 
// functions
using ::imaxabs;
 
// May collide with _Longlong abs(_Longlong), and is not described
// anywhere outside the synopsis. Likely, a defect.
//
// intmax_t abs(intmax_t)
 
using ::imaxdiv;
 
// Likewise, with lldiv_t div(_Longlong, _Longlong).
//
// imaxdiv_t div(intmax_t, intmax_t)
 
using ::strtoimax;
using ::strtoumax;
 
#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1
using ::wcstoimax;
using ::wcstoumax;
#endif
 
_GLIBCXX_END_NAMESPACE_TR1
}
 
#endif
/utility
0,0 → 1,120
// TR1 utility -*- 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 tr1_impl/utility
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
 
namespace std
{
_GLIBCXX_BEGIN_NAMESPACE_TR1
 
template<class _Tp>
class tuple_size;
 
#ifdef _GLIBCXX_INCLUDE_AS_CXX0X
template<std::size_t _Int, class _Tp>
#else
template<int _Int, class _Tp>
#endif
class tuple_element;
 
// Various functions which give std::pair a tuple-like interface.
template<class _Tp1, class _Tp2>
struct tuple_size<std::pair<_Tp1, _Tp2> >
#ifdef _GLIBCXX_INCLUDE_AS_CXX0X
{ static const std::size_t value = 2; };
#else
{ static const int value = 2; };
#endif
 
template<class _Tp1, class _Tp2>
#ifdef _GLIBCXX_INCLUDE_AS_CXX0X
const std::size_t
#else
const int
#endif
tuple_size<std::pair<_Tp1, _Tp2> >::value;
 
template<class _Tp1, class _Tp2>
struct tuple_element<0, std::pair<_Tp1, _Tp2> >
{ typedef _Tp1 type; };
template<class _Tp1, class _Tp2>
struct tuple_element<1, std::pair<_Tp1, _Tp2> >
{ typedef _Tp2 type; };
 
#ifdef _GLIBCXX_INCLUDE_AS_CXX0X
template<std::size_t _Int>
#else
template<int _Int>
#endif
struct __pair_get;
 
template<>
struct __pair_get<0>
{
template<typename _Tp1, typename _Tp2>
static _Tp1& __get(std::pair<_Tp1, _Tp2>& __pair)
{ return __pair.first; }
 
template<typename _Tp1, typename _Tp2>
static const _Tp1& __const_get(const std::pair<_Tp1, _Tp2>& __pair)
{ return __pair.first; }
};
 
template<>
struct __pair_get<1>
{
template<typename _Tp1, typename _Tp2>
static _Tp2& __get(std::pair<_Tp1, _Tp2>& __pair)
{ return __pair.second; }
 
template<typename _Tp1, typename _Tp2>
static const _Tp2& __const_get(const std::pair<_Tp1, _Tp2>& __pair)
{ return __pair.second; }
};
 
#ifdef _GLIBCXX_INCLUDE_AS_CXX0X
template<std::size_t _Int, class _Tp1, class _Tp2>
#else
template<int _Int, class _Tp1, class _Tp2>
#endif
inline typename tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&
get(std::pair<_Tp1, _Tp2>& __in)
{ return __pair_get<_Int>::__get(__in); }
 
#ifdef _GLIBCXX_INCLUDE_AS_CXX0X
template<std::size_t _Int, class _Tp1, class _Tp2>
#else
template<int _Int, class _Tp1, class _Tp2>
#endif
inline const typename tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&
get(const std::pair<_Tp1, _Tp2>& __in)
{ return __pair_get<_Int>::__const_get(__in); }
 
_GLIBCXX_END_NAMESPACE_TR1
}
 
/cstdlib
0,0 → 1,65
// TR1 cstdlib -*- C++ -*-
 
// 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 tr1_impl/cstdlib
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
 
#if _GLIBCXX_HOSTED
 
namespace std
{
_GLIBCXX_BEGIN_NAMESPACE_TR1
 
#if _GLIBCXX_USE_C99
 
#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
// types
using std::lldiv_t;
 
// functions
using std::llabs;
using std::lldiv;
#endif
 
using std::atoll;
using std::strtoll;
using std::strtoull;
 
using std::strtof;
using std::strtold;
 
// overloads
using std::abs;
#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
using std::div;
#endif
 
#endif
 
_GLIBCXX_END_NAMESPACE_TR1
}
 
#endif
/cstdio
0,0 → 1,44
// TR1 cstdio -*- C++ -*-
 
// 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 tr1_impl/cstdio
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
 
namespace std
{
_GLIBCXX_BEGIN_NAMESPACE_TR1
 
#if _GLIBCXX_USE_C99
using std::snprintf;
using std::vsnprintf;
 
using std::vfscanf;
using std::vscanf;
using std::vsscanf;
#endif
 
_GLIBCXX_END_NAMESPACE_TR1
}
/cctype
0,0 → 1,43
// TR1 cctype -*- C++ -*-
 
// 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 tr1_impl/cctype
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
 
#if _GLIBCXX_USE_C99_CTYPE_TR1
 
#undef isblank
 
namespace std
{
_GLIBCXX_BEGIN_NAMESPACE_TR1
 
using ::isblank;
 
_GLIBCXX_END_NAMESPACE_TR1
}
 
#endif
/complex
0,0 → 1,370
// TR1 complex -*- C++ -*-
 
// Copyright (C) 2007, 2008, 2009, 2010 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 tr1_impl/complex
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
 
namespace std
{
_GLIBCXX_BEGIN_NAMESPACE_TR1
 
/**
* @addtogroup complex_numbers
* @{
*/
 
// Forward declarations.
template<typename _Tp> std::complex<_Tp> acos(const std::complex<_Tp>&);
template<typename _Tp> std::complex<_Tp> asin(const std::complex<_Tp>&);
template<typename _Tp> std::complex<_Tp> atan(const std::complex<_Tp>&);
 
template<typename _Tp> std::complex<_Tp> acosh(const std::complex<_Tp>&);
template<typename _Tp> std::complex<_Tp> asinh(const std::complex<_Tp>&);
template<typename _Tp> std::complex<_Tp> atanh(const std::complex<_Tp>&);
#ifdef _GLIBCXX_INCLUDE_AS_CXX0X
// DR 595.
template<typename _Tp> _Tp fabs(const std::complex<_Tp>&);
#else
template<typename _Tp> std::complex<_Tp> fabs(const std::complex<_Tp>&);
#endif
 
template<typename _Tp>
inline std::complex<_Tp>
__complex_acos(const std::complex<_Tp>& __z)
{
const std::complex<_Tp> __t = std::_GLIBCXX_TR1 asin(__z);
const _Tp __pi_2 = 1.5707963267948966192313216916397514L;
return std::complex<_Tp>(__pi_2 - __t.real(), -__t.imag());
}
 
#if _GLIBCXX_USE_C99_COMPLEX_TR1
inline __complex__ float
__complex_acos(__complex__ float __z)
{ return __builtin_cacosf(__z); }
 
inline __complex__ double
__complex_acos(__complex__ double __z)
{ return __builtin_cacos(__z); }
 
inline __complex__ long double
__complex_acos(const __complex__ long double& __z)
{ return __builtin_cacosl(__z); }
 
template<typename _Tp>
inline std::complex<_Tp>
acos(const std::complex<_Tp>& __z)
{ return __complex_acos(__z.__rep()); }
#else
/// acos(__z) [8.1.2].
// Effects: Behaves the same as C99 function cacos, defined
// in subclause 7.3.5.1.
template<typename _Tp>
inline std::complex<_Tp>
acos(const std::complex<_Tp>& __z)
{ return __complex_acos(__z); }
#endif
 
template<typename _Tp>
inline std::complex<_Tp>
__complex_asin(const std::complex<_Tp>& __z)
{
std::complex<_Tp> __t(-__z.imag(), __z.real());
__t = std::_GLIBCXX_TR1 asinh(__t);
return std::complex<_Tp>(__t.imag(), -__t.real());
}
 
#if _GLIBCXX_USE_C99_COMPLEX_TR1
inline __complex__ float
__complex_asin(__complex__ float __z)
{ return __builtin_casinf(__z); }
 
inline __complex__ double
__complex_asin(__complex__ double __z)
{ return __builtin_casin(__z); }
 
inline __complex__ long double
__complex_asin(const __complex__ long double& __z)
{ return __builtin_casinl(__z); }
 
template<typename _Tp>
inline std::complex<_Tp>
asin(const std::complex<_Tp>& __z)
{ return __complex_asin(__z.__rep()); }
#else
/// asin(__z) [8.1.3].
// Effects: Behaves the same as C99 function casin, defined
// in subclause 7.3.5.2.
template<typename _Tp>
inline std::complex<_Tp>
asin(const std::complex<_Tp>& __z)
{ return __complex_asin(__z); }
#endif
template<typename _Tp>
std::complex<_Tp>
__complex_atan(const std::complex<_Tp>& __z)
{
const _Tp __r2 = __z.real() * __z.real();
const _Tp __x = _Tp(1.0) - __r2 - __z.imag() * __z.imag();
 
_Tp __num = __z.imag() + _Tp(1.0);
_Tp __den = __z.imag() - _Tp(1.0);
 
__num = __r2 + __num * __num;
__den = __r2 + __den * __den;
 
return std::complex<_Tp>(_Tp(0.5) * atan2(_Tp(2.0) * __z.real(), __x),
_Tp(0.25) * log(__num / __den));
}
 
#if _GLIBCXX_USE_C99_COMPLEX_TR1
inline __complex__ float
__complex_atan(__complex__ float __z)
{ return __builtin_catanf(__z); }
 
inline __complex__ double
__complex_atan(__complex__ double __z)
{ return __builtin_catan(__z); }
 
inline __complex__ long double
__complex_atan(const __complex__ long double& __z)
{ return __builtin_catanl(__z); }
 
template<typename _Tp>
inline std::complex<_Tp>
atan(const std::complex<_Tp>& __z)
{ return __complex_atan(__z.__rep()); }
#else
/// atan(__z) [8.1.4].
// Effects: Behaves the same as C99 function catan, defined
// in subclause 7.3.5.3.
template<typename _Tp>
inline std::complex<_Tp>
atan(const std::complex<_Tp>& __z)
{ return __complex_atan(__z); }
#endif
 
template<typename _Tp>
std::complex<_Tp>
__complex_acosh(const std::complex<_Tp>& __z)
{
std::complex<_Tp> __t((__z.real() - __z.imag())
* (__z.real() + __z.imag()) - _Tp(1.0),
_Tp(2.0) * __z.real() * __z.imag());
__t = std::sqrt(__t);
 
return std::log(__t + __z);
}
 
#if _GLIBCXX_USE_C99_COMPLEX_TR1
inline __complex__ float
__complex_acosh(__complex__ float __z)
{ return __builtin_cacoshf(__z); }
 
inline __complex__ double
__complex_acosh(__complex__ double __z)
{ return __builtin_cacosh(__z); }
 
inline __complex__ long double
__complex_acosh(const __complex__ long double& __z)
{ return __builtin_cacoshl(__z); }
 
template<typename _Tp>
inline std::complex<_Tp>
acosh(const std::complex<_Tp>& __z)
{ return __complex_acosh(__z.__rep()); }
#else
/// acosh(__z) [8.1.5].
// Effects: Behaves the same as C99 function cacosh, defined
// in subclause 7.3.6.1.
template<typename _Tp>
inline std::complex<_Tp>
acosh(const std::complex<_Tp>& __z)
{ return __complex_acosh(__z); }
#endif
 
template<typename _Tp>
std::complex<_Tp>
__complex_asinh(const std::complex<_Tp>& __z)
{
std::complex<_Tp> __t((__z.real() - __z.imag())
* (__z.real() + __z.imag()) + _Tp(1.0),
_Tp(2.0) * __z.real() * __z.imag());
__t = std::sqrt(__t);
 
return std::log(__t + __z);
}
 
#if _GLIBCXX_USE_C99_COMPLEX_TR1
inline __complex__ float
__complex_asinh(__complex__ float __z)
{ return __builtin_casinhf(__z); }
 
inline __complex__ double
__complex_asinh(__complex__ double __z)
{ return __builtin_casinh(__z); }
 
inline __complex__ long double
__complex_asinh(const __complex__ long double& __z)
{ return __builtin_casinhl(__z); }
 
template<typename _Tp>
inline std::complex<_Tp>
asinh(const std::complex<_Tp>& __z)
{ return __complex_asinh(__z.__rep()); }
#else
/// asinh(__z) [8.1.6].
// Effects: Behaves the same as C99 function casin, defined
// in subclause 7.3.6.2.
template<typename _Tp>
inline std::complex<_Tp>
asinh(const std::complex<_Tp>& __z)
{ return __complex_asinh(__z); }
#endif
 
template<typename _Tp>
std::complex<_Tp>
__complex_atanh(const std::complex<_Tp>& __z)
{
const _Tp __i2 = __z.imag() * __z.imag();
const _Tp __x = _Tp(1.0) - __i2 - __z.real() * __z.real();
 
_Tp __num = _Tp(1.0) + __z.real();
_Tp __den = _Tp(1.0) - __z.real();
 
__num = __i2 + __num * __num;
__den = __i2 + __den * __den;
 
return std::complex<_Tp>(_Tp(0.25) * (log(__num) - log(__den)),
_Tp(0.5) * atan2(_Tp(2.0) * __z.imag(), __x));
}
 
#if _GLIBCXX_USE_C99_COMPLEX_TR1
inline __complex__ float
__complex_atanh(__complex__ float __z)
{ return __builtin_catanhf(__z); }
 
inline __complex__ double
__complex_atanh(__complex__ double __z)
{ return __builtin_catanh(__z); }
 
inline __complex__ long double
__complex_atanh(const __complex__ long double& __z)
{ return __builtin_catanhl(__z); }
 
template<typename _Tp>
inline std::complex<_Tp>
atanh(const std::complex<_Tp>& __z)
{ return __complex_atanh(__z.__rep()); }
#else
/// atanh(__z) [8.1.7].
// Effects: Behaves the same as C99 function catanh, defined
// in subclause 7.3.6.3.
template<typename _Tp>
inline std::complex<_Tp>
atanh(const std::complex<_Tp>& __z)
{ return __complex_atanh(__z); }
#endif
 
template<typename _Tp>
#ifdef _GLIBCXX_INCLUDE_AS_CXX0X
inline _Tp
#else
inline std::complex<_Tp>
#endif
/// fabs(__z) [8.1.8].
// Effects: Behaves the same as C99 function cabs, defined
// in subclause 7.3.8.1.
fabs(const std::complex<_Tp>& __z)
{ return std::abs(__z); }
 
/// Additional overloads [8.1.9].
#if (defined(_GLIBCXX_INCLUDE_AS_CXX0X) \
|| (defined(_GLIBCXX_INCLUDE_AS_TR1) \
&& !defined(__GXX_EXPERIMENTAL_CXX0X__)))
 
template<typename _Tp>
inline typename __gnu_cxx::__promote<_Tp>::__type
arg(_Tp __x)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
#if (_GLIBCXX_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC)
return std::signbit(__x) ? __type(3.1415926535897932384626433832795029L)
: __type();
#else
return std::arg(std::complex<__type>(__x));
#endif
}
 
template<typename _Tp>
inline typename __gnu_cxx::__promote<_Tp>::__type
imag(_Tp)
{ return _Tp(); }
 
template<typename _Tp>
inline typename __gnu_cxx::__promote<_Tp>::__type
norm(_Tp __x)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
return __type(__x) * __type(__x);
}
 
template<typename _Tp>
inline typename __gnu_cxx::__promote<_Tp>::__type
real(_Tp __x)
{ return __x; }
 
#endif
 
template<typename _Tp, typename _Up>
inline std::complex<typename __gnu_cxx::__promote_2<_Tp, _Up>::__type>
pow(const std::complex<_Tp>& __x, const _Up& __y)
{
typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
return std::pow(std::complex<__type>(__x), __type(__y));
}
 
template<typename _Tp, typename _Up>
inline std::complex<typename __gnu_cxx::__promote_2<_Tp, _Up>::__type>
pow(const _Tp& __x, const std::complex<_Up>& __y)
{
typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
return std::pow(__type(__x), std::complex<__type>(__y));
}
 
template<typename _Tp, typename _Up>
inline std::complex<typename __gnu_cxx::__promote_2<_Tp, _Up>::__type>
pow(const std::complex<_Tp>& __x, const std::complex<_Up>& __y)
{
typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
return std::pow(std::complex<__type>(__x),
std::complex<__type>(__y));
}
 
// @} group complex_numbers
 
_GLIBCXX_END_NAMESPACE_TR1
}
/cwchar
0,0 → 1,58
// TR1 cwchar -*- C++ -*-
 
// 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 tr1_impl/cwchar
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
 
#if _GLIBCXX_USE_WCHAR_T
 
namespace std
{
_GLIBCXX_BEGIN_NAMESPACE_TR1
 
#if _GLIBCXX_HAVE_WCSTOF
using std::wcstof;
#endif
#if _GLIBCXX_HAVE_VFWSCANF
using std::vfwscanf;
#endif
#if _GLIBCXX_HAVE_VSWSCANF
using std::vswscanf;
#endif
#if _GLIBCXX_HAVE_VWSCANF
using std::vwscanf;
#endif
 
#if _GLIBCXX_USE_C99
using std::wcstold;
using std::wcstoll;
using std::wcstoull;
#endif
 
_GLIBCXX_END_NAMESPACE_TR1
}
 
#endif
/type_traits
0,0 → 1,502
// TR1 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 tr1_impl/type_traits
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
 
namespace std
{
_GLIBCXX_BEGIN_NAMESPACE_TR1
 
/**
* @defgroup metaprogramming Type Traits
* @ingroup utilities
*
* Compile time type transformation and information.
* @{
*/
 
// For use in __is_convertible_simple.
struct __sfinae_types
{
typedef char __one;
typedef struct { char __arr[2]; } __two;
};
 
#define _DEFINE_SPEC_0_HELPER \
template<>
 
#define _DEFINE_SPEC_1_HELPER \
template<typename _Tp>
 
#define _DEFINE_SPEC_2_HELPER \
template<typename _Tp, typename _Cp>
 
#define _DEFINE_SPEC(_Order, _Trait, _Type, _Value) \
_DEFINE_SPEC_##_Order##_HELPER \
struct _Trait<_Type> \
: public integral_constant<bool, _Value> { };
 
// helper classes [4.3].
 
/// integral_constant
template<typename _Tp, _Tp __v>
struct integral_constant
{
static const _Tp value = __v;
typedef _Tp value_type;
typedef integral_constant<_Tp, __v> type;
};
/// typedef for true_type
typedef integral_constant<bool, true> true_type;
 
/// typedef for false_type
typedef integral_constant<bool, false> false_type;
 
template<typename _Tp, _Tp __v>
const _Tp integral_constant<_Tp, __v>::value;
 
/// remove_cv
template<typename>
struct remove_cv;
 
template<typename>
struct __is_void_helper
: public false_type { };
_DEFINE_SPEC(0, __is_void_helper, void, true)
 
// primary type categories [4.5.1].
 
/// is_void
template<typename _Tp>
struct is_void
: public integral_constant<bool, (__is_void_helper<typename
remove_cv<_Tp>::type>::value)>
{ };
 
template<typename>
struct __is_integral_helper
: public false_type { };
_DEFINE_SPEC(0, __is_integral_helper, bool, true)
_DEFINE_SPEC(0, __is_integral_helper, char, true)
_DEFINE_SPEC(0, __is_integral_helper, signed char, true)
_DEFINE_SPEC(0, __is_integral_helper, unsigned char, true)
#ifdef _GLIBCXX_USE_WCHAR_T
_DEFINE_SPEC(0, __is_integral_helper, wchar_t, true)
#endif
#ifdef _GLIBCXX_INCLUDE_AS_CXX0X
_DEFINE_SPEC(0, __is_integral_helper, char16_t, true)
_DEFINE_SPEC(0, __is_integral_helper, char32_t, true)
#endif
_DEFINE_SPEC(0, __is_integral_helper, short, true)
_DEFINE_SPEC(0, __is_integral_helper, unsigned short, true)
_DEFINE_SPEC(0, __is_integral_helper, int, true)
_DEFINE_SPEC(0, __is_integral_helper, unsigned int, true)
_DEFINE_SPEC(0, __is_integral_helper, long, true)
_DEFINE_SPEC(0, __is_integral_helper, unsigned long, true)
_DEFINE_SPEC(0, __is_integral_helper, long long, true)
_DEFINE_SPEC(0, __is_integral_helper, unsigned long long, true)
 
/// is_integral
template<typename _Tp>
struct is_integral
: public integral_constant<bool, (__is_integral_helper<typename
remove_cv<_Tp>::type>::value)>
{ };
 
template<typename>
struct __is_floating_point_helper
: public false_type { };
_DEFINE_SPEC(0, __is_floating_point_helper, float, true)
_DEFINE_SPEC(0, __is_floating_point_helper, double, true)
_DEFINE_SPEC(0, __is_floating_point_helper, long double, true)
 
/// is_floating_point
template<typename _Tp>
struct is_floating_point
: public integral_constant<bool, (__is_floating_point_helper<typename
remove_cv<_Tp>::type>::value)>
{ };
 
/// is_array
template<typename>
struct is_array
: public false_type { };
 
template<typename _Tp, std::size_t _Size>
struct is_array<_Tp[_Size]>
: public true_type { };
 
template<typename _Tp>
struct is_array<_Tp[]>
: public true_type { };
 
template<typename>
struct __is_pointer_helper
: public false_type { };
_DEFINE_SPEC(1, __is_pointer_helper, _Tp*, true)
 
/// is_pointer
template<typename _Tp>
struct is_pointer
: public integral_constant<bool, (__is_pointer_helper<typename
remove_cv<_Tp>::type>::value)>
{ };
 
/// is_reference
template<typename _Tp>
struct is_reference;
 
/// is_function
template<typename _Tp>
struct is_function;
 
template<typename>
struct __is_member_object_pointer_helper
: public false_type { };
_DEFINE_SPEC(2, __is_member_object_pointer_helper, _Tp _Cp::*,
!is_function<_Tp>::value)
 
/// is_member_object_pointer
template<typename _Tp>
struct is_member_object_pointer
: public integral_constant<bool, (__is_member_object_pointer_helper<
typename remove_cv<_Tp>::type>::value)>
{ };
 
template<typename>
struct __is_member_function_pointer_helper
: public false_type { };
_DEFINE_SPEC(2, __is_member_function_pointer_helper, _Tp _Cp::*,
is_function<_Tp>::value)
 
/// is_member_function_pointer
template<typename _Tp>
struct is_member_function_pointer
: public integral_constant<bool, (__is_member_function_pointer_helper<
typename remove_cv<_Tp>::type>::value)>
{ };
 
/// is_enum
template<typename _Tp>
struct is_enum
: public integral_constant<bool, __is_enum(_Tp)>
{ };
 
/// is_union
template<typename _Tp>
struct is_union
: public integral_constant<bool, __is_union(_Tp)>
{ };
 
/// is_class
template<typename _Tp>
struct is_class
: public integral_constant<bool, __is_class(_Tp)>
{ };
 
/// is_function
template<typename>
struct is_function
: public false_type { };
template<typename _Res, typename... _ArgTypes>
struct is_function<_Res(_ArgTypes...)>
: public true_type { };
template<typename _Res, typename... _ArgTypes>
struct is_function<_Res(_ArgTypes......)>
: public true_type { };
template<typename _Res, typename... _ArgTypes>
struct is_function<_Res(_ArgTypes...) const>
: public true_type { };
template<typename _Res, typename... _ArgTypes>
struct is_function<_Res(_ArgTypes......) const>
: public true_type { };
template<typename _Res, typename... _ArgTypes>
struct is_function<_Res(_ArgTypes...) volatile>
: public true_type { };
template<typename _Res, typename... _ArgTypes>
struct is_function<_Res(_ArgTypes......) volatile>
: public true_type { };
template<typename _Res, typename... _ArgTypes>
struct is_function<_Res(_ArgTypes...) const volatile>
: public true_type { };
template<typename _Res, typename... _ArgTypes>
struct is_function<_Res(_ArgTypes......) const volatile>
: public true_type { };
 
// composite type traits [4.5.2].
/// is_arithmetic
template<typename _Tp>
struct is_arithmetic
: public integral_constant<bool, (is_integral<_Tp>::value
|| is_floating_point<_Tp>::value)>
{ };
 
/// is_fundamental
template<typename _Tp>
struct is_fundamental
: public integral_constant<bool, (is_arithmetic<_Tp>::value
|| is_void<_Tp>::value)>
{ };
 
/// is_object
template<typename _Tp>
struct is_object
: public integral_constant<bool, !(is_function<_Tp>::value
|| is_reference<_Tp>::value
|| is_void<_Tp>::value)>
{ };
 
/// is_member_pointer
template<typename _Tp>
struct is_member_pointer;
 
/// is_scalar
template<typename _Tp>
struct is_scalar
: public integral_constant<bool, (is_arithmetic<_Tp>::value
|| is_enum<_Tp>::value
|| is_pointer<_Tp>::value
|| is_member_pointer<_Tp>::value)>
{ };
 
/// is_compound
template<typename _Tp>
struct is_compound
: public integral_constant<bool, !is_fundamental<_Tp>::value> { };
 
/// is_member_pointer
template<typename _Tp>
struct __is_member_pointer_helper
: public false_type { };
_DEFINE_SPEC(2, __is_member_pointer_helper, _Tp _Cp::*, true)
 
template<typename _Tp>
struct is_member_pointer
: public integral_constant<bool, (__is_member_pointer_helper<
typename remove_cv<_Tp>::type>::value)>
{ };
 
// type properties [4.5.3].
/// is_const
template<typename>
struct is_const
: public false_type { };
 
template<typename _Tp>
struct is_const<_Tp const>
: public true_type { };
/// is_volatile
template<typename>
struct is_volatile
: public false_type { };
 
template<typename _Tp>
struct is_volatile<_Tp volatile>
: public true_type { };
 
/// is_empty
template<typename _Tp>
struct is_empty
: public integral_constant<bool, __is_empty(_Tp)>
{ };
 
/// is_polymorphic
template<typename _Tp>
struct is_polymorphic
: public integral_constant<bool, __is_polymorphic(_Tp)>
{ };
 
/// is_abstract
template<typename _Tp>
struct is_abstract
: public integral_constant<bool, __is_abstract(_Tp)>
{ };
 
/// has_virtual_destructor
template<typename _Tp>
struct has_virtual_destructor
: public integral_constant<bool, __has_virtual_destructor(_Tp)>
{ };
 
/// alignment_of
template<typename _Tp>
struct alignment_of
: public integral_constant<std::size_t, __alignof__(_Tp)> { };
/// rank
template<typename>
struct rank
: public integral_constant<std::size_t, 0> { };
template<typename _Tp, std::size_t _Size>
struct rank<_Tp[_Size]>
: public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
 
template<typename _Tp>
struct rank<_Tp[]>
: public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
 
/// extent
template<typename, unsigned _Uint = 0>
struct extent
: public integral_constant<std::size_t, 0> { };
template<typename _Tp, unsigned _Uint, std::size_t _Size>
struct extent<_Tp[_Size], _Uint>
: public integral_constant<std::size_t,
_Uint == 0 ? _Size : extent<_Tp,
_Uint - 1>::value>
{ };
 
template<typename _Tp, unsigned _Uint>
struct extent<_Tp[], _Uint>
: public integral_constant<std::size_t,
_Uint == 0 ? 0 : extent<_Tp,
_Uint - 1>::value>
{ };
 
// relationships between types [4.6].
 
/// is_same
template<typename, typename>
struct is_same
: public false_type { };
 
template<typename _Tp>
struct is_same<_Tp, _Tp>
: public true_type { };
 
// const-volatile modifications [4.7.1].
 
/// remove_const
template<typename _Tp>
struct remove_const
{ typedef _Tp type; };
 
template<typename _Tp>
struct remove_const<_Tp const>
{ typedef _Tp type; };
/// remove_volatile
template<typename _Tp>
struct remove_volatile
{ typedef _Tp type; };
 
template<typename _Tp>
struct remove_volatile<_Tp volatile>
{ typedef _Tp type; };
/// remove_cv
template<typename _Tp>
struct remove_cv
{
typedef typename
remove_const<typename remove_volatile<_Tp>::type>::type type;
};
/// add_const
template<typename _Tp>
struct add_const
{ typedef _Tp const type; };
/// add_volatile
template<typename _Tp>
struct add_volatile
{ typedef _Tp volatile type; };
/// add_cv
template<typename _Tp>
struct add_cv
{
typedef typename
add_const<typename add_volatile<_Tp>::type>::type type;
};
 
// array modifications [4.7.3].
 
/// remove_extent
template<typename _Tp>
struct remove_extent
{ typedef _Tp type; };
 
template<typename _Tp, std::size_t _Size>
struct remove_extent<_Tp[_Size]>
{ typedef _Tp type; };
 
template<typename _Tp>
struct remove_extent<_Tp[]>
{ typedef _Tp type; };
 
/// remove_all_extents
template<typename _Tp>
struct remove_all_extents
{ typedef _Tp type; };
 
template<typename _Tp, std::size_t _Size>
struct remove_all_extents<_Tp[_Size]>
{ typedef typename remove_all_extents<_Tp>::type type; };
 
template<typename _Tp>
struct remove_all_extents<_Tp[]>
{ typedef typename remove_all_extents<_Tp>::type type; };
 
// pointer modifications [4.7.4].
 
template<typename _Tp, typename>
struct __remove_pointer_helper
{ typedef _Tp type; };
 
template<typename _Tp, typename _Up>
struct __remove_pointer_helper<_Tp, _Up*>
{ typedef _Up type; };
 
/// remove_pointer
template<typename _Tp>
struct remove_pointer
: public __remove_pointer_helper<_Tp, typename remove_cv<_Tp>::type>
{ };
 
template<typename>
struct remove_reference;
 
/// add_pointer
template<typename _Tp>
struct add_pointer
{ typedef typename remove_reference<_Tp>::type* type; };
 
#undef _DEFINE_SPEC_0_HELPER
#undef _DEFINE_SPEC_1_HELPER
#undef _DEFINE_SPEC_2_HELPER
#undef _DEFINE_SPEC
 
// @} group metaprogramming
 
_GLIBCXX_END_NAMESPACE_TR1
}
/cstdint
0,0 → 1,75
// TR1 cstdint -*- 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 tr1_impl/cstdint
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
 
#if _GLIBCXX_USE_C99_STDINT_TR1
 
namespace std
{
_GLIBCXX_BEGIN_NAMESPACE_TR1
 
using ::int8_t;
using ::int16_t;
using ::int32_t;
using ::int64_t;
 
using ::int_fast8_t;
using ::int_fast16_t;
using ::int_fast32_t;
using ::int_fast64_t;
 
using ::int_least8_t;
using ::int_least16_t;
using ::int_least32_t;
using ::int_least64_t;
 
using ::intmax_t;
using ::intptr_t;
using ::uint8_t;
using ::uint16_t;
using ::uint32_t;
using ::uint64_t;
 
using ::uint_fast8_t;
using ::uint_fast16_t;
using ::uint_fast32_t;
using ::uint_fast64_t;
 
using ::uint_least8_t;
using ::uint_least16_t;
using ::uint_least32_t;
using ::uint_least64_t;
 
using ::uintmax_t;
using ::uintptr_t;
 
_GLIBCXX_END_NAMESPACE_TR1
}
 
#endif
/boost_sp_counted_base.h
0,0 → 1,243
// <tr1_impl/boost_sp_counted_base.h> -*- C++ -*-
 
// 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/>.
 
// shared_count.hpp
// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
 
// shared_ptr.hpp
// Copyright (C) 1998, 1999 Greg Colvin and Beman Dawes.
// Copyright (C) 2001, 2002, 2003 Peter Dimov
 
// weak_ptr.hpp
// Copyright (C) 2001, 2002, 2003 Peter Dimov
 
// enable_shared_from_this.hpp
// Copyright (C) 2002 Peter Dimov
 
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
 
// GCC Note: based on version 1.32.0 of the Boost library.
 
/** @file tr1_impl/boost_sp_counted_base.h
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
 
 
namespace std
{
_GLIBCXX_BEGIN_NAMESPACE_TR1
 
/**
* @brief Exception possibly thrown by @c shared_ptr.
* @ingroup exceptions
*/
class bad_weak_ptr : public std::exception
{
public:
virtual char const*
what() const throw()
#ifdef _GLIBCXX_INCLUDE_AS_CXX0X
{ return "std::bad_weak_ptr"; }
#else
{ return "tr1::bad_weak_ptr"; }
#endif
};
 
// Substitute for bad_weak_ptr object in the case of -fno-exceptions.
inline void
__throw_bad_weak_ptr()
{
#if __EXCEPTIONS
throw bad_weak_ptr();
#else
__builtin_abort();
#endif
}
 
using __gnu_cxx::_Lock_policy;
using __gnu_cxx::__default_lock_policy;
using __gnu_cxx::_S_single;
using __gnu_cxx::_S_mutex;
using __gnu_cxx::_S_atomic;
 
// Empty helper class except when the template argument is _S_mutex.
template<_Lock_policy _Lp>
class _Mutex_base
{
protected:
// The atomic policy uses fully-fenced builtins, single doesn't care.
enum { _S_need_barriers = 0 };
};
 
template<>
class _Mutex_base<_S_mutex>
: public __gnu_cxx::__mutex
{
protected:
// This policy is used when atomic builtins are not available.
// The replacement atomic operations might not have the necessary
// memory barriers.
enum { _S_need_barriers = 1 };
};
 
template<_Lock_policy _Lp = __default_lock_policy>
class _Sp_counted_base
: public _Mutex_base<_Lp>
{
public:
_Sp_counted_base()
: _M_use_count(1), _M_weak_count(1) { }
virtual
~_Sp_counted_base() // nothrow
{ }
// Called when _M_use_count drops to zero, to release the resources
// managed by *this.
virtual void
_M_dispose() = 0; // nothrow
// Called when _M_weak_count drops to zero.
virtual void
_M_destroy() // nothrow
{ delete this; }
virtual void*
_M_get_deleter(const std::type_info&) = 0;
 
void
_M_add_ref_copy()
{ __gnu_cxx::__atomic_add_dispatch(&_M_use_count, 1); }
void
_M_add_ref_lock();
void
_M_release() // nothrow
{
if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, -1) == 1)
{
_M_dispose();
// There must be a memory barrier between dispose() and destroy()
// to ensure that the effects of dispose() are observed in the
// thread that runs destroy().
// See http://gcc.gnu.org/ml/libstdc++/2005-11/msg00136.html
if (_Mutex_base<_Lp>::_S_need_barriers)
{
_GLIBCXX_READ_MEM_BARRIER;
_GLIBCXX_WRITE_MEM_BARRIER;
}
 
if (__gnu_cxx::__exchange_and_add_dispatch(&_M_weak_count,
-1) == 1)
_M_destroy();
}
}
void
_M_weak_add_ref() // nothrow
{ __gnu_cxx::__atomic_add_dispatch(&_M_weak_count, 1); }
 
void
_M_weak_release() // nothrow
{
if (__gnu_cxx::__exchange_and_add_dispatch(&_M_weak_count, -1) == 1)
{
if (_Mutex_base<_Lp>::_S_need_barriers)
{
// See _M_release(),
// destroy() must observe results of dispose()
_GLIBCXX_READ_MEM_BARRIER;
_GLIBCXX_WRITE_MEM_BARRIER;
}
_M_destroy();
}
}
long
_M_get_use_count() const // nothrow
{
// No memory barrier is used here so there is no synchronization
// with other threads.
return const_cast<const volatile _Atomic_word&>(_M_use_count);
}
 
private:
_Sp_counted_base(_Sp_counted_base const&);
_Sp_counted_base& operator=(_Sp_counted_base const&);
 
_Atomic_word _M_use_count; // #shared
_Atomic_word _M_weak_count; // #weak + (#shared != 0)
};
 
template<>
inline void
_Sp_counted_base<_S_single>::
_M_add_ref_lock()
{
if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, 1) == 0)
{
_M_use_count = 0;
__throw_bad_weak_ptr();
}
}
 
template<>
inline void
_Sp_counted_base<_S_mutex>::
_M_add_ref_lock()
{
__gnu_cxx::__scoped_lock sentry(*this);
if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, 1) == 0)
{
_M_use_count = 0;
__throw_bad_weak_ptr();
}
}
 
template<>
inline void
_Sp_counted_base<_S_atomic>::
_M_add_ref_lock()
{
// Perform lock-free add-if-not-zero operation.
_Atomic_word __count;
do
{
__count = _M_use_count;
if (__count == 0)
__throw_bad_weak_ptr();
// Replace the current counter value with the old value + 1, as
// long as it's not changed meanwhile.
}
while (!__sync_bool_compare_and_swap(&_M_use_count, __count,
__count + 1));
}
 
_GLIBCXX_END_NAMESPACE_TR1
}
boost_sp_counted_base.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: regex =================================================================== --- regex (nonexistent) +++ regex (revision 826) @@ -0,0 +1,2710 @@ +// class template regex -*- C++ -*- + +// Copyright (C) 2007, 2008, 2009, 2010 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 +// . + +/** + * @file tr1_impl/regex + * @brief The common implementation file for tr1 and std regular expressions. + * + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + +namespace std +{ +_GLIBCXX_BEGIN_NAMESPACE_TR1 + +/** + * @defgroup tr1_regex Regular Expressions + * A facility for performing regular expression pattern matching. + */ + //@{ + +/** @namespace std::regex_constants + * @brief ISO C++ 0x entities sub namespace for regex. + */ +namespace regex_constants +{ + /** + * @name 5.1 Regular Expression Syntax Options + */ + //@{ + enum __syntax_option + { + _S_icase, + _S_nosubs, + _S_optimize, + _S_collate, + _S_ECMAScript, + _S_basic, + _S_extended, + _S_awk, + _S_grep, + _S_egrep, + _S_syntax_last + }; + + /** + * @brief This is a bitmask type indicating how to interpret the regex. + * + * The @c syntax_option_type is implementation defined but it is valid to + * perform bitwise operations on these values and expect the right thing to + * happen. + * + * A valid value of type syntax_option_type shall have exactly one of the + * elements @c ECMAScript, @c basic, @c extended, @c awk, @c grep, @c egrep + * %set. + */ + typedef unsigned int syntax_option_type; + + /** + * Specifies that the matching of regular expressions against a character + * sequence shall be performed without regard to case. + */ + static const syntax_option_type icase = 1 << _S_icase; + + /** + * Specifies that when a regular expression is matched against a character + * container sequence, no sub-expression matches are to be stored in the + * supplied match_results structure. + */ + static const syntax_option_type nosubs = 1 << _S_nosubs; + + /** + * Specifies that the regular expression engine should pay more attention to + * the speed with which regular expressions are matched, and less to the + * speed with which regular expression objects are constructed. Otherwise + * it has no detectable effect on the program output. + */ + static const syntax_option_type optimize = 1 << _S_optimize; + + /** + * Specifies that character ranges of the form [a-b] should be locale + * sensitive. + */ + static const syntax_option_type collate = 1 << _S_collate; + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by ECMAScript in ECMA-262 [Ecma International, ECMAScript + * Language Specification, Standard Ecma-262, third edition, 1999], as + * modified in tr1 section [7.13]. This grammar is similar to that defined + * in the PERL scripting language but extended with elements found in the + * POSIX regular expression grammar. + */ + static const syntax_option_type ECMAScript = 1 << _S_ECMAScript; + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by POSIX basic regular expressions in IEEE Std 1003.1-2001, + * Portable Operating System Interface (POSIX), Base Definitions and + * Headers, Section 9, Regular Expressions [IEEE, Information Technology -- + * Portable Operating System Interface (POSIX), IEEE Standard 1003.1-2001]. + */ + static const syntax_option_type basic = 1 << _S_basic; + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by POSIX extended regular expressions in IEEE Std 1003.1-2001, + * Portable Operating System Interface (POSIX), Base Definitions and Headers, + * Section 9, Regular Expressions. + */ + static const syntax_option_type extended = 1 << _S_extended; + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by POSIX utility awk in IEEE Std 1003.1-2001. This option is + * identical to syntax_option_type extended, except that C-style escape + * sequences are supported. These sequences are: + * \\\\, \\a, \\b, \\f, + * \\n, \\r, \\t , \\v, + * \\', ', and \\ddd + * (where ddd is one, two, or three octal digits). + */ + static const syntax_option_type awk = 1 << _S_awk; + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by POSIX utility grep in IEEE Std 1003.1-2001. This option is + * identical to syntax_option_type basic, except that newlines are treated + * as whitespace. + */ + static const syntax_option_type grep = 1 << _S_grep; + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by POSIX utility grep when given the -E option in + * IEEE Std 1003.1-2001. This option is identical to syntax_option_type + * extended, except that newlines are treated as whitespace. + */ + static const syntax_option_type egrep = 1 << _S_egrep; + + //@} + + /** + * @name 5.2 Matching Rules + * + * Matching a regular expression against a sequence of characters [first, + * last) proceeds according to the rules of the grammar specified for the + * regular expression object, modified according to the effects listed + * below for any bitmask elements set. + * + */ + //@{ + + enum __match_flag + { + _S_not_bol, + _S_not_eol, + _S_not_bow, + _S_not_eow, + _S_any, + _S_not_null, + _S_continuous, + _S_prev_avail, + _S_sed, + _S_no_copy, + _S_first_only, + _S_match_flag_last + }; + + /** + * @brief This is a bitmask type indicating regex matching rules. + * + * The @c match_flag_type is implementation defined but it is valid to + * perform bitwise operations on these values and expect the right thing to + * happen. + */ + typedef std::bitset<_S_match_flag_last> match_flag_type; + + /** + * The default matching rules. + */ + static const match_flag_type match_default = 0; + + /** + * The first character in the sequence [first, last) is treated as though it + * is not at the beginning of a line, so the character (^) in the regular + * expression shall not match [first, first). + */ + static const match_flag_type match_not_bol = 1 << _S_not_bol; + + /** + * The last character in the sequence [first, last) is treated as though it + * is not at the end of a line, so the character ($) in the regular + * expression shall not match [last, last). + */ + static const match_flag_type match_not_eol = 1 << _S_not_eol; + + /** + * The expression \\b is not matched against the sub-sequence + * [first,first). + */ + static const match_flag_type match_not_bow = 1 << _S_not_bow; + + /** + * The expression \\b should not be matched against the sub-sequence + * [last,last). + */ + static const match_flag_type match_not_eow = 1 << _S_not_eow; + + /** + * If more than one match is possible then any match is an acceptable + * result. + */ + static const match_flag_type match_any = 1 << _S_any; + + /** + * The expression does not match an empty sequence. + */ + static const match_flag_type match_not_null = 1 << _S_not_null; + + /** + * The expression only matches a sub-sequence that begins at first . + */ + static const match_flag_type match_continuous = 1 << _S_continuous; + + /** + * --first is a valid iterator position. When this flag is set then the + * flags match_not_bol and match_not_bow are ignored by the regular + * expression algorithms 7.11 and iterators 7.12. + */ + static const match_flag_type match_prev_avail = 1 << _S_prev_avail; + + /** + * When a regular expression match is to be replaced by a new string, the + * new string is constructed using the rules used by the ECMAScript replace + * function in ECMA- 262 [Ecma International, ECMAScript Language + * Specification, Standard Ecma-262, third edition, 1999], part 15.5.4.11 + * String.prototype.replace. In addition, during search and replace + * operations all non-overlapping occurrences of the regular expression + * are located and replaced, and sections of the input that did not match + * the expression are copied unchanged to the output string. + * + * Format strings (from ECMA-262 [15.5.4.11]): + * @li $$ The dollar-sign itself ($) + * @li $& The matched substring. + * @li $` The portion of @a string that precedes the matched substring. + * This would be match_results::prefix(). + * @li $' The portion of @a string that follows the matched substring. + * This would be match_results::suffix(). + * @li $n The nth capture, where n is in [1,9] and $n is not followed by a + * decimal digit. If n <= match_results::size() and the nth capture + * is undefined, use the empty string instead. If n > + * match_results::size(), the result is implementation-defined. + * @li $nn The nnth capture, where nn is a two-digit decimal number on + * [01, 99]. If nn <= match_results::size() and the nth capture is + * undefined, use the empty string instead. If + * nn > match_results::size(), the result is implementation-defined. + */ + static const match_flag_type format_default = 0; + + /** + * When a regular expression match is to be replaced by a new string, the + * new string is constructed using the rules used by the POSIX sed utility + * in IEEE Std 1003.1- 2001 [IEEE, Information Technology -- Portable + * Operating System Interface (POSIX), IEEE Standard 1003.1-2001]. + */ + static const match_flag_type format_sed = 1 << _S_sed; + + /** + * During a search and replace operation, sections of the character + * container sequence being searched that do not match the regular + * expression shall not be copied to the output string. + */ + static const match_flag_type format_no_copy = 1 << _S_no_copy; + + /** + * When specified during a search and replace operation, only the first + * occurrence of the regular expression shall be replaced. + */ + static const match_flag_type format_first_only = 1 << _S_first_only; + + //@} + + /** + * @name 5.3 Error Types + */ + //@{ + + enum error_type + { + _S_error_collate, + _S_error_ctype, + _S_error_escape, + _S_error_backref, + _S_error_brack, + _S_error_paren, + _S_error_brace, + _S_error_badbrace, + _S_error_range, + _S_error_space, + _S_error_badrepeat, + _S_error_complexity, + _S_error_stack, + _S_error_last + }; + + /** The expression contained an invalid collating element name. */ + static const error_type error_collate(_S_error_collate); + + /** The expression contained an invalid character class name. */ + static const error_type error_ctype(_S_error_ctype); + + /** + * The expression contained an invalid escaped character, or a trailing + * escape. + */ + static const error_type error_escape(_S_error_escape); + + /** The expression contained an invalid back reference. */ + static const error_type error_backref(_S_error_backref); + + /** The expression contained mismatched [ and ]. */ + static const error_type error_brack(_S_error_brack); + + /** The expression contained mismatched ( and ). */ + static const error_type error_paren(_S_error_paren); + + /** The expression contained mismatched { and } */ + static const error_type error_brace(_S_error_brace); + + /** The expression contained an invalid range in a {} expression. */ + static const error_type error_badbrace(_S_error_badbrace); + + /** + * The expression contained an invalid character range, + * such as [b-a] in most encodings. + */ + static const error_type error_range(_S_error_range); + + /** + * There was insufficient memory to convert the expression into a + * finite state machine. + */ + static const error_type error_space(_S_error_space); + + /** + * One of *?+{ was not preceded by a valid regular expression. + */ + static const error_type error_badrepeat(_S_error_badrepeat); + + /** + * The complexity of an attempted match against a regular expression + * exceeded a pre-set level. + */ + static const error_type error_complexity(_S_error_complexity); + + /** + * There was insufficient memory to determine whether the + * regular expression could match the specified character sequence. + */ + static const error_type error_stack(_S_error_stack); + + //@} +} + + + // [7.8] Class regex_error + /** + * @brief A regular expression exception class. + * @ingroup exceptions + * + * The regular expression library throws objects of this class on error. + */ + class regex_error + : public std::runtime_error + { + public: + /** + * @brief Constructs a regex_error object. + * + * @param ecode the regex error code. + */ + explicit + regex_error(regex_constants::error_type __ecode) + : std::runtime_error("regex_error"), _M_code(__ecode) + { } + + /** + * @brief Gets the regex error code. + * + * @returns the regex error code. + */ + regex_constants::error_type + code() const + { return _M_code; } + + protected: + regex_constants::error_type _M_code; + }; + + // [7.7] Class regex_traits + /** + * @brief Describes aspects of a regular expression. + * + * A regular expression traits class that satisfies the requirements of tr1 + * section [7.2]. + * + * The class %regex is parameterized around a set of related types and + * functions used to complete the definition of its semantics. This class + * satisfies the requirements of such a traits class. + */ + template + struct regex_traits + { + public: + typedef _Ch_type char_type; + typedef std::basic_string string_type; + typedef std::locale locale_type; + typedef std::ctype_base::mask char_class_type; + + public: + /** + * @brief Constructs a default traits object. + */ + regex_traits() + { } + + /** + * @brief Gives the length of a C-style string starting at @p __p. + * + * @param __p a pointer to the start of a character sequence. + * + * @returns the number of characters between @p *__p and the first + * default-initialized value of type @p char_type. In other words, uses + * the C-string algorithm for determining the length of a sequence of + * characters. + */ + static std::size_t + length(const char_type* __p) + { return string_type::traits_type::length(__p); } + + /** + * @brief Performs the identity translation. + * + * @param c A character to the locale-specific character set. + * + * @returns c. + */ + char_type + translate(char_type __c) const + { return __c; } + + /** + * @brief Translates a character into a case-insensitive equivalent. + * + * @param c A character to the locale-specific character set. + * + * @returns the locale-specific lower-case equivalent of c. + * @throws std::bad_cast if the imbued locale does not support the ctype + * facet. + */ + char_type + translate_nocase(char_type __c) const + { + using std::ctype; + using std::use_facet; + return use_facet >(_M_locale).tolower(__c); + } + + /** + * @brief Gets a sort key for a character sequence. + * + * @param first beginning of the character sequence. + * @param last one-past-the-end of the character sequence. + * + * Returns a sort key for the character sequence designated by the + * iterator range [F1, F2) such that if the character sequence [G1, G2) + * sorts before the character sequence [H1, H2) then + * v.transform(G1, G2) < v.transform(H1, H2). + * + * What this really does is provide a more efficient way to compare a + * string to multiple other strings in locales with fancy collation + * rules and equivalence classes. + * + * @returns a locale-specific sort key equivalent to the input range. + * + * @throws std::bad_cast if the current locale does not have a collate + * facet. + */ + template + string_type + transform(_Fwd_iter __first, _Fwd_iter __last) const + { + using std::collate; + using std::use_facet; + const collate<_Ch_type>& __c(use_facet< + collate<_Ch_type> >(_M_locale)); + string_type __s(__first, __last); + return __c.transform(__s.data(), __s.data() + __s.size()); + } + + /** + * @brief Dunno. + * + * @param first beginning of the character sequence. + * @param last one-past-the-end of the character sequence. + * + * Effects: if typeid(use_facet >) == + * typeid(collate_byname<_Ch_type>) and the form of the sort key + * returned by collate_byname<_Ch_type>::transform(first, last) is known + * and can be converted into a primary sort key then returns that key, + * otherwise returns an empty string. WTF?? + * + * @todo Implement this function. + */ + template + string_type + transform_primary(_Fwd_iter __first, _Fwd_iter __last) const; + + /** + * @brief Gets a collation element by name. + * + * @param first beginning of the collation element name. + * @param last one-past-the-end of the collation element name. + * + * @returns a sequence of one or more characters that represents the + * collating element consisting of the character sequence designated by + * the iterator range [first, last). Returns an empty string if the + * character sequence is not a valid collating element. + * + * @todo Implement this function. + */ + template + string_type + lookup_collatename(_Fwd_iter __first, _Fwd_iter __last) const; + + /** + * @brief Maps one or more characters to a named character + * classification. + * + * @param first beginning of the character sequence. + * @param last one-past-the-end of the character sequence. + * + * @returns an unspecified value that represents the character + * classification named by the character sequence designated by the + * iterator range [first, last). The value returned shall be independent + * of the case of the characters in the character sequence. If the name + * is not recognized then returns a value that compares equal to 0. + * + * At least the following names (or their wide-character equivalent) are + * supported. + * - d + * - w + * - s + * - alnum + * - alpha + * - blank + * - cntrl + * - digit + * - graph + * - lower + * - print + * - punct + * - space + * - upper + * - xdigit + * + * @todo Implement this function. + */ + template + char_class_type + lookup_classname(_Fwd_iter __first, _Fwd_iter __last) const; + + /** + * @brief Determines if @p c is a member of an identified class. + * + * @param c a character. + * @param f a class type (as returned from lookup_classname). + * + * @returns true if the character @p c is a member of the classification + * represented by @p f, false otherwise. + * + * @throws std::bad_cast if the current locale does not have a ctype + * facet. + */ + bool + isctype(_Ch_type __c, char_class_type __f) const; + + /** + * @brief Converts a digit to an int. + * + * @param ch a character representing a digit. + * @param radix the radix if the numeric conversion (limited to 8, 10, + * or 16). + * + * @returns the value represented by the digit ch in base radix if the + * character ch is a valid digit in base radix; otherwise returns -1. + */ + int + value(_Ch_type __ch, int __radix) const; + + /** + * @brief Imbues the regex_traits object with a copy of a new locale. + * + * @param loc A locale. + * + * @returns a copy of the previous locale in use by the regex_traits + * object. + * + * @note Calling imbue with a different locale than the one currently in + * use invalidates all cached data held by *this. + */ + locale_type + imbue(locale_type __loc) + { + std::swap(_M_locale, __loc); + return __loc; + } + + /** + * @brief Gets a copy of the current locale in use by the regex_traits + * object. + */ + locale_type + getloc() const + { return _M_locale; } + + protected: + locale_type _M_locale; + }; + + template + bool regex_traits<_Ch_type>:: + isctype(_Ch_type __c, char_class_type __f) const + { + using std::ctype; + using std::use_facet; + const ctype<_Ch_type>& __ctype(use_facet< + ctype<_Ch_type> >(_M_locale)); + + if (__ctype.is(__c, __f)) + return true; + + // special case of underscore in [[:w:]] + if (__c == __ctype.widen('_')) + { + const char* const __wb[] = "w"; + char_class_type __wt = this->lookup_classname(__wb, + __wb + sizeof(__wb)); + if (__f | __wt) + return true; + } + + // special case of [[:space:]] in [[:blank:]] + if (__c == __ctype.isspace(__c)) + { + const char* const __bb[] = "blank"; + char_class_type __bt = this->lookup_classname(__bb, + __bb + sizeof(__bb)); + if (__f | __bt) + return true; + } + + return false; + } + + template + int regex_traits<_Ch_type>:: + value(_Ch_type __ch, int __radix) const + { + std::basic_istringstream<_Ch_type> __is(string_type(1, __ch)); + int __v; + if (__radix == 8) + __is >> std::oct; + else if (__radix == 16) + __is >> std::hex; + __is >> __v; + return __is.fail() ? -1 : __v; + } + + // [7.8] Class basic_regex + /** + * Objects of specializations of this class represent regular expressions + * constructed from sequences of character type @p _Ch_type. + * + * Storage for the regular expression is allocated and deallocated as + * necessary by the member functions of this class. + */ + template > + class basic_regex + { + public: + // types: + typedef _Ch_type value_type; + typedef regex_constants::syntax_option_type flag_type; + typedef typename _Rx_traits::locale_type locale_type; + typedef typename _Rx_traits::string_type string_type; + + /** + * @name Constants + * tr1 [7.8.1] std [28.8.1] + */ + //@{ + static const regex_constants::syntax_option_type icase + = regex_constants::icase; + static const regex_constants::syntax_option_type nosubs + = regex_constants::nosubs; + static const regex_constants::syntax_option_type optimize + = regex_constants::optimize; + static const regex_constants::syntax_option_type collate + = regex_constants::collate; + static const regex_constants::syntax_option_type ECMAScript + = regex_constants::ECMAScript; + static const regex_constants::syntax_option_type basic + = regex_constants::basic; + static const regex_constants::syntax_option_type extended + = regex_constants::extended; + static const regex_constants::syntax_option_type awk + = regex_constants::awk; + static const regex_constants::syntax_option_type grep + = regex_constants::grep; + static const regex_constants::syntax_option_type egrep + = regex_constants::egrep; + //@} + + // [7.8.2] construct/copy/destroy + /** + * Constructs a basic regular expression that does not match any + * character sequence. + */ + basic_regex() + : _M_flags(regex_constants::ECMAScript), _M_pattern(), _M_mark_count(0) + { _M_compile(); } + + /** + * @brief Constructs a basic regular expression from the sequence + * [p, p + char_traits<_Ch_type>::length(p)) interpreted according to the + * flags in @p f. + * + * @param p A pointer to the start of a C-style null-terminated string + * containing a regular expression. + * @param f Flags indicating the syntax rules and options. + * + * @throws regex_error if @p p is not a valid regular expression. + */ + explicit + basic_regex(const _Ch_type* __p, + flag_type __f = regex_constants::ECMAScript) + : _M_flags(__f), _M_pattern(__p), _M_mark_count(0) + { _M_compile(); } + + /** + * @brief Constructs a basic regular expression from the sequence + * [p, p + len) interpreted according to the flags in @p f. + * + * @param p A pointer to the start of a string containing a regular + * expression. + * @param len The length of the string containing the regular expression. + * @param f Flags indicating the syntax rules and options. + * + * @throws regex_error if @p p is not a valid regular expression. + */ + basic_regex(const _Ch_type* __p, std::size_t __len, flag_type __f) + : _M_flags(__f) , _M_pattern(__p, __len), _M_mark_count(0) + { _M_compile(); } + + /** + * @brief Copy-constructs a basic regular expression. + * + * @param rhs A @p regex object. + */ + basic_regex(const basic_regex& __rhs) + : _M_flags(__rhs._M_flags), _M_pattern(__rhs._M_pattern), + _M_mark_count(__rhs._M_mark_count) + { _M_compile(); } + + /** + * @brief Constructs a basic regular expression from the string + * @p s interpreted according to the flags in @p f. + * + * @param s A string containing a regular expression. + * @param f Flags indicating the syntax rules and options. + * + * @throws regex_error if @p s is not a valid regular expression. + */ + template + explicit + basic_regex(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s, + flag_type __f = regex_constants::ECMAScript) + : _M_flags(__f), _M_pattern(__s.begin(), __s.end()), _M_mark_count(0) + { _M_compile(); } + + /** + * @brief Constructs a basic regular expression from the range + * [first, last) interpreted according to the flags in @p f. + * + * @param first The start of a range containing a valid regular + * expression. + * @param last The end of a range containing a valid regular + * expression. + * @param f The format flags of the regular expression. + * + * @throws regex_error if @p [first, last) is not a valid regular + * expression. + */ + template + basic_regex(_InputIterator __first, _InputIterator __last, + flag_type __f = regex_constants::ECMAScript) + : _M_flags(__f), _M_pattern(__first, __last), _M_mark_count(0) + { _M_compile(); } + +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + /** + * @brief Constructs a basic regular expression from an initializer list. + * + * @param l The initializer list. + * @param f The format flags of the regular expression. + * + * @throws regex_error if @p l is not a valid regular expression. + */ + basic_regex(initializer_list<_Ch_type> __l, + flag_type __f = regex_constants::ECMAScript) + : _M_flags(__f), _M_pattern(__l.begin(), __l.end()), _M_mark_count(0) + { _M_compile(); } +#endif + + /** + * @brief Destroys a basic regular expression. + */ + ~basic_regex() + { } + + /** + * @brief Assigns one regular expression to another. + */ + basic_regex& + operator=(const basic_regex& __rhs) + { return this->assign(__rhs); } + + /** + * @brief Replaces a regular expression with a new one constructed from + * a C-style null-terminated string. + * + * @param A pointer to the start of a null-terminated C-style string + * containing a regular expression. + */ + basic_regex& + operator=(const _Ch_type* __p) + { return this->assign(__p, flags()); } + + /** + * @brief Replaces a regular expression with a new one constructed from + * a string. + * + * @param A pointer to a string containing a regular expression. + */ + template + basic_regex& + operator=(const basic_string<_Ch_type, _Ch_typeraits, _Allocator>& __s) + { return this->assign(__s, flags()); } + + // [7.8.3] assign + /** + * @brief the real assignment operator. + * + * @param that Another regular expression object. + */ + basic_regex& + assign(const basic_regex& __that) + { + basic_regex __tmp(__that); + this->swap(__tmp); + return *this; + } + + /** + * @brief Assigns a new regular expression to a regex object from a + * C-style null-terminated string containing a regular expression + * pattern. + * + * @param p A pointer to a C-style null-terminated string containing + * a regular expression pattern. + * @param flags Syntax option flags. + * + * @throws regex_error if p does not contain a valid regular expression + * pattern interpreted according to @p flags. If regex_error is thrown, + * *this remains unchanged. + */ + basic_regex& + assign(const _Ch_type* __p, + flag_type __flags = regex_constants::ECMAScript) + { return this->assign(string_type(__p), __flags); } + + /** + * @brief Assigns a new regular expression to a regex object from a + * C-style string containing a regular expression pattern. + * + * @param p A pointer to a C-style string containing a + * regular expression pattern. + * @param len The length of the regular expression pattern string. + * @param flags Syntax option flags. + * + * @throws regex_error if p does not contain a valid regular expression + * pattern interpreted according to @p flags. If regex_error is thrown, + * *this remains unchanged. + */ + basic_regex& + assign(const _Ch_type* __p, std::size_t __len, flag_type __flags) + { return this->assign(string_type(__p, __len), __flags); } + + /** + * @brief Assigns a new regular expression to a regex object from a + * string containing a regular expression pattern. + * + * @param s A string containing a regular expression pattern. + * @param flags Syntax option flags. + * + * @throws regex_error if p does not contain a valid regular expression + * pattern interpreted according to @p flags. If regex_error is thrown, + * *this remains unchanged. + */ + template + basic_regex& + assign(const basic_string<_Ch_type, _Ch_typeraits, _Allocator>& __s, + flag_type __f = regex_constants::ECMAScript) + { + basic_regex __tmp(__s, __f); + this->swap(__tmp); + return *this; + } + + /** + * @brief Assigns a new regular expression to a regex object. + * + * @param first The start of a range containing a valid regular + * expression. + * @param last The end of a range containing a valid regular + * expression. + * @param flags Syntax option flags. + * + * @throws regex_error if p does not contain a valid regular expression + * pattern interpreted according to @p flags. If regex_error is thrown, + * the object remains unchanged. + */ + template + basic_regex& + assign(_InputIterator __first, _InputIterator __last, + flag_type __flags = regex_constants::ECMAScript) + { return this->assign(string_type(__first, __last), __flags); } + +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + /** + * @brief Assigns a new regular expression to a regex object. + * + * @param l An initializer list representing a regular expression. + * @param flags Syntax option flags. + * + * @throws regex_error if @p l does not contain a valid regular + * expression pattern interpreted according to @p flags. If regex_error + * is thrown, the object remains unchanged. + */ + basic_regex& + assign(initializer_list<_Ch_type> __l, + flag_type __f = regex_constants::ECMAScript) + { return this->assign(__l.begin(), __l.end(), __f); } +#endif + + // [7.8.4] const operations + /** + * @brief Gets the number of marked subexpressions within the regular + * expression. + */ + unsigned int + mark_count() const + { return _M_mark_count; } + + /** + * @brief Gets the flags used to construct the regular expression + * or in the last call to assign(). + */ + flag_type + flags() const + { return _M_flags; } + + // [7.8.5] locale + /** + * @brief Imbues the regular expression object with the given locale. + * + * @param loc A locale. + */ + locale_type + imbue(locale_type __loc) + { return _M_traits.imbue(__loc); } + + /** + * @brief Gets the locale currently imbued in the regular expression + * object. + */ + locale_type + getloc() const + { return _M_traits.getloc(); } + + // [7.8.6] swap + /** + * @brief Swaps the contents of two regular expression objects. + * + * @param rhs Another regular expression object. + */ + void + swap(basic_regex& __rhs) + { + std::swap(_M_flags, __rhs._M_flags); + std::swap(_M_pattern, __rhs._M_pattern); + std::swap(_M_mark_count, __rhs._M_mark_count); + std::swap(_M_traits, __rhs._M_traits); + } + + private: + /** + * @brief Compiles a regular expression pattern into a NFA. + * @todo Implement this function. + */ + void _M_compile(); + + protected: + flag_type _M_flags; + string_type _M_pattern; + unsigned int _M_mark_count; + _Rx_traits _M_traits; + }; + + /** @brief Standard regular expressions. */ + typedef basic_regex regex; +#ifdef _GLIBCXX_USE_WCHAR_T + /** @brief Standard wide-character regular expressions. */ + typedef basic_regex wregex; +#endif + + + // [7.8.6] basic_regex swap + /** + * @brief Swaps the contents of two regular expression objects. + * @param lhs First regular expression. + * @param rhs Second regular expression. + */ + template + inline void + swap(basic_regex<_Ch_type, _Rx_traits>& __lhs, + basic_regex<_Ch_type, _Rx_traits>& __rhs) + { __lhs.swap(__rhs); } + + + // [7.9] Class template sub_match + /** + * A sequence of characters matched by a particular marked sub-expression. + * + * An object of this class is essentially a pair of iterators marking a + * matched subexpression within a regular expression pattern match. Such + * objects can be converted to and compared with std::basic_string objects + * of a similar base character type as the pattern matched by the regular + * expression. + * + * The iterators that make up the pair are the usual half-open interval + * referencing the actual original pattern matched. + */ + template + class sub_match : public std::pair<_BiIter, _BiIter> + { + public: + typedef typename iterator_traits<_BiIter>::value_type value_type; + typedef typename iterator_traits<_BiIter>::difference_type + difference_type; + typedef _BiIter iterator; + + public: + bool matched; + + /** + * Gets the length of the matching sequence. + */ + difference_type + length() const + { return this->matched ? std::distance(this->first, this->second) : 0; } + + /** + * @brief Gets the matching sequence as a string. + * + * @returns the matching sequence as a string. + * + * This is the implicit conversion operator. It is identical to the + * str() member function except that it will want to pop up in + * unexpected places and cause a great deal of confusion and cursing + * from the unwary. + */ + operator basic_string() const + { + return this->matched + ? std::basic_string(this->first, this->second) + : std::basic_string(); + } + + /** + * @brief Gets the matching sequence as a string. + * + * @returns the matching sequence as a string. + */ + basic_string + str() const + { + return this->matched + ? std::basic_string(this->first, this->second) + : std::basic_string(); + } + + /** + * @brief Compares this and another matched sequence. + * + * @param s Another matched sequence to compare to this one. + * + * @retval <0 this matched sequence will collate before @p s. + * @retval =0 this matched sequence is equivalent to @p s. + * @retval <0 this matched sequence will collate after @p s. + */ + int + compare(const sub_match& __s) const + { return this->str().compare(__s.str()); } + + /** + * @brief Compares this sub_match to a string. + * + * @param s A string to compare to this sub_match. + * + * @retval <0 this matched sequence will collate before @p s. + * @retval =0 this matched sequence is equivalent to @p s. + * @retval <0 this matched sequence will collate after @p s. + */ + int + compare(const basic_string& __s) const + { return this->str().compare(__s); } + + /** + * @brief Compares this sub_match to a C-style string. + * + * @param s A C-style string to compare to this sub_match. + * + * @retval <0 this matched sequence will collate before @p s. + * @retval =0 this matched sequence is equivalent to @p s. + * @retval <0 this matched sequence will collate after @p s. + */ + int + compare(const value_type* __s) const + { return this->str().compare(__s); } + }; + + + /** @brief Standard regex submatch over a C-style null-terminated string. */ + typedef sub_match csub_match; + /** @brief Standard regex submatch over a standard string. */ + typedef sub_match ssub_match; +#ifdef _GLIBCXX_USE_WCHAR_T + /** @brief Regex submatch over a C-style null-terminated wide string. */ + typedef sub_match wcsub_match; + /** @brief Regex submatch over a standard wide string. */ + typedef sub_match wssub_match; +#endif + + // [7.9.2] sub_match non-member operators + + /** + * @brief Tests the equivalence of two regular expression submatches. + * @param lhs First regular expression submatch. + * @param rhs Second regular expression submatch. + * @returns true if @a lhs is equivalent to @a rhs, false otherwise. + */ + template + inline bool + operator==(const sub_match<_BiIter>& __lhs, + const sub_match<_BiIter>& __rhs) + { return __lhs.compare(__rhs) == 0; } + + /** + * @brief Tests the inequivalence of two regular expression submatches. + * @param lhs First regular expression submatch. + * @param rhs Second regular expression submatch. + * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. + */ + template + inline bool + operator!=(const sub_match<_BiIter>& __lhs, + const sub_match<_BiIter>& __rhs) + { return __lhs.compare(__rhs) != 0; } + + /** + * @brief Tests the ordering of two regular expression submatches. + * @param lhs First regular expression submatch. + * @param rhs Second regular expression submatch. + * @returns true if @a lhs precedes @a rhs, false otherwise. + */ + template + inline bool + operator<(const sub_match<_BiIter>& __lhs, + const sub_match<_BiIter>& __rhs) + { return __lhs.compare(__rhs) < 0; } + + /** + * @brief Tests the ordering of two regular expression submatches. + * @param lhs First regular expression submatch. + * @param rhs Second regular expression submatch. + * @returns true if @a lhs does not succeed @a rhs, false otherwise. + */ + template + inline bool + operator<=(const sub_match<_BiIter>& __lhs, + const sub_match<_BiIter>& __rhs) + { return __lhs.compare(__rhs) <= 0; } + + /** + * @brief Tests the ordering of two regular expression submatches. + * @param lhs First regular expression submatch. + * @param rhs Second regular expression submatch. + * @returns true if @a lhs does not precede @a rhs, false otherwise. + */ + template + inline bool + operator>=(const sub_match<_BiIter>& __lhs, + const sub_match<_BiIter>& __rhs) + { return __lhs.compare(__rhs) >= 0; } + + /** + * @brief Tests the ordering of two regular expression submatches. + * @param lhs First regular expression submatch. + * @param rhs Second regular expression submatch. + * @returns true if @a lhs succeeds @a rhs, false otherwise. + */ + template + inline bool + operator>(const sub_match<_BiIter>& __lhs, + const sub_match<_BiIter>& __rhs) + { return __lhs.compare(__rhs) > 0; } + + /** + * @brief Tests the equivalence of a string and a regular expression + * submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs is equivalent to @a rhs, false otherwise. + */ + template + inline bool + operator==(const basic_string< + typename iterator_traits<_Bi_iter>::value_type, + _Ch_traits, _Ch_alloc>& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __lhs == __rhs.str(); } + + /** + * @brief Tests the inequivalence of a string and a regular expression + * submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. + */ + template + inline bool + operator!=(const basic_string< + typename iterator_traits<_Bi_iter>::value_type, + _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs) + { return __lhs != __rhs.str(); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs precedes @a rhs, false otherwise. + */ + template + inline bool + operator<(const basic_string< + typename iterator_traits<_Bi_iter>::value_type, + _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs) + { return __lhs < __rhs.str(); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs succeeds @a rhs, false otherwise. + */ + template + inline bool + operator>(const basic_string< + typename iterator_traits<_Bi_iter>::value_type, + _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs) + { return __lhs > __rhs.str(); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs does not precede @a rhs, false otherwise. + */ + template + inline bool + operator>=(const basic_string< + typename iterator_traits<_Bi_iter>::value_type, + _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs) + { return __lhs >= __rhs.str(); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs does not succeed @a rhs, false otherwise. + */ + template + inline bool + operator<=(const basic_string< + typename iterator_traits<_Bi_iter>::value_type, + _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs) + { return __lhs <= __rhs.str(); } + + /** + * @brief Tests the equivalence of a regular expression submatch and a + * string. + * @param lhs A regular expression submatch. + * @param rhs A string. + * @returns true if @a lhs is equivalent to @a rhs, false otherwise. + */ + template + inline bool + operator==(const sub_match<_Bi_iter>& __lhs, + const basic_string< + typename iterator_traits<_Bi_iter>::value_type, + _Ch_traits, _Ch_alloc>& __rhs) + { return __lhs.str() == __rhs; } + + /** + * @brief Tests the inequivalence of a regular expression submatch and a + * string. + * @param lhs A regular expression submatch. + * @param rhs A string. + * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. + */ + template + inline bool + operator!=(const sub_match<_Bi_iter>& __lhs, + const basic_string< + typename iterator_traits<_Bi_iter>::value_type, + _Ch_traits, _Ch_alloc>& __rhs) + { return __lhs.str() != __rhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param lhs A regular expression submatch. + * @param rhs A string. + * @returns true if @a lhs precedes @a rhs, false otherwise. + */ + template + inline bool + operator<(const sub_match<_Bi_iter>& __lhs, + const basic_string< + typename iterator_traits<_Bi_iter>::value_type, + _Ch_traits, _Ch_alloc>& __rhs) + { return __lhs.str() < __rhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param lhs A regular expression submatch. + * @param rhs A string. + * @returns true if @a lhs succeeds @a rhs, false otherwise. + */ + template + inline bool + operator>(const sub_match<_Bi_iter>& __lhs, + const basic_string< + typename iterator_traits<_Bi_iter>::value_type, + _Ch_traits, _Ch_alloc>& __rhs) + { return __lhs.str() > __rhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param lhs A regular expression submatch. + * @param rhs A string. + * @returns true if @a lhs does not precede @a rhs, false otherwise. + */ + template + inline bool + operator>=(const sub_match<_Bi_iter>& __lhs, + const basic_string< + typename iterator_traits<_Bi_iter>::value_type, + _Ch_traits, _Ch_alloc>& __rhs) + { return __lhs.str() >= __rhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param lhs A regular expression submatch. + * @param rhs A string. + * @returns true if @a lhs does not succeed @a rhs, false otherwise. + */ + template + inline bool + operator<=(const sub_match<_Bi_iter>& __lhs, + const basic_string< + typename iterator_traits<_Bi_iter>::value_type, + _Ch_traits, _Ch_alloc>& __rhs) + { return __lhs.str() <= __rhs; } + + /** + * @brief Tests the equivalence of a C string and a regular expression + * submatch. + * @param lhs A C string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs is equivalent to @a rhs, false otherwise. + */ + template + inline bool + operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __lhs == __rhs.str(); } + + /** + * @brief Tests the inequivalence of an iterator value and a regular + * expression submatch. + * @param lhs A regular expression submatch. + * @param rhs A string. + * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. + */ + template + inline bool + operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __lhs != __rhs.str(); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs precedes @a rhs, false otherwise. + */ + template + inline bool + operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __lhs < __rhs.str(); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs succeeds @a rhs, false otherwise. + */ + template + inline bool + operator>(typename iterator_traits<_Bi_iter>::value_type const* __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __lhs > __rhs.str(); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs does not precede @a rhs, false otherwise. + */ + template + inline bool + operator>=(typename iterator_traits<_Bi_iter>::value_type const* __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __lhs >= __rhs.str(); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs does not succeed @a rhs, false otherwise. + */ + template + inline bool + operator<=(typename iterator_traits<_Bi_iter>::value_type const* __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __lhs <= __rhs.str(); } + + /** + * @brief Tests the equivalence of a regular expression submatch and a + * string. + * @param lhs A regular expression submatch. + * @param rhs A pointer to a string? + * @returns true if @a lhs is equivalent to @a rhs, false otherwise. + */ + template + inline bool + operator==(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const* __rhs) + { return __lhs.str() == __rhs; } + + /** + * @brief Tests the inequivalence of a regular expression submatch and a + * string. + * @param lhs A regular expression submatch. + * @param rhs A pointer to a string. + * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. + */ + template + inline bool + operator!=(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const* __rhs) + { return __lhs.str() != __rhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param lhs A regular expression submatch. + * @param rhs A string. + * @returns true if @a lhs precedes @a rhs, false otherwise. + */ + template + inline bool + operator<(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const* __rhs) + { return __lhs.str() < __rhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param lhs A regular expression submatch. + * @param rhs A string. + * @returns true if @a lhs succeeds @a rhs, false otherwise. + */ + template + inline bool + operator>(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const* __rhs) + { return __lhs.str() > __rhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param lhs A regular expression submatch. + * @param rhs A string. + * @returns true if @a lhs does not precede @a rhs, false otherwise. + */ + template + inline bool + operator>=(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const* __rhs) + { return __lhs.str() >= __rhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param lhs A regular expression submatch. + * @param rhs A string. + * @returns true if @a lhs does not succeed @a rhs, false otherwise. + */ + template + inline bool + operator<=(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const* __rhs) + { return __lhs.str() <= __rhs; } + + /** + * @brief Tests the equivalence of a string and a regular expression + * submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs is equivalent to @a rhs, false otherwise. + */ + template + inline bool + operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __lhs == __rhs.str(); } + + /** + * @brief Tests the inequivalence of a string and a regular expression + * submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. + */ + template + inline bool + operator!=(typename iterator_traits<_Bi_iter>::value_type const& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __lhs != __rhs.str(); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs precedes @a rhs, false otherwise. + */ + template + inline bool + operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __lhs < __rhs.str(); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs succeeds @a rhs, false otherwise. + */ + template + inline bool + operator>(typename iterator_traits<_Bi_iter>::value_type const& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __lhs > __rhs.str(); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs does not precede @a rhs, false otherwise. + */ + template + inline bool + operator>=(typename iterator_traits<_Bi_iter>::value_type const& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __lhs >= __rhs.str(); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs does not succeed @a rhs, false otherwise. + */ + template + inline bool + operator<=(typename iterator_traits<_Bi_iter>::value_type const& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __lhs <= __rhs.str(); } + + /** + * @brief Tests the equivalence of a regular expression submatch and a + * string. + * @param lhs A regular expression submatch. + * @param rhs A const string reference. + * @returns true if @a lhs is equivalent to @a rhs, false otherwise. + */ + template + inline bool + operator==(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const& __rhs) + { return __lhs.str() == __rhs; } + + /** + * @brief Tests the inequivalence of a regular expression submatch and a + * string. + * @param lhs A regular expression submatch. + * @param rhs A const string reference. + * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. + */ + template + inline bool + operator!=(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const& __rhs) + { return __lhs.str() != __rhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param lhs A regular expression submatch. + * @param rhs A const string reference. + * @returns true if @a lhs precedes @a rhs, false otherwise. + */ + template + inline bool + operator<(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const& __rhs) + { return __lhs.str() < __rhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param lhs A regular expression submatch. + * @param rhs A const string reference. + * @returns true if @a lhs succeeds @a rhs, false otherwise. + */ + template + inline bool + operator>(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const& __rhs) + { return __lhs.str() > __rhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param lhs A regular expression submatch. + * @param rhs A const string reference. + * @returns true if @a lhs does not precede @a rhs, false otherwise. + */ + template + inline bool + operator>=(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const& __rhs) + { return __lhs.str() >= __rhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param lhs A regular expression submatch. + * @param rhs A const string reference. + * @returns true if @a lhs does not succeed @a rhs, false otherwise. + */ + template + inline bool + operator<=(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const& __rhs) + { return __lhs.str() <= __rhs; } + + /** + * @brief Inserts a matched string into an output stream. + * + * @param os The output stream. + * @param m A submatch string. + * + * @returns the output stream with the submatch string inserted. + */ + template + inline + basic_ostream<_Ch_type, _Ch_traits>& + operator<<(basic_ostream<_Ch_type, _Ch_traits>& __os, + const sub_match<_Bi_iter>& __m) + { return __os << __m.str(); } + + // [7.10] Class template match_results + /** + * @brief The results of a match or search operation. + * + * A collection of character sequences representing the result of a regular + * expression match. Storage for the collection is allocated and freed as + * necessary by the member functions of class template match_results. + * + * This class satisfies the Sequence requirements, with the exception that + * only the operations defined for a const-qualified Sequence are supported. + * + * The sub_match object stored at index 0 represents sub-expression 0, i.e. + * the whole match. In this case the sub_match member matched is always true. + * The sub_match object stored at index n denotes what matched the marked + * sub-expression n within the matched expression. If the sub-expression n + * participated in a regular expression match then the sub_match member + * matched evaluates to true, and members first and second denote the range + * of characters [first, second) which formed that match. Otherwise matched + * is false, and members first and second point to the end of the sequence + * that was searched. + * + * @nosubgrouping + */ + template > > + class match_results + : private std::vector, _Allocator> + { + private: + typedef std::vector, _Allocator> + _Base_type; + + public: + /** + * @name 10.? Public Types + */ + //@{ + typedef sub_match<_Bi_iter> value_type; + typedef typename _Allocator::const_reference const_reference; + typedef const_reference reference; + typedef typename _Base_type::const_iterator const_iterator; + typedef const_iterator iterator; + typedef typename iterator_traits<_Bi_iter>::difference_type + difference_type; + typedef typename _Allocator::size_type size_type; + typedef _Allocator allocator_type; + typedef typename iterator_traits<_Bi_iter>::value_type char_type; + typedef basic_string string_type; + //@} + + public: + /** + * @name 10.1 Construction, Copying, and Destruction + */ + //@{ + + /** + * @brief Constructs a default %match_results container. + * @post size() returns 0 and str() returns an empty string. + */ + explicit + match_results(const _Allocator& __a = _Allocator()) + : _Base_type(__a), _M_matched(false) + { } + + /** + * @brief Copy constructs a %match_results. + */ + match_results(const match_results& __rhs) + : _Base_type(__rhs), _M_matched(__rhs._M_matched), + _M_prefix(__rhs._M_prefix), _M_suffix(__rhs._M_suffix) + { } + + /** + * @brief Assigns rhs to *this. + */ + match_results& + operator=(const match_results& __rhs) + { + match_results __tmp(__rhs); + this->swap(__tmp); + return *this; + } + + /** + * @brief Destroys a %match_results object. + */ + ~match_results() + { } + + //@} + + /** + * @name 10.2 Size + */ + //@{ + + /** + * @brief Gets the number of matches and submatches. + * + * The number of matches for a given regular expression will be either 0 + * if there was no match or mark_count() + 1 if a match was successful. + * Some matches may be empty. + * + * @returns the number of matches found. + */ + size_type + size() const + { return _M_matched ? _Base_type::size() + 1 : 0; } + + //size_type + //max_size() const; + using _Base_type::max_size; + + /** + * @brief Indicates if the %match_results contains no results. + * @retval true The %match_results object is empty. + * @retval false The %match_results object is not empty. + */ + bool + empty() const + { return size() == 0; } + + //@} + + /** + * @name 10.3 Element Access + */ + //@{ + + /** + * @brief Gets the length of the indicated submatch. + * @param sub indicates the submatch. + * + * This function returns the length of the indicated submatch, or the + * length of the entire match if @p sub is zero (the default). + */ + difference_type + length(size_type __sub = 0) const + { return _M_matched ? this->str(__sub).length() : 0; } + + /** + * @brief Gets the offset of the beginning of the indicated submatch. + * @param sub indicates the submatch. + * + * This function returns the offset from the beginning of the target + * sequence to the beginning of the submatch, unless the value of @p sub + * is zero (the default), in which case this function returns the offset + * from the beginning of the target sequence to the beginning of the + * match. + */ + difference_type + position(size_type __sub = 0) const + { + return _M_matched ? std::distance(this->prefix().first, + (*this)[__sub].first) : 0; + } + + /** + * @brief Gets the match or submatch converted to a string type. + * @param sub indicates the submatch. + * + * This function gets the submatch (or match, if @p sub is zero) extracted + * from the target range and converted to the associated string type. + */ + string_type + str(size_type __sub = 0) const + { return _M_matched ? (*this)[__sub].str() : string_type(); } + + /** + * @brief Gets a %sub_match reference for the match or submatch. + * @param sub indicates the submatch. + * + * This function gets a reference to the indicated submatch, or the entire + * match if @p sub is zero. + * + * If @p sub >= size() then this function returns a %sub_match with a + * special value indicating no submatch. + */ + const_reference + operator[](size_type __sub) const + { return _Base_type::operator[](__sub); } + + /** + * @brief Gets a %sub_match representing the match prefix. + * + * This function gets a reference to a %sub_match object representing the + * part of the target range between the start of the target range and the + * start of the match. + */ + const_reference + prefix() const + { return _M_prefix; } + + /** + * @brief Gets a %sub_match representing the match suffix. + * + * This function gets a reference to a %sub_match object representing the + * part of the target range between the end of the match and the end of + * the target range. + */ + const_reference + suffix() const + { return _M_suffix; } + + /** + * @brief Gets an iterator to the start of the %sub_match collection. + */ + const_iterator + begin() const + { return _Base_type::begin(); } + +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + /** + * @brief Gets an iterator to the start of the %sub_match collection. + */ + const_iterator + cbegin() const + { return _Base_type::begin(); } +#endif + + /** + * @brief Gets an iterator to one-past-the-end of the collection. + */ + const_iterator + end() const + { return _Base_type::end(); } + +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + /** + * @brief Gets an iterator to one-past-the-end of the collection. + */ + const_iterator + cend() const + { return _Base_type::end(); } +#endif + + //@} + + /** + * @name 10.4 Formatting + * + * These functions perform formatted substitution of the matched character + * sequences into their target. The format specifiers and escape sequences + * accepted by these functions are determined by their @p flags parameter + * as documented above. + */ + //@{ + + /** + * @todo Implement this function. + */ + template + _Out_iter + format(_Out_iter __out, const string_type& __fmt, + regex_constants::match_flag_type __flags + = regex_constants::format_default) const; + + /** + * @todo Implement this function. + */ + string_type + format(const string_type& __fmt, + regex_constants::match_flag_type __flags + = regex_constants::format_default) const; + + //@} + + /** + * @name 10.5 Allocator + */ + //@{ + + /** + * @brief Gets a copy of the allocator. + */ + //allocator_type + //get_allocator() const; + using _Base_type::get_allocator; + + //@} + + /** + * @name 10.6 Swap + */ + //@{ + + /** + * @brief Swaps the contents of two match_results. + */ + void + swap(match_results& __that) + { + _Base_type::swap(__that); + std::swap(_M_matched, __that._M_matched); + std::swap(_M_prefix, __that._M_prefix); + std::swap(_M_suffix, __that._M_suffix); + } + //@} + + private: + bool _M_matched; + value_type _M_prefix; + value_type _M_suffix; + }; + + typedef match_results cmatch; + typedef match_results smatch; +#ifdef _GLIBCXX_USE_WCHAR_T + typedef match_results wcmatch; + typedef match_results wsmatch; +#endif + + // match_results comparisons + /** + * @brief Compares two match_results for equality. + * @returns true if the two objects refer to the same match, + * false otherwise. + * @todo Implement this function. + */ + template + inline bool + operator==(const match_results<_Bi_iter, _Allocator>& __m1, + const match_results<_Bi_iter, _Allocator>& __m2); + + /** + * @brief Compares two match_results for inequality. + * @returns true if the two objects do not refer to the same match, + * false otherwise. + */ + template + inline bool + operator!=(const match_results<_Bi_iter, _Allocator>& __m1, + const match_results<_Bi_iter, _Allocator>& __m2) + { return !(__m1 == __m2); } + + // [7.10.6] match_results swap + /** + * @brief Swaps two match results. + * @param lhs A match result. + * @param rhs A match result. + * + * The contents of the two match_results objects are swapped. + */ + template + inline void + swap(match_results<_Bi_iter, _Allocator>& __lhs, + match_results<_Bi_iter, _Allocator>& __rhs) + { __lhs.swap(__rhs); } + + // [7.11.2] Function template regex_match + /** + * @name Matching, Searching, and Replacing + */ + //@{ + + /** + * @brief Determines if there is a match between the regular expression @p e + * and all of the character sequence [first, last). + * + * @param first Beginning of the character sequence to match. + * @param last One-past-the-end of the character sequence to match. + * @param m The match results. + * @param re The regular expression. + * @param flags Controls how the regular expression is matched. + * + * @retval true A match exists. + * @retval false Otherwise. + * + * @throws an exception of type regex_error. + * + * @todo Implement this function. + */ + template + bool + regex_match(_Bi_iter __first, _Bi_iter __last, + match_results<_Bi_iter, _Allocator>& __m, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __flags + = regex_constants::match_default); + + /** + * @brief Indicates if there is a match between the regular expression @p e + * and all of the character sequence [first, last). + * + * @param first Beginning of the character sequence to match. + * @param last One-past-the-end of the character sequence to match. + * @param re The regular expression. + * @param flags Controls how the regular expression is matched. + * + * @retval true A match exists. + * @retval false Otherwise. + * + * @throws an exception of type regex_error. + */ + template + bool + regex_match(_Bi_iter __first, _Bi_iter __last, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { + match_results<_Bi_iter> __what; + return regex_match(__first, __last, __what, __re, __flags); + } + + /** + * @brief Determines if there is a match between the regular expression @p e + * and a C-style null-terminated string. + * + * @param s The C-style null-terminated string to match. + * @param m The match results. + * @param re The regular expression. + * @param f Controls how the regular expression is matched. + * + * @retval true A match exists. + * @retval false Otherwise. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_match(const _Ch_type* __s, + match_results& __m, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __f + = regex_constants::match_default) + { return regex_match(__s, __s + _Rx_traits::length(__s), __m, __re, __f); } + + /** + * @brief Determines if there is a match between the regular expression @p e + * and a string. + * + * @param s The string to match. + * @param m The match results. + * @param re The regular expression. + * @param flags Controls how the regular expression is matched. + * + * @retval true A match exists. + * @retval false Otherwise. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_match(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s, + match_results::const_iterator, _Allocator>& __m, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { return regex_match(__s.begin(), __s.end(), __m, __re, __flags); } + + /** + * @brief Indicates if there is a match between the regular expression @p e + * and a C-style null-terminated string. + * + * @param s The C-style null-terminated string to match. + * @param re The regular expression. + * @param f Controls how the regular expression is matched. + * + * @retval true A match exists. + * @retval false Otherwise. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_match(const _Ch_type* __s, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __f + = regex_constants::match_default) + { return regex_match(__s, __s + _Rx_traits::length(__s), __re, __f); } + + /** + * @brief Indicates if there is a match between the regular expression @p e + * and a string. + * + * @param s [IN] The string to match. + * @param re [IN] The regular expression. + * @param flags [IN] Controls how the regular expression is matched. + * + * @retval true A match exists. + * @retval false Otherwise. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_match(const basic_string<_Ch_type, _Ch_traits, _Str_allocator>& __s, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { return regex_match(__s.begin(), __s.end(), __re, __flags); } + + // [7.11.3] Function template regex_search + /** + * Searches for a regular expression within a range. + * @param first [IN] The start of the string to search. + * @param last [IN] One-past-the-end of the string to search. + * @param m [OUT] The match results. + * @param re [IN] The regular expression to search for. + * @param flags [IN] Search policy flags. + * @retval true A match was found within the string. + * @retval false No match was found within the string, the content of %m is + * undefined. + * + * @throws an exception of type regex_error. + * + * @todo Implement this function. + */ + template + inline bool + regex_search(_Bi_iter __first, _Bi_iter __last, + match_results<_Bi_iter, _Allocator>& __m, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __flags + = regex_constants::match_default); + + /** + * Searches for a regular expression within a range. + * @param first [IN] The start of the string to search. + * @param last [IN] One-past-the-end of the string to search. + * @param re [IN] The regular expression to search for. + * @param flags [IN] Search policy flags. + * @retval true A match was found within the string. + * @retval false No match was found within the string. + * @doctodo + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_search(_Bi_iter __first, _Bi_iter __last, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { + match_results<_Bi_iter> __what; + return regex_search(__first, __last, __what, __re, __flags); + } + + /** + * @brief Searches for a regular expression within a C-string. + * @param s [IN] A C-string to search for the regex. + * @param m [OUT] The set of regex matches. + * @param e [IN] The regex to search for in @p s. + * @param f [IN] The search flags. + * @retval true A match was found within the string. + * @retval false No match was found within the string, the content of %m is + * undefined. + * @doctodo + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_search(const _Ch_type* __s, + match_results& __m, + const basic_regex<_Ch_type, _Rx_traits>& __e, + regex_constants::match_flag_type __f + = regex_constants::match_default) + { return regex_search(__s, __s + _Rx_traits::length(__s), __m, __e, __f); } + + /** + * @brief Searches for a regular expression within a C-string. + * @param s [IN] The C-string to search. + * @param e [IN] The regular expression to search for. + * @param f [IN] Search policy flags. + * @retval true A match was found within the string. + * @retval false No match was found within the string. + * @doctodo + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_search(const _Ch_type* __s, + const basic_regex<_Ch_type, _Rx_traits>& __e, + regex_constants::match_flag_type __f + = regex_constants::match_default) + { return regex_search(__s, __s + _Rx_traits::length(__s), __e, __f); } + + /** + * @brief Searches for a regular expression within a string. + * @param s [IN] The string to search. + * @param e [IN] The regular expression to search for. + * @param flags [IN] Search policy flags. + * @retval true A match was found within the string. + * @retval false No match was found within the string. + * @doctodo + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_search(const basic_string<_Ch_type, _Ch_traits, + _String_allocator>& __s, + const basic_regex<_Ch_type, _Rx_traits>& __e, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { return regex_search(__s.begin(), __s.end(), __e, __flags); } + + /** + * @brief Searches for a regular expression within a string. + * @param s [IN] A C++ string to search for the regex. + * @param m [OUT] The set of regex matches. + * @param e [IN] The regex to search for in @p s. + * @param f [IN] The search flags. + * @retval true A match was found within the string. + * @retval false No match was found within the string, the content of %m is + * undefined. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_search(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s, + match_results::const_iterator, _Allocator>& __m, + const basic_regex<_Ch_type, _Rx_traits>& __e, + regex_constants::match_flag_type __f + = regex_constants::match_default) + { return regex_search(__s.begin(), __s.end(), __m, __e, __f); } + + // tr1 [7.11.4] std [28.11.4] Function template regex_replace + /** + * @doctodo + * @param out + * @param first + * @param last + * @param e + * @param fmt + * @param flags + * + * @returns out + * @throws an exception of type regex_error. + * + * @todo Implement this function. + */ + template + inline _Out_iter + regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last, + const basic_regex<_Ch_type, _Rx_traits>& __e, + const basic_string<_Ch_type>& __fmt, + regex_constants::match_flag_type __flags + = regex_constants::match_default); + + /** + * @doctodo + * @param s + * @param e + * @param fmt + * @param flags + * + * @returns a copy of string @p s with replacements. + * + * @throws an exception of type regex_error. + */ + template + inline basic_string<_Ch_type> + regex_replace(const basic_string<_Ch_type>& __s, + const basic_regex<_Ch_type, _Rx_traits>& __e, + const basic_string<_Ch_type>& __fmt, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { + std::string __result; + regex_replace(std::back_inserter(__result), + __s.begin(), __s.end(), __e, __fmt, __flags); + return __result; + } + + //@} + + // tr1 [7.12.1] std [28.12] Class template regex_iterator + /** + * An iterator adaptor that will provide repeated calls of regex_search over + * a range until no more matches remain. + */ + template::value_type, + typename _Rx_traits = regex_traits<_Ch_type> > + class regex_iterator + { + public: + typedef basic_regex<_Ch_type, _Rx_traits> regex_type; + typedef match_results<_Bi_iter> value_type; + typedef std::ptrdiff_t difference_type; + typedef const value_type* pointer; + typedef const value_type& reference; + typedef std::forward_iterator_tag iterator_category; + + public: + /** + * @brief Provides a singular iterator, useful for indicating + * one-past-the-end of a range. + * @todo Implement this function. + * @doctodo + */ + regex_iterator(); + + /** + * Constructs a %regex_iterator... + * @param a [IN] The start of a text range to search. + * @param b [IN] One-past-the-end of the text range to search. + * @param re [IN] The regular expression to match. + * @param m [IN] Policy flags for match rules. + * @todo Implement this function. + * @doctodo + */ + regex_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type& __re, + regex_constants::match_flag_type __m + = regex_constants::match_default); + + /** + * Copy constructs a %regex_iterator. + * @todo Implement this function. + * @doctodo + */ + regex_iterator(const regex_iterator& __rhs); + + /** + * @todo Implement this function. + * @doctodo + */ + regex_iterator& + operator=(const regex_iterator& __rhs); + + /** + * @todo Implement this function. + * @doctodo + */ + bool + operator==(const regex_iterator& __rhs); + + /** + * @todo Implement this function. + * @doctodo + */ + bool + operator!=(const regex_iterator& __rhs); + + /** + * @todo Implement this function. + * @doctodo + */ + const value_type& + operator*(); + + /** + * @todo Implement this function. + * @doctodo + */ + const value_type* + operator->(); + + /** + * @todo Implement this function. + * @doctodo + */ + regex_iterator& + operator++(); + + /** + * @todo Implement this function. + * @doctodo + */ + regex_iterator + operator++(int); + + private: + // these members are shown for exposition only: + _Bi_iter begin; + _Bi_iter end; + const regex_type* pregex; + regex_constants::match_flag_type flags; + match_results<_Bi_iter> match; + }; + + typedef regex_iterator cregex_iterator; + typedef regex_iterator sregex_iterator; +#ifdef _GLIBCXX_USE_WCHAR_T + typedef regex_iterator wcregex_iterator; + typedef regex_iterator wsregex_iterator; +#endif + + // [7.12.2] Class template regex_token_iterator + /** + * Iterates over submatches in a range (or @a splits a text string). + * + * The purpose of this iterator is to enumerate all, or all specified, + * matches of a regular expression within a text range. The dereferenced + * value of an iterator of this class is a std::tr1::sub_match object. + */ + template::value_type, + typename _Rx_traits = regex_traits<_Ch_type> > + class regex_token_iterator + { + public: + typedef basic_regex<_Ch_type, _Rx_traits> regex_type; + typedef sub_match<_Bi_iter> value_type; + typedef std::ptrdiff_t difference_type; + typedef const value_type* pointer; + typedef const value_type& reference; + typedef std::forward_iterator_tag iterator_category; + + public: + /** + * @brief Default constructs a %regex_token_iterator. + * @todo Implement this function. + * + * A default-constructed %regex_token_iterator is a singular iterator + * that will compare equal to the one-past-the-end value for any + * iterator of the same type. + */ + regex_token_iterator(); + + /** + * Constructs a %regex_token_iterator... + * @param a [IN] The start of the text to search. + * @param b [IN] One-past-the-end of the text to search. + * @param re [IN] The regular expression to search for. + * @param submatch [IN] Which submatch to return. There are some + * special values for this parameter: + * - -1 each enumerated subexpression does NOT + * match the regular expression (aka field + * splitting) + * - 0 the entire string matching the + * subexpression is returned for each match + * within the text. + * - >0 enumerates only the indicated + * subexpression from a match within the text. + * @param m [IN] Policy flags for match rules. + * + * @todo Implement this function. + * @doctodo + */ + regex_token_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type& __re, + int __submatch = 0, + regex_constants::match_flag_type __m + = regex_constants::match_default); + + /** + * Constructs a %regex_token_iterator... + * @param a [IN] The start of the text to search. + * @param b [IN] One-past-the-end of the text to search. + * @param re [IN] The regular expression to search for. + * @param submatches [IN] A list of subexpressions to return for each + * regular expression match within the text. + * @param m [IN] Policy flags for match rules. + * + * @todo Implement this function. + * @doctodo + */ + regex_token_iterator(_Bi_iter __a, _Bi_iter __b, + const regex_type& __re, + const std::vector& __submatches, + regex_constants::match_flag_type __m + = regex_constants::match_default); + + /** + * Constructs a %regex_token_iterator... + * @param a [IN] The start of the text to search. + * @param b [IN] One-past-the-end of the text to search. + * @param re [IN] The regular expression to search for. + * @param submatches [IN] A list of subexpressions to return for each + * regular expression match within the text. + * @param m [IN] Policy flags for match rules. + + * @todo Implement this function. + * @doctodo + */ + template + regex_token_iterator(_Bi_iter __a, _Bi_iter __b, + const regex_type& __re, + const int (&__submatches)[_Nm], + regex_constants::match_flag_type __m + = regex_constants::match_default); + + /** + * @brief Copy constructs a %regex_token_iterator. + * @param rhs [IN] A %regex_token_iterator to copy. + * @todo Implement this function. + */ + regex_token_iterator(const regex_token_iterator& __rhs); + + /** + * @brief Assigns a %regex_token_iterator to another. + * @param rhs [IN] A %regex_token_iterator to copy. + * @todo Implement this function. + */ + regex_token_iterator& + operator=(const regex_token_iterator& __rhs); + + /** + * @brief Compares a %regex_token_iterator to another for equality. + * @todo Implement this function. + */ + bool + operator==(const regex_token_iterator& __rhs); + + /** + * @brief Compares a %regex_token_iterator to another for inequality. + * @todo Implement this function. + */ + bool + operator!=(const regex_token_iterator& __rhs); + + /** + * @brief Dereferences a %regex_token_iterator. + * @todo Implement this function. + */ + const value_type& + operator*(); + + /** + * @brief Selects a %regex_token_iterator member. + * @todo Implement this function. + */ + const value_type* + operator->(); + + /** + * @brief Increments a %regex_token_iterator. + * @todo Implement this function. + */ + regex_token_iterator& + operator++(); + + /** + * @brief Postincrements a %regex_token_iterator. + * @todo Implement this function. + */ + regex_token_iterator + operator++(int); + + private: // data members for exposition only: + typedef regex_iterator<_Bi_iter, _Ch_type, _Rx_traits> position_iterator; + + position_iterator __position; + const value_type* __result; + value_type __suffix; + std::size_t __n; + std::vector __subs; + }; + + /** @brief Token iterator for C-style NULL-terminated strings. */ + typedef regex_token_iterator cregex_token_iterator; + /** @brief Token iterator for standard strings. */ + typedef regex_token_iterator sregex_token_iterator; +#ifdef _GLIBCXX_USE_WCHAR_T + /** @brief Token iterator for C-style NULL-terminated wide strings. */ + typedef regex_token_iterator wcregex_token_iterator; + /** @brief Token iterator for standard wide-character strings. */ + typedef regex_token_iterator wsregex_token_iterator; +#endif + + //@} + +_GLIBCXX_END_NAMESPACE_TR1 +} Index: cmath =================================================================== --- cmath (nonexistent) +++ cmath (revision 826) @@ -0,0 +1,902 @@ +// TR1 cmath -*- C++ -*- + +// 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 +// . + +/** @file tr1_impl/cmath + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + +#if _GLIBCXX_USE_C99_MATH_TR1 + +#undef acosh +#undef acoshf +#undef acoshl +#undef asinh +#undef asinhf +#undef asinhl +#undef atanh +#undef atanhf +#undef atanhl +#undef cbrt +#undef cbrtf +#undef cbrtl +#undef copysign +#undef copysignf +#undef copysignl +#undef erf +#undef erff +#undef erfl +#undef erfc +#undef erfcf +#undef erfcl +#undef exp2 +#undef exp2f +#undef exp2l +#undef expm1 +#undef expm1f +#undef expm1l +#undef fdim +#undef fdimf +#undef fdiml +#undef fma +#undef fmaf +#undef fmal +#undef fmax +#undef fmaxf +#undef fmaxl +#undef fmin +#undef fminf +#undef fminl +#undef hypot +#undef hypotf +#undef hypotl +#undef ilogb +#undef ilogbf +#undef ilogbl +#undef lgamma +#undef lgammaf +#undef lgammal +#undef llrint +#undef llrintf +#undef llrintl +#undef llround +#undef llroundf +#undef llroundl +#undef log1p +#undef log1pf +#undef log1pl +#undef log2 +#undef log2f +#undef log2l +#undef logb +#undef logbf +#undef logbl +#undef lrint +#undef lrintf +#undef lrintl +#undef lround +#undef lroundf +#undef lroundl +#undef nan +#undef nanf +#undef nanl +#undef nearbyint +#undef nearbyintf +#undef nearbyintl +#undef nextafter +#undef nextafterf +#undef nextafterl +#undef nexttoward +#undef nexttowardf +#undef nexttowardl +#undef remainder +#undef remainderf +#undef remainderl +#undef remquo +#undef remquof +#undef remquol +#undef rint +#undef rintf +#undef rintl +#undef round +#undef roundf +#undef roundl +#undef scalbln +#undef scalblnf +#undef scalblnl +#undef scalbn +#undef scalbnf +#undef scalbnl +#undef tgamma +#undef tgammaf +#undef tgammal +#undef trunc +#undef truncf +#undef truncl + +#endif + +namespace std +{ +_GLIBCXX_BEGIN_NAMESPACE_TR1 + +#if _GLIBCXX_USE_C99_MATH_TR1 + + // types + using ::double_t; + using ::float_t; + + // functions + using ::acosh; + using ::acoshf; + using ::acoshl; + + using ::asinh; + using ::asinhf; + using ::asinhl; + + using ::atanh; + using ::atanhf; + using ::atanhl; + + using ::cbrt; + using ::cbrtf; + using ::cbrtl; + + using ::copysign; + using ::copysignf; + using ::copysignl; + + using ::erf; + using ::erff; + using ::erfl; + + using ::erfc; + using ::erfcf; + using ::erfcl; + + using ::exp2; + using ::exp2f; + using ::exp2l; + + using ::expm1; + using ::expm1f; + using ::expm1l; + + using ::fdim; + using ::fdimf; + using ::fdiml; + + using ::fma; + using ::fmaf; + using ::fmal; + + using ::fmax; + using ::fmaxf; + using ::fmaxl; + + using ::fmin; + using ::fminf; + using ::fminl; + + using ::hypot; + using ::hypotf; + using ::hypotl; + + using ::ilogb; + using ::ilogbf; + using ::ilogbl; + + using ::lgamma; + using ::lgammaf; + using ::lgammal; + + using ::llrint; + using ::llrintf; + using ::llrintl; + + using ::llround; + using ::llroundf; + using ::llroundl; + + using ::log1p; + using ::log1pf; + using ::log1pl; + + using ::log2; + using ::log2f; + using ::log2l; + + using ::logb; + using ::logbf; + using ::logbl; + + using ::lrint; + using ::lrintf; + using ::lrintl; + + using ::lround; + using ::lroundf; + using ::lroundl; + + using ::nan; + using ::nanf; + using ::nanl; + + using ::nearbyint; + using ::nearbyintf; + using ::nearbyintl; + + using ::nextafter; + using ::nextafterf; + using ::nextafterl; + + using ::nexttoward; + using ::nexttowardf; + using ::nexttowardl; + + using ::remainder; + using ::remainderf; + using ::remainderl; + + using ::remquo; + using ::remquof; + using ::remquol; + + using ::rint; + using ::rintf; + using ::rintl; + + using ::round; + using ::roundf; + using ::roundl; + + using ::scalbln; + using ::scalblnf; + using ::scalblnl; + + using ::scalbn; + using ::scalbnf; + using ::scalbnl; + + using ::tgamma; + using ::tgammaf; + using ::tgammal; + + using ::trunc; + using ::truncf; + using ::truncl; + +#endif + +#if _GLIBCXX_USE_C99_MATH +#if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC + + /// Function template definitions [8.16.3]. + using std::signbit; + + using std::fpclassify; + + using std::isfinite; + using std::isinf; + using std::isnan; + using std::isnormal; + + using std::isgreater; + using std::isgreaterequal; + using std::isless; + using std::islessequal; + using std::islessgreater; + using std::isunordered; +#endif +#endif + +#if _GLIBCXX_USE_C99_MATH_TR1 + + /// Additional overloads [8.16.4]. + using std::acos; + + inline float + acosh(float __x) + { return __builtin_acoshf(__x); } + + inline long double + acosh(long double __x) + { return __builtin_acoshl(__x); } + + template + inline typename __gnu_cxx::__promote<_Tp>::__type + acosh(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return acosh(__type(__x)); + } + + using std::asin; + + inline float + asinh(float __x) + { return __builtin_asinhf(__x); } + + inline long double + asinh(long double __x) + { return __builtin_asinhl(__x); } + + template + inline typename __gnu_cxx::__promote<_Tp>::__type + asinh(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return asinh(__type(__x)); + } + + using std::atan; + using std::atan2; + + inline float + atanh(float __x) + { return __builtin_atanhf(__x); } + + inline long double + atanh(long double __x) + { return __builtin_atanhl(__x); } + + template + inline typename __gnu_cxx::__promote<_Tp>::__type + atanh(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return atanh(__type(__x)); + } + + inline float + cbrt(float __x) + { return __builtin_cbrtf(__x); } + + inline long double + cbrt(long double __x) + { return __builtin_cbrtl(__x); } + + template + inline typename __gnu_cxx::__promote<_Tp>::__type + cbrt(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return cbrt(__type(__x)); + } + + using std::ceil; + + inline float + copysign(float __x, float __y) + { return __builtin_copysignf(__x, __y); } + + inline long double + copysign(long double __x, long double __y) + { return __builtin_copysignl(__x, __y); } + + template + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + copysign(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return copysign(__type(__x), __type(__y)); + } + + using std::cos; + using std::cosh; + + inline float + erf(float __x) + { return __builtin_erff(__x); } + + inline long double + erf(long double __x) + { return __builtin_erfl(__x); } + + template + inline typename __gnu_cxx::__promote<_Tp>::__type + erf(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return erf(__type(__x)); + } + + inline float + erfc(float __x) + { return __builtin_erfcf(__x); } + + inline long double + erfc(long double __x) + { return __builtin_erfcl(__x); } + + template + inline typename __gnu_cxx::__promote<_Tp>::__type + erfc(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return erfc(__type(__x)); + } + + using std::exp; + + inline float + exp2(float __x) + { return __builtin_exp2f(__x); } + + inline long double + exp2(long double __x) + { return __builtin_exp2l(__x); } + + template + inline typename __gnu_cxx::__promote<_Tp>::__type + exp2(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return exp2(__type(__x)); + } + + inline float + expm1(float __x) + { return __builtin_expm1f(__x); } + + inline long double + expm1(long double __x) + { return __builtin_expm1l(__x); } + + template + inline typename __gnu_cxx::__promote<_Tp>::__type + expm1(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return expm1(__type(__x)); + } + + using std::fabs; + + inline float + fdim(float __x, float __y) + { return __builtin_fdimf(__x, __y); } + + inline long double + fdim(long double __x, long double __y) + { return __builtin_fdiml(__x, __y); } + + template + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + fdim(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return fdim(__type(__x), __type(__y)); + } + + using std::floor; + + inline float + fma(float __x, float __y, float __z) + { return __builtin_fmaf(__x, __y, __z); } + + inline long double + fma(long double __x, long double __y, long double __z) + { return __builtin_fmal(__x, __y, __z); } + + template + inline typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type + fma(_Tp __x, _Up __y, _Vp __z) + { + typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type; + return fma(__type(__x), __type(__y), __type(__z)); + } + + inline float + fmax(float __x, float __y) + { return __builtin_fmaxf(__x, __y); } + + inline long double + fmax(long double __x, long double __y) + { return __builtin_fmaxl(__x, __y); } + + template + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + fmax(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return fmax(__type(__x), __type(__y)); + } + + inline float + fmin(float __x, float __y) + { return __builtin_fminf(__x, __y); } + + inline long double + fmin(long double __x, long double __y) + { return __builtin_fminl(__x, __y); } + + template + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + fmin(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return fmin(__type(__x), __type(__y)); + } + + using std::fmod; + using std::frexp; + + inline float + hypot(float __x, float __y) + { return __builtin_hypotf(__x, __y); } + + inline long double + hypot(long double __x, long double __y) + { return __builtin_hypotl(__x, __y); } + + template + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + hypot(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return hypot(__type(__x), __type(__y)); + } + + inline int + ilogb(float __x) + { return __builtin_ilogbf(__x); } + + inline int + ilogb(long double __x) + { return __builtin_ilogbl(__x); } + + template + inline int + ilogb(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return ilogb(__type(__x)); + } + + using std::ldexp; + + inline float + lgamma(float __x) + { return __builtin_lgammaf(__x); } + + inline long double + lgamma(long double __x) + { return __builtin_lgammal(__x); } + + template + inline typename __gnu_cxx::__promote<_Tp>::__type + lgamma(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return lgamma(__type(__x)); + } + + inline long long + llrint(float __x) + { return __builtin_llrintf(__x); } + + inline long long + llrint(long double __x) + { return __builtin_llrintl(__x); } + + template + inline long long + llrint(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return llrint(__type(__x)); + } + + inline long long + llround(float __x) + { return __builtin_llroundf(__x); } + + inline long long + llround(long double __x) + { return __builtin_llroundl(__x); } + + template + inline long long + llround(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return llround(__type(__x)); + } + + using std::log; + using std::log10; + + inline float + log1p(float __x) + { return __builtin_log1pf(__x); } + + inline long double + log1p(long double __x) + { return __builtin_log1pl(__x); } + + template + inline typename __gnu_cxx::__promote<_Tp>::__type + log1p(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return log1p(__type(__x)); + } + + // DR 568. + inline float + log2(float __x) + { return __builtin_log2f(__x); } + + inline long double + log2(long double __x) + { return __builtin_log2l(__x); } + + template + inline typename __gnu_cxx::__promote<_Tp>::__type + log2(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return log2(__type(__x)); + } + + inline float + logb(float __x) + { return __builtin_logbf(__x); } + + inline long double + logb(long double __x) + { return __builtin_logbl(__x); } + + template + inline typename __gnu_cxx::__promote<_Tp>::__type + logb(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return logb(__type(__x)); + } + + inline long + lrint(float __x) + { return __builtin_lrintf(__x); } + + inline long + lrint(long double __x) + { return __builtin_lrintl(__x); } + + template + inline long + lrint(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return lrint(__type(__x)); + } + + inline long + lround(float __x) + { return __builtin_lroundf(__x); } + + inline long + lround(long double __x) + { return __builtin_lroundl(__x); } + + template + inline long + lround(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return lround(__type(__x)); + } + + inline float + nearbyint(float __x) + { return __builtin_nearbyintf(__x); } + + inline long double + nearbyint(long double __x) + { return __builtin_nearbyintl(__x); } + + template + inline typename __gnu_cxx::__promote<_Tp>::__type + nearbyint(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return nearbyint(__type(__x)); + } + + inline float + nextafter(float __x, float __y) + { return __builtin_nextafterf(__x, __y); } + + inline long double + nextafter(long double __x, long double __y) + { return __builtin_nextafterl(__x, __y); } + + template + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + nextafter(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return nextafter(__type(__x), __type(__y)); + } + + inline float + nexttoward(float __x, long double __y) + { return __builtin_nexttowardf(__x, __y); } + + inline long double + nexttoward(long double __x, long double __y) + { return __builtin_nexttowardl(__x, __y); } + + template + inline typename __gnu_cxx::__promote<_Tp>::__type + nexttoward(_Tp __x, long double __y) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return nexttoward(__type(__x), __y); + } + + // DR 550. What should the return type of pow(float,int) be? + // NB: C++0x and TR1 != C++03. + // using std::pow; + + inline float + remainder(float __x, float __y) + { return __builtin_remainderf(__x, __y); } + + inline long double + remainder(long double __x, long double __y) + { return __builtin_remainderl(__x, __y); } + + template + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + remainder(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return remainder(__type(__x), __type(__y)); + } + + inline float + remquo(float __x, float __y, int* __pquo) + { return __builtin_remquof(__x, __y, __pquo); } + + inline long double + remquo(long double __x, long double __y, int* __pquo) + { return __builtin_remquol(__x, __y, __pquo); } + + template + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + remquo(_Tp __x, _Up __y, int* __pquo) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return remquo(__type(__x), __type(__y), __pquo); + } + + inline float + rint(float __x) + { return __builtin_rintf(__x); } + + inline long double + rint(long double __x) + { return __builtin_rintl(__x); } + + template + inline typename __gnu_cxx::__promote<_Tp>::__type + rint(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return rint(__type(__x)); + } + + inline float + round(float __x) + { return __builtin_roundf(__x); } + + inline long double + round(long double __x) + { return __builtin_roundl(__x); } + + template + inline typename __gnu_cxx::__promote<_Tp>::__type + round(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return round(__type(__x)); + } + + inline float + scalbln(float __x, long __ex) + { return __builtin_scalblnf(__x, __ex); } + + inline long double + scalbln(long double __x, long __ex) + { return __builtin_scalblnl(__x, __ex); } + + template + inline typename __gnu_cxx::__promote<_Tp>::__type + scalbln(_Tp __x, long __ex) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return scalbln(__type(__x), __ex); + } + + inline float + scalbn(float __x, int __ex) + { return __builtin_scalbnf(__x, __ex); } + + inline long double + scalbn(long double __x, int __ex) + { return __builtin_scalbnl(__x, __ex); } + + template + inline typename __gnu_cxx::__promote<_Tp>::__type + scalbn(_Tp __x, int __ex) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return scalbn(__type(__x), __ex); + } + + using std::sin; + using std::sinh; + using std::sqrt; + using std::tan; + using std::tanh; + + inline float + tgamma(float __x) + { return __builtin_tgammaf(__x); } + + inline long double + tgamma(long double __x) + { return __builtin_tgammal(__x); } + + template + inline typename __gnu_cxx::__promote<_Tp>::__type + tgamma(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return tgamma(__type(__x)); + } + + inline float + trunc(float __x) + { return __builtin_truncf(__x); } + + inline long double + trunc(long double __x) + { return __builtin_truncl(__x); } + + template + inline typename __gnu_cxx::__promote<_Tp>::__type + trunc(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return trunc(__type(__x)); + } + +#endif + +_GLIBCXX_END_NAMESPACE_TR1 +} Index: array =================================================================== --- array (nonexistent) +++ array (revision 826) @@ -0,0 +1,291 @@ +// class template array -*- C++ -*- + +// Copyright (C) 2007, 2008, 2009, 2010 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 +// . + +/** @file tr1_impl/array + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + +namespace std +{ +_GLIBCXX_BEGIN_NAMESPACE_TR1 + + /** + * @brief A standard container for storing a fixed size sequence of elements. + * + * @ingroup sequences + * + * Meets the requirements of a container, a + * reversible container, and a + * sequence. + * + * Sets support random access iterators. + * + * @param Tp Type of element. Required to be a complete type. + * @param N Number of elements. + */ + template + struct array + { + typedef _Tp value_type; +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + typedef _Tp* pointer; + typedef const _Tp* const_pointer; +#endif + typedef value_type& reference; + typedef const value_type& const_reference; + typedef value_type* iterator; + typedef const value_type* const_iterator; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + + // Support for zero-sized arrays mandatory. + value_type _M_instance[_Nm ? _Nm : 1]; + + // No explicit construct/copy/destroy for aggregate type. + + void +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + // DR 776. + fill(const value_type& __u) +#else + assign(const value_type& __u) +#endif + { std::fill_n(begin(), size(), __u); } + + void + swap(array& __other) + { std::swap_ranges(begin(), end(), __other.begin()); } + + // Iterators. + iterator + begin() + { return iterator(&_M_instance[0]); } + + const_iterator + begin() const + { return const_iterator(&_M_instance[0]); } + + iterator + end() + { return iterator(&_M_instance[_Nm]); } + + const_iterator + end() const + { return const_iterator(&_M_instance[_Nm]); } + + reverse_iterator + rbegin() + { return reverse_iterator(end()); } + + const_reverse_iterator + rbegin() const + { return const_reverse_iterator(end()); } + + reverse_iterator + rend() + { return reverse_iterator(begin()); } + + const_reverse_iterator + rend() const + { return const_reverse_iterator(begin()); } + +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + const_iterator + cbegin() const + { return const_iterator(&_M_instance[0]); } + + const_iterator + cend() const + { return const_iterator(&_M_instance[_Nm]); } + + const_reverse_iterator + crbegin() const + { return const_reverse_iterator(end()); } + + const_reverse_iterator + crend() const + { return const_reverse_iterator(begin()); } +#endif + + // Capacity. + size_type + size() const { return _Nm; } + + size_type + max_size() const { return _Nm; } + + bool + empty() const { return size() == 0; } + + // Element access. + reference + operator[](size_type __n) + { return _M_instance[__n]; } + + const_reference + operator[](size_type __n) const + { return _M_instance[__n]; } + + reference + at(size_type __n) + { + if (__n >= _Nm) + std::__throw_out_of_range(__N("array::at")); + return _M_instance[__n]; + } + + const_reference + at(size_type __n) const + { + if (__n >= _Nm) + std::__throw_out_of_range(__N("array::at")); + return _M_instance[__n]; + } + + reference + front() + { return *begin(); } + + const_reference + front() const + { return *begin(); } + + reference + back() + { return _Nm ? *(end() - 1) : *end(); } + + const_reference + back() const + { return _Nm ? *(end() - 1) : *end(); } + + _Tp* + data() + { return &_M_instance[0]; } + + const _Tp* + data() const + { return &_M_instance[0]; } + }; + + // Array comparisons. + template + inline bool + operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return std::equal(__one.begin(), __one.end(), __two.begin()); } + + template + inline bool + operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return !(__one == __two); } + + template + inline bool + operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b) + { + return std::lexicographical_compare(__a.begin(), __a.end(), + __b.begin(), __b.end()); + } + + template + inline bool + operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return __two < __one; } + + template + inline bool + operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return !(__one > __two); } + + template + inline bool + operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return !(__one < __two); } + + // Specialized algorithms [6.2.2.2]. + template + inline void + swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two) + { __one.swap(__two); } + + // Tuple interface to class template array [6.2.2.5]. + + /// tuple_size + template + class tuple_size; + + /// tuple_element +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + template +#else + template +#endif + class tuple_element; + + template + struct tuple_size > +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + { static const std::size_t value = _Nm; }; +#else + { static const int value = _Nm; }; +#endif + + template +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + const std::size_t +#else + const int +#endif + tuple_size >::value; + +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + template +#else + template +#endif + struct tuple_element<_Int, array<_Tp, _Nm> > + { typedef _Tp type; }; + +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + template +#else + template +#endif + inline _Tp& + get(array<_Tp, _Nm>& __arr) + { return __arr[_Int]; } + +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + template +#else + template +#endif + inline const _Tp& + get(const array<_Tp, _Nm>& __arr) + { return __arr[_Int]; } + +_GLIBCXX_END_NAMESPACE_TR1 +} Index: cwctype =================================================================== --- cwctype (nonexistent) +++ cwctype (revision 826) @@ -0,0 +1,43 @@ +// TR1 cwctype -*- C++ -*- + +// 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 +// . + +/** @file tr1_impl/cwctype + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + +#if _GLIBCXX_USE_WCHAR_T + +namespace std +{ +_GLIBCXX_BEGIN_NAMESPACE_TR1 + +#if _GLIBCXX_HAVE_ISWBLANK + using std::iswblank; +#endif + +_GLIBCXX_END_NAMESPACE_TR1 +} + +#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.