[SCM] FreeFem++ packaging branch, master, updated. debian/3.13-1-5-gd183d0f
Dimitrios Eftaxiopoulos
eftaxi12 at otenet.gr
Thu Jun 2 11:53:58 UTC 2011
The following commit has been merged in the master branch:
commit d183d0f3c1accaffe099dd0e82354099e868badb
Author: Dimitrios Eftaxiopoulos <eftaxi12 at otenet.gr>
Date: Thu Jun 2 14:53:45 2011 +0300
Remove debian/array_long.ii
diff --git a/debian/array_long.ii b/debian/array_long.ii
deleted file mode 100644
index b200881..0000000
--- a/debian/array_long.ii
+++ /dev/null
@@ -1,33354 +0,0 @@
-namespace std
-{
- typedef long unsigned int size_t;
- typedef long int ptrdiff_t;
-}
-namespace __gnu_cxx __attribute__ ((__visibility__ ("default")))
-{
- template<typename _Iterator, typename _Container>
- class __normal_iterator;
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- struct __true_type { };
- struct __false_type { };
- template<bool>
- struct __truth_type
- { typedef __false_type __type; };
- template<>
- struct __truth_type<true>
- { typedef __true_type __type; };
- template<class _Sp, class _Tp>
- struct __traitor
- {
- enum { __value = bool(_Sp::__value) || bool(_Tp::__value) };
- typedef typename __truth_type<__value>::__type __type;
- };
- template<typename, typename>
- struct __are_same
- {
- enum { __value = 0 };
- typedef __false_type __type;
- };
- template<typename _Tp>
- struct __are_same<_Tp, _Tp>
- {
- enum { __value = 1 };
- typedef __true_type __type;
- };
- template<typename _Tp>
- struct __is_void
- {
- enum { __value = 0 };
- typedef __false_type __type;
- };
- template<>
- struct __is_void<void>
- {
- enum { __value = 1 };
- typedef __true_type __type;
- };
- template<typename _Tp>
- struct __is_integer
- {
- enum { __value = 0 };
- typedef __false_type __type;
- };
- template<>
- struct __is_integer<bool>
- {
- enum { __value = 1 };
- typedef __true_type __type;
- };
- template<>
- struct __is_integer<char>
- {
- enum { __value = 1 };
- typedef __true_type __type;
- };
- template<>
- struct __is_integer<signed char>
- {
- enum { __value = 1 };
- typedef __true_type __type;
- };
- template<>
- struct __is_integer<unsigned char>
- {
- enum { __value = 1 };
- typedef __true_type __type;
- };
- template<>
- struct __is_integer<wchar_t>
- {
- enum { __value = 1 };
- typedef __true_type __type;
- };
- template<>
- struct __is_integer<short>
- {
- enum { __value = 1 };
- typedef __true_type __type;
- };
- template<>
- struct __is_integer<unsigned short>
- {
- enum { __value = 1 };
- typedef __true_type __type;
- };
- template<>
- struct __is_integer<int>
- {
- enum { __value = 1 };
- typedef __true_type __type;
- };
- template<>
- struct __is_integer<unsigned int>
- {
- enum { __value = 1 };
- typedef __true_type __type;
- };
- template<>
- struct __is_integer<long>
- {
- enum { __value = 1 };
- typedef __true_type __type;
- };
- template<>
- struct __is_integer<unsigned long>
- {
- enum { __value = 1 };
- typedef __true_type __type;
- };
- template<>
- struct __is_integer<long long>
- {
- enum { __value = 1 };
- typedef __true_type __type;
- };
- template<>
- struct __is_integer<unsigned long long>
- {
- enum { __value = 1 };
- typedef __true_type __type;
- };
- template<typename _Tp>
- struct __is_floating
- {
- enum { __value = 0 };
- typedef __false_type __type;
- };
- template<>
- struct __is_floating<float>
- {
- enum { __value = 1 };
- typedef __true_type __type;
- };
- template<>
- struct __is_floating<double>
- {
- enum { __value = 1 };
- typedef __true_type __type;
- };
- template<>
- struct __is_floating<long double>
- {
- enum { __value = 1 };
- typedef __true_type __type;
- };
- template<typename _Tp>
- struct __is_pointer
- {
- enum { __value = 0 };
- typedef __false_type __type;
- };
- template<typename _Tp>
- struct __is_pointer<_Tp*>
- {
- enum { __value = 1 };
- typedef __true_type __type;
- };
- template<typename _Tp>
- struct __is_normal_iterator
- {
- enum { __value = 0 };
- typedef __false_type __type;
- };
- template<typename _Iterator, typename _Container>
- struct __is_normal_iterator< __gnu_cxx::__normal_iterator<_Iterator,
- _Container> >
- {
- enum { __value = 1 };
- typedef __true_type __type;
- };
- template<typename _Tp>
- struct __is_arithmetic
- : public __traitor<__is_integer<_Tp>, __is_floating<_Tp> >
- { };
- template<typename _Tp>
- struct __is_fundamental
- : public __traitor<__is_void<_Tp>, __is_arithmetic<_Tp> >
- { };
- template<typename _Tp>
- struct __is_scalar
- : public __traitor<__is_arithmetic<_Tp>, __is_pointer<_Tp> >
- { };
- template<typename _Tp>
- struct __is_char
- {
- enum { __value = 0 };
- typedef __false_type __type;
- };
- template<>
- struct __is_char<char>
- {
- enum { __value = 1 };
- typedef __true_type __type;
- };
- template<>
- struct __is_char<wchar_t>
- {
- enum { __value = 1 };
- typedef __true_type __type;
- };
- template<typename _Tp>
- struct __is_byte
- {
- enum { __value = 0 };
- typedef __false_type __type;
- };
- template<>
- struct __is_byte<char>
- {
- enum { __value = 1 };
- typedef __true_type __type;
- };
- template<>
- struct __is_byte<signed char>
- {
- enum { __value = 1 };
- typedef __true_type __type;
- };
- template<>
- struct __is_byte<unsigned char>
- {
- enum { __value = 1 };
- typedef __true_type __type;
- };
- template<typename _Tp>
- struct __is_move_iterator
- {
- enum { __value = 0 };
- typedef __false_type __type;
- };
-}
-namespace __gnu_cxx __attribute__ ((__visibility__ ("default")))
-{
- template<bool, typename>
- struct __enable_if
- { };
- template<typename _Tp>
- struct __enable_if<true, _Tp>
- { typedef _Tp __type; };
- template<bool _Cond, typename _Iftrue, typename _Iffalse>
- struct __conditional_type
- { typedef _Iftrue __type; };
- template<typename _Iftrue, typename _Iffalse>
- struct __conditional_type<false, _Iftrue, _Iffalse>
- { typedef _Iffalse __type; };
- template<typename _Tp>
- struct __add_unsigned
- {
- private:
- typedef __enable_if<std::__is_integer<_Tp>::__value, _Tp> __if_type;
- public:
- typedef typename __if_type::__type __type;
- };
- template<>
- struct __add_unsigned<char>
- { typedef unsigned char __type; };
- template<>
- struct __add_unsigned<signed char>
- { typedef unsigned char __type; };
- template<>
- struct __add_unsigned<short>
- { typedef unsigned short __type; };
- template<>
- struct __add_unsigned<int>
- { typedef unsigned int __type; };
- template<>
- struct __add_unsigned<long>
- { typedef unsigned long __type; };
- template<>
- struct __add_unsigned<long long>
- { typedef unsigned long long __type; };
- template<>
- struct __add_unsigned<bool>;
- template<>
- struct __add_unsigned<wchar_t>;
- template<typename _Tp>
- struct __remove_unsigned
- {
- private:
- typedef __enable_if<std::__is_integer<_Tp>::__value, _Tp> __if_type;
- public:
- typedef typename __if_type::__type __type;
- };
- template<>
- struct __remove_unsigned<char>
- { typedef signed char __type; };
- template<>
- struct __remove_unsigned<unsigned char>
- { typedef signed char __type; };
- template<>
- struct __remove_unsigned<unsigned short>
- { typedef short __type; };
- template<>
- struct __remove_unsigned<unsigned int>
- { typedef int __type; };
- template<>
- struct __remove_unsigned<unsigned long>
- { typedef long __type; };
- template<>
- struct __remove_unsigned<unsigned long long>
- { typedef long long __type; };
- template<>
- struct __remove_unsigned<bool>;
- template<>
- struct __remove_unsigned<wchar_t>;
- template<typename _Type>
- inline bool
- __is_null_pointer(_Type* __ptr)
- { return __ptr == 0; }
- template<typename _Type>
- inline bool
- __is_null_pointer(_Type)
- { return false; }
- template<typename _Tp, bool = std::__is_integer<_Tp>::__value>
- struct __promote
- { typedef double __type; };
- template<typename _Tp>
- struct __promote<_Tp, false>
- { typedef _Tp __type; };
- template<typename _Tp, typename _Up>
- struct __promote_2
- {
- private:
- typedef typename __promote<_Tp>::__type __type1;
- typedef typename __promote<_Up>::__type __type2;
- public:
- typedef __typeof__(__type1() + __type2()) __type;
- };
- template<typename _Tp, typename _Up, typename _Vp>
- struct __promote_3
- {
- private:
- typedef typename __promote<_Tp>::__type __type1;
- typedef typename __promote<_Up>::__type __type2;
- typedef typename __promote<_Vp>::__type __type3;
- public:
- typedef __typeof__(__type1() + __type2() + __type3()) __type;
- };
- template<typename _Tp, typename _Up, typename _Vp, typename _Wp>
- struct __promote_4
- {
- private:
- typedef typename __promote<_Tp>::__type __type1;
- typedef typename __promote<_Up>::__type __type2;
- typedef typename __promote<_Vp>::__type __type3;
- typedef typename __promote<_Wp>::__type __type4;
- public:
- typedef __typeof__(__type1() + __type2() + __type3() + __type4()) __type;
- };
-}
-extern "C" {
-typedef float float_t;
-typedef double double_t;
-extern double acos (double __x) throw (); extern double __acos (double __x) throw ();
-extern double asin (double __x) throw (); extern double __asin (double __x) throw ();
-extern double atan (double __x) throw (); extern double __atan (double __x) throw ();
-extern double atan2 (double __y, double __x) throw (); extern double __atan2 (double __y, double __x) throw ();
-extern double cos (double __x) throw (); extern double __cos (double __x) throw ();
-extern double sin (double __x) throw (); extern double __sin (double __x) throw ();
-extern double tan (double __x) throw (); extern double __tan (double __x) throw ();
-extern double cosh (double __x) throw (); extern double __cosh (double __x) throw ();
-extern double sinh (double __x) throw (); extern double __sinh (double __x) throw ();
-extern double tanh (double __x) throw (); extern double __tanh (double __x) throw ();
-extern void sincos (double __x, double *__sinx, double *__cosx) throw (); extern void __sincos (double __x, double *__sinx, double *__cosx) throw ()
- ;
-extern double acosh (double __x) throw (); extern double __acosh (double __x) throw ();
-extern double asinh (double __x) throw (); extern double __asinh (double __x) throw ();
-extern double atanh (double __x) throw (); extern double __atanh (double __x) throw ();
-extern double exp (double __x) throw (); extern double __exp (double __x) throw ();
-extern double frexp (double __x, int *__exponent) throw (); extern double __frexp (double __x, int *__exponent) throw ();
-extern double ldexp (double __x, int __exponent) throw (); extern double __ldexp (double __x, int __exponent) throw ();
-extern double log (double __x) throw (); extern double __log (double __x) throw ();
-extern double log10 (double __x) throw (); extern double __log10 (double __x) throw ();
-extern double modf (double __x, double *__iptr) throw (); extern double __modf (double __x, double *__iptr) throw ();
-extern double exp10 (double __x) throw (); extern double __exp10 (double __x) throw ();
-extern double pow10 (double __x) throw (); extern double __pow10 (double __x) throw ();
-extern double expm1 (double __x) throw (); extern double __expm1 (double __x) throw ();
-extern double log1p (double __x) throw (); extern double __log1p (double __x) throw ();
-extern double logb (double __x) throw (); extern double __logb (double __x) throw ();
-extern double exp2 (double __x) throw (); extern double __exp2 (double __x) throw ();
-extern double log2 (double __x) throw (); extern double __log2 (double __x) throw ();
-extern double pow (double __x, double __y) throw (); extern double __pow (double __x, double __y) throw ();
-extern double sqrt (double __x) throw (); extern double __sqrt (double __x) throw ();
-extern double hypot (double __x, double __y) throw (); extern double __hypot (double __x, double __y) throw ();
-extern double cbrt (double __x) throw (); extern double __cbrt (double __x) throw ();
-extern double ceil (double __x) throw () __attribute__ ((__const__)); extern double __ceil (double __x) throw () __attribute__ ((__const__));
-extern double fabs (double __x) throw () __attribute__ ((__const__)); extern double __fabs (double __x) throw () __attribute__ ((__const__));
-extern double floor (double __x) throw () __attribute__ ((__const__)); extern double __floor (double __x) throw () __attribute__ ((__const__));
-extern double fmod (double __x, double __y) throw (); extern double __fmod (double __x, double __y) throw ();
-extern int __isinf (double __value) throw () __attribute__ ((__const__));
-extern int __finite (double __value) throw () __attribute__ ((__const__));
-extern int isinf (double __value) throw () __attribute__ ((__const__));
-extern int finite (double __value) throw () __attribute__ ((__const__));
-extern double drem (double __x, double __y) throw (); extern double __drem (double __x, double __y) throw ();
-extern double significand (double __x) throw (); extern double __significand (double __x) throw ();
-extern double copysign (double __x, double __y) throw () __attribute__ ((__const__)); extern double __copysign (double __x, double __y) throw () __attribute__ ((__const__));
-extern double nan (__const char *__tagb) throw () __attribute__ ((__const__)); extern double __nan (__const char *__tagb) throw () __attribute__ ((__const__));
-extern int __isnan (double __value) throw () __attribute__ ((__const__));
-extern int isnan (double __value) throw () __attribute__ ((__const__));
-extern double j0 (double) throw (); extern double __j0 (double) throw ();
-extern double j1 (double) throw (); extern double __j1 (double) throw ();
-extern double jn (int, double) throw (); extern double __jn (int, double) throw ();
-extern double y0 (double) throw (); extern double __y0 (double) throw ();
-extern double y1 (double) throw (); extern double __y1 (double) throw ();
-extern double yn (int, double) throw (); extern double __yn (int, double) throw ();
-extern double erf (double) throw (); extern double __erf (double) throw ();
-extern double erfc (double) throw (); extern double __erfc (double) throw ();
-extern double lgamma (double) throw (); extern double __lgamma (double) throw ();
-extern double tgamma (double) throw (); extern double __tgamma (double) throw ();
-extern double gamma (double) throw (); extern double __gamma (double) throw ();
-extern double lgamma_r (double, int *__signgamp) throw (); extern double __lgamma_r (double, int *__signgamp) throw ();
-extern double rint (double __x) throw (); extern double __rint (double __x) throw ();
-extern double nextafter (double __x, double __y) throw () __attribute__ ((__const__)); extern double __nextafter (double __x, double __y) throw () __attribute__ ((__const__));
-extern double nexttoward (double __x, long double __y) throw () __attribute__ ((__const__)); extern double __nexttoward (double __x, long double __y) throw () __attribute__ ((__const__));
-extern double remainder (double __x, double __y) throw (); extern double __remainder (double __x, double __y) throw ();
-extern double scalbn (double __x, int __n) throw (); extern double __scalbn (double __x, int __n) throw ();
-extern int ilogb (double __x) throw (); extern int __ilogb (double __x) throw ();
-extern double scalbln (double __x, long int __n) throw (); extern double __scalbln (double __x, long int __n) throw ();
-extern double nearbyint (double __x) throw (); extern double __nearbyint (double __x) throw ();
-extern double round (double __x) throw () __attribute__ ((__const__)); extern double __round (double __x) throw () __attribute__ ((__const__));
-extern double trunc (double __x) throw () __attribute__ ((__const__)); extern double __trunc (double __x) throw () __attribute__ ((__const__));
-extern double remquo (double __x, double __y, int *__quo) throw (); extern double __remquo (double __x, double __y, int *__quo) throw ();
-extern long int lrint (double __x) throw (); extern long int __lrint (double __x) throw ();
-extern long long int llrint (double __x) throw (); extern long long int __llrint (double __x) throw ();
-extern long int lround (double __x) throw (); extern long int __lround (double __x) throw ();
-extern long long int llround (double __x) throw (); extern long long int __llround (double __x) throw ();
-extern double fdim (double __x, double __y) throw (); extern double __fdim (double __x, double __y) throw ();
-extern double fmax (double __x, double __y) throw (); extern double __fmax (double __x, double __y) throw ();
-extern double fmin (double __x, double __y) throw (); extern double __fmin (double __x, double __y) throw ();
-extern int __fpclassify (double __value) throw ()
- __attribute__ ((__const__));
-extern int __signbit (double __value) throw ()
- __attribute__ ((__const__));
-extern double fma (double __x, double __y, double __z) throw (); extern double __fma (double __x, double __y, double __z) throw ();
-extern double scalb (double __x, double __n) throw (); extern double __scalb (double __x, double __n) throw ();
-extern float acosf (float __x) throw (); extern float __acosf (float __x) throw ();
-extern float asinf (float __x) throw (); extern float __asinf (float __x) throw ();
-extern float atanf (float __x) throw (); extern float __atanf (float __x) throw ();
-extern float atan2f (float __y, float __x) throw (); extern float __atan2f (float __y, float __x) throw ();
-extern float cosf (float __x) throw (); extern float __cosf (float __x) throw ();
-extern float sinf (float __x) throw (); extern float __sinf (float __x) throw ();
-extern float tanf (float __x) throw (); extern float __tanf (float __x) throw ();
-extern float coshf (float __x) throw (); extern float __coshf (float __x) throw ();
-extern float sinhf (float __x) throw (); extern float __sinhf (float __x) throw ();
-extern float tanhf (float __x) throw (); extern float __tanhf (float __x) throw ();
-extern void
- sincosf
- (float __x, float *__sinx, float *__cosx) throw (); extern void
- __sincosf
- (float __x, float *__sinx, float *__cosx) throw ()
- ;
-extern float acoshf (float __x) throw (); extern float __acoshf (float __x) throw ();
-extern float asinhf (float __x) throw (); extern float __asinhf (float __x) throw ();
-extern float atanhf (float __x) throw (); extern float __atanhf (float __x) throw ();
-extern float expf (float __x) throw (); extern float __expf (float __x) throw ();
-extern float frexpf (float __x, int *__exponent) throw (); extern float __frexpf (float __x, int *__exponent) throw ();
-extern float ldexpf (float __x, int __exponent) throw (); extern float __ldexpf (float __x, int __exponent) throw ();
-extern float logf (float __x) throw (); extern float __logf (float __x) throw ();
-extern float log10f (float __x) throw (); extern float __log10f (float __x) throw ();
-extern float modff (float __x, float *__iptr) throw (); extern float __modff (float __x, float *__iptr) throw ();
-extern float exp10f (float __x) throw (); extern float __exp10f (float __x) throw ();
-extern float pow10f (float __x) throw (); extern float __pow10f (float __x) throw ();
-extern float expm1f (float __x) throw (); extern float __expm1f (float __x) throw ();
-extern float log1pf (float __x) throw (); extern float __log1pf (float __x) throw ();
-extern float logbf (float __x) throw (); extern float __logbf (float __x) throw ();
-extern float exp2f (float __x) throw (); extern float __exp2f (float __x) throw ();
-extern float log2f (float __x) throw (); extern float __log2f (float __x) throw ();
-extern float powf (float __x, float __y) throw (); extern float __powf (float __x, float __y) throw ();
-extern float sqrtf (float __x) throw (); extern float __sqrtf (float __x) throw ();
-extern float hypotf (float __x, float __y) throw (); extern float __hypotf (float __x, float __y) throw ();
-extern float cbrtf (float __x) throw (); extern float __cbrtf (float __x) throw ();
-extern float ceilf (float __x) throw () __attribute__ ((__const__)); extern float __ceilf (float __x) throw () __attribute__ ((__const__));
-extern float fabsf (float __x) throw () __attribute__ ((__const__)); extern float __fabsf (float __x) throw () __attribute__ ((__const__));
-extern float floorf (float __x) throw () __attribute__ ((__const__)); extern float __floorf (float __x) throw () __attribute__ ((__const__));
-extern float fmodf (float __x, float __y) throw (); extern float __fmodf (float __x, float __y) throw ();
-extern int __isinff (float __value) throw () __attribute__ ((__const__));
-extern int __finitef (float __value) throw () __attribute__ ((__const__));
-extern int isinff (float __value) throw () __attribute__ ((__const__));
-extern int finitef (float __value) throw () __attribute__ ((__const__));
-extern float dremf (float __x, float __y) throw (); extern float __dremf (float __x, float __y) throw ();
-extern float significandf (float __x) throw (); extern float __significandf (float __x) throw ();
-extern float copysignf (float __x, float __y) throw () __attribute__ ((__const__)); extern float __copysignf (float __x, float __y) throw () __attribute__ ((__const__));
-extern float nanf (__const char *__tagb) throw () __attribute__ ((__const__)); extern float __nanf (__const char *__tagb) throw () __attribute__ ((__const__));
-extern int __isnanf (float __value) throw () __attribute__ ((__const__));
-extern int isnanf (float __value) throw () __attribute__ ((__const__));
-extern float j0f (float) throw (); extern float __j0f (float) throw ();
-extern float j1f (float) throw (); extern float __j1f (float) throw ();
-extern float jnf (int, float) throw (); extern float __jnf (int, float) throw ();
-extern float y0f (float) throw (); extern float __y0f (float) throw ();
-extern float y1f (float) throw (); extern float __y1f (float) throw ();
-extern float ynf (int, float) throw (); extern float __ynf (int, float) throw ();
-extern float erff (float) throw (); extern float __erff (float) throw ();
-extern float erfcf (float) throw (); extern float __erfcf (float) throw ();
-extern float lgammaf (float) throw (); extern float __lgammaf (float) throw ();
-extern float tgammaf (float) throw (); extern float __tgammaf (float) throw ();
-extern float gammaf (float) throw (); extern float __gammaf (float) throw ();
-extern float lgammaf_r (float, int *__signgamp) throw (); extern float __lgammaf_r (float, int *__signgamp) throw ();
-extern float rintf (float __x) throw (); extern float __rintf (float __x) throw ();
-extern float nextafterf (float __x, float __y) throw () __attribute__ ((__const__)); extern float __nextafterf (float __x, float __y) throw () __attribute__ ((__const__));
-extern float nexttowardf (float __x, long double __y) throw () __attribute__ ((__const__)); extern float __nexttowardf (float __x, long double __y) throw () __attribute__ ((__const__));
-extern float remainderf (float __x, float __y) throw (); extern float __remainderf (float __x, float __y) throw ();
-extern float scalbnf (float __x, int __n) throw (); extern float __scalbnf (float __x, int __n) throw ();
-extern int ilogbf (float __x) throw (); extern int __ilogbf (float __x) throw ();
-extern float scalblnf (float __x, long int __n) throw (); extern float __scalblnf (float __x, long int __n) throw ();
-extern float nearbyintf (float __x) throw (); extern float __nearbyintf (float __x) throw ();
-extern float roundf (float __x) throw () __attribute__ ((__const__)); extern float __roundf (float __x) throw () __attribute__ ((__const__));
-extern float truncf (float __x) throw () __attribute__ ((__const__)); extern float __truncf (float __x) throw () __attribute__ ((__const__));
-extern float remquof (float __x, float __y, int *__quo) throw (); extern float __remquof (float __x, float __y, int *__quo) throw ();
-extern long int lrintf (float __x) throw (); extern long int __lrintf (float __x) throw ();
-extern long long int llrintf (float __x) throw (); extern long long int __llrintf (float __x) throw ();
-extern long int lroundf (float __x) throw (); extern long int __lroundf (float __x) throw ();
-extern long long int llroundf (float __x) throw (); extern long long int __llroundf (float __x) throw ();
-extern float fdimf (float __x, float __y) throw (); extern float __fdimf (float __x, float __y) throw ();
-extern float fmaxf (float __x, float __y) throw (); extern float __fmaxf (float __x, float __y) throw ();
-extern float fminf (float __x, float __y) throw (); extern float __fminf (float __x, float __y) throw ();
-extern int __fpclassifyf (float __value) throw ()
- __attribute__ ((__const__));
-extern int __signbitf (float __value) throw ()
- __attribute__ ((__const__));
-extern float fmaf (float __x, float __y, float __z) throw (); extern float __fmaf (float __x, float __y, float __z) throw ();
-extern float scalbf (float __x, float __n) throw (); extern float __scalbf (float __x, float __n) throw ();
-extern long double acosl (long double __x) throw (); extern long double __acosl (long double __x) throw ();
-extern long double asinl (long double __x) throw (); extern long double __asinl (long double __x) throw ();
-extern long double atanl (long double __x) throw (); extern long double __atanl (long double __x) throw ();
-extern long double atan2l (long double __y, long double __x) throw (); extern long double __atan2l (long double __y, long double __x) throw ();
-extern long double cosl (long double __x) throw (); extern long double __cosl (long double __x) throw ();
-extern long double sinl (long double __x) throw (); extern long double __sinl (long double __x) throw ();
-extern long double tanl (long double __x) throw (); extern long double __tanl (long double __x) throw ();
-extern long double coshl (long double __x) throw (); extern long double __coshl (long double __x) throw ();
-extern long double sinhl (long double __x) throw (); extern long double __sinhl (long double __x) throw ();
-extern long double tanhl (long double __x) throw (); extern long double __tanhl (long double __x) throw ();
-extern void
- sincosl
- (long double __x, long double *__sinx, long double *__cosx) throw (); extern void
- __sincosl
- (long double __x, long double *__sinx, long double *__cosx) throw ()
- ;
-extern long double acoshl (long double __x) throw (); extern long double __acoshl (long double __x) throw ();
-extern long double asinhl (long double __x) throw (); extern long double __asinhl (long double __x) throw ();
-extern long double atanhl (long double __x) throw (); extern long double __atanhl (long double __x) throw ();
-extern long double expl (long double __x) throw (); extern long double __expl (long double __x) throw ();
-extern long double frexpl (long double __x, int *__exponent) throw (); extern long double __frexpl (long double __x, int *__exponent) throw ();
-extern long double ldexpl (long double __x, int __exponent) throw (); extern long double __ldexpl (long double __x, int __exponent) throw ();
-extern long double logl (long double __x) throw (); extern long double __logl (long double __x) throw ();
-extern long double log10l (long double __x) throw (); extern long double __log10l (long double __x) throw ();
-extern long double modfl (long double __x, long double *__iptr) throw (); extern long double __modfl (long double __x, long double *__iptr) throw ();
-extern long double exp10l (long double __x) throw (); extern long double __exp10l (long double __x) throw ();
-extern long double pow10l (long double __x) throw (); extern long double __pow10l (long double __x) throw ();
-extern long double expm1l (long double __x) throw (); extern long double __expm1l (long double __x) throw ();
-extern long double log1pl (long double __x) throw (); extern long double __log1pl (long double __x) throw ();
-extern long double logbl (long double __x) throw (); extern long double __logbl (long double __x) throw ();
-extern long double exp2l (long double __x) throw (); extern long double __exp2l (long double __x) throw ();
-extern long double log2l (long double __x) throw (); extern long double __log2l (long double __x) throw ();
-extern long double powl (long double __x, long double __y) throw (); extern long double __powl (long double __x, long double __y) throw ();
-extern long double sqrtl (long double __x) throw (); extern long double __sqrtl (long double __x) throw ();
-extern long double hypotl (long double __x, long double __y) throw (); extern long double __hypotl (long double __x, long double __y) throw ();
-extern long double cbrtl (long double __x) throw (); extern long double __cbrtl (long double __x) throw ();
-extern long double ceill (long double __x) throw () __attribute__ ((__const__)); extern long double __ceill (long double __x) throw () __attribute__ ((__const__));
-extern long double fabsl (long double __x) throw () __attribute__ ((__const__)); extern long double __fabsl (long double __x) throw () __attribute__ ((__const__));
-extern long double floorl (long double __x) throw () __attribute__ ((__const__)); extern long double __floorl (long double __x) throw () __attribute__ ((__const__));
-extern long double fmodl (long double __x, long double __y) throw (); extern long double __fmodl (long double __x, long double __y) throw ();
-extern int __isinfl (long double __value) throw () __attribute__ ((__const__));
-extern int __finitel (long double __value) throw () __attribute__ ((__const__));
-extern int isinfl (long double __value) throw () __attribute__ ((__const__));
-extern int finitel (long double __value) throw () __attribute__ ((__const__));
-extern long double dreml (long double __x, long double __y) throw (); extern long double __dreml (long double __x, long double __y) throw ();
-extern long double significandl (long double __x) throw (); extern long double __significandl (long double __x) throw ();
-extern long double copysignl (long double __x, long double __y) throw () __attribute__ ((__const__)); extern long double __copysignl (long double __x, long double __y) throw () __attribute__ ((__const__));
-extern long double nanl (__const char *__tagb) throw () __attribute__ ((__const__)); extern long double __nanl (__const char *__tagb) throw () __attribute__ ((__const__));
-extern int __isnanl (long double __value) throw () __attribute__ ((__const__));
-extern int isnanl (long double __value) throw () __attribute__ ((__const__));
-extern long double j0l (long double) throw (); extern long double __j0l (long double) throw ();
-extern long double j1l (long double) throw (); extern long double __j1l (long double) throw ();
-extern long double jnl (int, long double) throw (); extern long double __jnl (int, long double) throw ();
-extern long double y0l (long double) throw (); extern long double __y0l (long double) throw ();
-extern long double y1l (long double) throw (); extern long double __y1l (long double) throw ();
-extern long double ynl (int, long double) throw (); extern long double __ynl (int, long double) throw ();
-extern long double erfl (long double) throw (); extern long double __erfl (long double) throw ();
-extern long double erfcl (long double) throw (); extern long double __erfcl (long double) throw ();
-extern long double lgammal (long double) throw (); extern long double __lgammal (long double) throw ();
-extern long double tgammal (long double) throw (); extern long double __tgammal (long double) throw ();
-extern long double gammal (long double) throw (); extern long double __gammal (long double) throw ();
-extern long double lgammal_r (long double, int *__signgamp) throw (); extern long double __lgammal_r (long double, int *__signgamp) throw ();
-extern long double rintl (long double __x) throw (); extern long double __rintl (long double __x) throw ();
-extern long double nextafterl (long double __x, long double __y) throw () __attribute__ ((__const__)); extern long double __nextafterl (long double __x, long double __y) throw () __attribute__ ((__const__));
-extern long double nexttowardl (long double __x, long double __y) throw () __attribute__ ((__const__)); extern long double __nexttowardl (long double __x, long double __y) throw () __attribute__ ((__const__));
-extern long double remainderl (long double __x, long double __y) throw (); extern long double __remainderl (long double __x, long double __y) throw ();
-extern long double scalbnl (long double __x, int __n) throw (); extern long double __scalbnl (long double __x, int __n) throw ();
-extern int ilogbl (long double __x) throw (); extern int __ilogbl (long double __x) throw ();
-extern long double scalblnl (long double __x, long int __n) throw (); extern long double __scalblnl (long double __x, long int __n) throw ();
-extern long double nearbyintl (long double __x) throw (); extern long double __nearbyintl (long double __x) throw ();
-extern long double roundl (long double __x) throw () __attribute__ ((__const__)); extern long double __roundl (long double __x) throw () __attribute__ ((__const__));
-extern long double truncl (long double __x) throw () __attribute__ ((__const__)); extern long double __truncl (long double __x) throw () __attribute__ ((__const__));
-extern long double remquol (long double __x, long double __y, int *__quo) throw (); extern long double __remquol (long double __x, long double __y, int *__quo) throw ();
-extern long int lrintl (long double __x) throw (); extern long int __lrintl (long double __x) throw ();
-extern long long int llrintl (long double __x) throw (); extern long long int __llrintl (long double __x) throw ();
-extern long int lroundl (long double __x) throw (); extern long int __lroundl (long double __x) throw ();
-extern long long int llroundl (long double __x) throw (); extern long long int __llroundl (long double __x) throw ();
-extern long double fdiml (long double __x, long double __y) throw (); extern long double __fdiml (long double __x, long double __y) throw ();
-extern long double fmaxl (long double __x, long double __y) throw (); extern long double __fmaxl (long double __x, long double __y) throw ();
-extern long double fminl (long double __x, long double __y) throw (); extern long double __fminl (long double __x, long double __y) throw ();
-extern int __fpclassifyl (long double __value) throw ()
- __attribute__ ((__const__));
-extern int __signbitl (long double __value) throw ()
- __attribute__ ((__const__));
-extern long double fmal (long double __x, long double __y, long double __z) throw (); extern long double __fmal (long double __x, long double __y, long double __z) throw ();
-extern long double scalbl (long double __x, long double __n) throw (); extern long double __scalbl (long double __x, long double __n) throw ();
-extern int signgam;
-enum
- {
- FP_NAN,
- FP_INFINITE,
- FP_ZERO,
- FP_SUBNORMAL,
- FP_NORMAL
- };
-typedef enum
-{
- _IEEE_ = -1,
- _SVID_,
- _XOPEN_,
- _POSIX_,
- _ISOC_
-} _LIB_VERSION_TYPE;
-extern _LIB_VERSION_TYPE _LIB_VERSION;
-struct __exception
- {
- int type;
- char *name;
- double arg1;
- double arg2;
- double retval;
- };
-extern int matherr (struct __exception *__exc) throw ();
-extern __inline __attribute__ ((__gnu_inline__)) int
-__signbitf (float __x) throw ()
-{
- int __m;
- __asm ("pmovmskb %1, %0" : "=r" (__m) : "x" (__x));
- return __m & 0x8;
-}
-extern __inline __attribute__ ((__gnu_inline__)) int
-__signbit (double __x) throw ()
-{
- int __m;
- __asm ("pmovmskb %1, %0" : "=r" (__m) : "x" (__x));
- return __m & 0x80;
-}
-extern __inline __attribute__ ((__gnu_inline__)) int
-__signbitl (long double __x) throw ()
-{
- __extension__ union { long double __l; int __i[3]; } __u = { __l: __x };
- return (__u.__i[2] & 0x8000) != 0;
-}
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- inline double
- abs(double __x)
- { return __builtin_fabs(__x); }
- inline float
- abs(float __x)
- { return __builtin_fabsf(__x); }
- inline long double
- abs(long double __x)
- { return __builtin_fabsl(__x); }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
- double>::__type
- abs(_Tp __x)
- { return __builtin_fabs(__x); }
- using ::acos;
- inline float
- acos(float __x)
- { return __builtin_acosf(__x); }
- inline long double
- acos(long double __x)
- { return __builtin_acosl(__x); }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
- double>::__type
- acos(_Tp __x)
- { return __builtin_acos(__x); }
- using ::asin;
- inline float
- asin(float __x)
- { return __builtin_asinf(__x); }
- inline long double
- asin(long double __x)
- { return __builtin_asinl(__x); }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
- double>::__type
- asin(_Tp __x)
- { return __builtin_asin(__x); }
- using ::atan;
- inline float
- atan(float __x)
- { return __builtin_atanf(__x); }
- inline long double
- atan(long double __x)
- { return __builtin_atanl(__x); }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
- double>::__type
- atan(_Tp __x)
- { return __builtin_atan(__x); }
- using ::atan2;
- inline float
- atan2(float __y, float __x)
- { return __builtin_atan2f(__y, __x); }
- inline long double
- atan2(long double __y, long double __x)
- { return __builtin_atan2l(__y, __x); }
- template<typename _Tp, typename _Up>
- inline
- typename __gnu_cxx::__promote_2<
- typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
- && __is_arithmetic<_Up>::__value,
- _Tp>::__type, _Up>::__type
- atan2(_Tp __y, _Up __x)
- {
- typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
- return atan2(__type(__y), __type(__x));
- }
- using ::ceil;
- inline float
- ceil(float __x)
- { return __builtin_ceilf(__x); }
- inline long double
- ceil(long double __x)
- { return __builtin_ceill(__x); }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
- double>::__type
- ceil(_Tp __x)
- { return __builtin_ceil(__x); }
- using ::cos;
- inline float
- cos(float __x)
- { return __builtin_cosf(__x); }
- inline long double
- cos(long double __x)
- { return __builtin_cosl(__x); }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
- double>::__type
- cos(_Tp __x)
- { return __builtin_cos(__x); }
- using ::cosh;
- inline float
- cosh(float __x)
- { return __builtin_coshf(__x); }
- inline long double
- cosh(long double __x)
- { return __builtin_coshl(__x); }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
- double>::__type
- cosh(_Tp __x)
- { return __builtin_cosh(__x); }
- using ::exp;
- inline float
- exp(float __x)
- { return __builtin_expf(__x); }
- inline long double
- exp(long double __x)
- { return __builtin_expl(__x); }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
- double>::__type
- exp(_Tp __x)
- { return __builtin_exp(__x); }
- using ::fabs;
- inline float
- fabs(float __x)
- { return __builtin_fabsf(__x); }
- inline long double
- fabs(long double __x)
- { return __builtin_fabsl(__x); }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
- double>::__type
- fabs(_Tp __x)
- { return __builtin_fabs(__x); }
- using ::floor;
- inline float
- floor(float __x)
- { return __builtin_floorf(__x); }
- inline long double
- floor(long double __x)
- { return __builtin_floorl(__x); }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
- double>::__type
- floor(_Tp __x)
- { return __builtin_floor(__x); }
- using ::fmod;
- inline float
- fmod(float __x, float __y)
- { return __builtin_fmodf(__x, __y); }
- inline long double
- fmod(long double __x, long double __y)
- { return __builtin_fmodl(__x, __y); }
- using ::frexp;
- inline float
- frexp(float __x, int* __exp)
- { return __builtin_frexpf(__x, __exp); }
- inline long double
- frexp(long double __x, int* __exp)
- { return __builtin_frexpl(__x, __exp); }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
- double>::__type
- frexp(_Tp __x, int* __exp)
- { return __builtin_frexp(__x, __exp); }
- using ::ldexp;
- inline float
- ldexp(float __x, int __exp)
- { return __builtin_ldexpf(__x, __exp); }
- inline long double
- ldexp(long double __x, int __exp)
- { return __builtin_ldexpl(__x, __exp); }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
- double>::__type
- ldexp(_Tp __x, int __exp)
- { return __builtin_ldexp(__x, __exp); }
- using ::log;
- inline float
- log(float __x)
- { return __builtin_logf(__x); }
- inline long double
- log(long double __x)
- { return __builtin_logl(__x); }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
- double>::__type
- log(_Tp __x)
- { return __builtin_log(__x); }
- using ::log10;
- inline float
- log10(float __x)
- { return __builtin_log10f(__x); }
- inline long double
- log10(long double __x)
- { return __builtin_log10l(__x); }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
- double>::__type
- log10(_Tp __x)
- { return __builtin_log10(__x); }
- using ::modf;
- inline float
- modf(float __x, float* __iptr)
- { return __builtin_modff(__x, __iptr); }
- inline long double
- modf(long double __x, long double* __iptr)
- { return __builtin_modfl(__x, __iptr); }
- using ::pow;
- inline float
- pow(float __x, float __y)
- { return __builtin_powf(__x, __y); }
- inline long double
- pow(long double __x, long double __y)
- { return __builtin_powl(__x, __y); }
- inline double
- pow(double __x, int __i)
- { return __builtin_powi(__x, __i); }
- inline float
- pow(float __x, int __n)
- { return __builtin_powif(__x, __n); }
- inline long double
- pow(long double __x, int __n)
- { return __builtin_powil(__x, __n); }
- template<typename _Tp, typename _Up>
- inline
- typename __gnu_cxx::__promote_2<
- typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
- && __is_arithmetic<_Up>::__value,
- _Tp>::__type, _Up>::__type
- pow(_Tp __x, _Up __y)
- {
- typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
- return pow(__type(__x), __type(__y));
- }
- using ::sin;
- inline float
- sin(float __x)
- { return __builtin_sinf(__x); }
- inline long double
- sin(long double __x)
- { return __builtin_sinl(__x); }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
- double>::__type
- sin(_Tp __x)
- { return __builtin_sin(__x); }
- using ::sinh;
- inline float
- sinh(float __x)
- { return __builtin_sinhf(__x); }
- inline long double
- sinh(long double __x)
- { return __builtin_sinhl(__x); }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
- double>::__type
- sinh(_Tp __x)
- { return __builtin_sinh(__x); }
- using ::sqrt;
- inline float
- sqrt(float __x)
- { return __builtin_sqrtf(__x); }
- inline long double
- sqrt(long double __x)
- { return __builtin_sqrtl(__x); }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
- double>::__type
- sqrt(_Tp __x)
- { return __builtin_sqrt(__x); }
- using ::tan;
- inline float
- tan(float __x)
- { return __builtin_tanf(__x); }
- inline long double
- tan(long double __x)
- { return __builtin_tanl(__x); }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
- double>::__type
- tan(_Tp __x)
- { return __builtin_tan(__x); }
- using ::tanh;
- inline float
- tanh(float __x)
- { return __builtin_tanhf(__x); }
- inline long double
- tanh(long double __x)
- { return __builtin_tanhl(__x); }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
- double>::__type
- tanh(_Tp __x)
- { return __builtin_tanh(__x); }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
- int>::__type
- fpclassify(_Tp __f)
- {
- typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
- return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
- FP_SUBNORMAL, FP_ZERO, __type(__f));
- }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
- int>::__type
- isfinite(_Tp __f)
- {
- typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
- return __builtin_isfinite(__type(__f));
- }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
- int>::__type
- isinf(_Tp __f)
- {
- typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
- return __builtin_isinf(__type(__f));
- }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
- int>::__type
- isnan(_Tp __f)
- {
- typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
- return __builtin_isnan(__type(__f));
- }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
- int>::__type
- isnormal(_Tp __f)
- {
- typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
- return __builtin_isnormal(__type(__f));
- }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
- int>::__type
- signbit(_Tp __f)
- {
- typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
- return __builtin_signbit(__type(__f));
- }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
- int>::__type
- isgreater(_Tp __f1, _Tp __f2)
- {
- typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
- return __builtin_isgreater(__type(__f1), __type(__f2));
- }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
- int>::__type
- isgreaterequal(_Tp __f1, _Tp __f2)
- {
- typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
- return __builtin_isgreaterequal(__type(__f1), __type(__f2));
- }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
- int>::__type
- isless(_Tp __f1, _Tp __f2)
- {
- typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
- return __builtin_isless(__type(__f1), __type(__f2));
- }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
- int>::__type
- islessequal(_Tp __f1, _Tp __f2)
- {
- typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
- return __builtin_islessequal(__type(__f1), __type(__f2));
- }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
- int>::__type
- islessgreater(_Tp __f1, _Tp __f2)
- {
- typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
- return __builtin_islessgreater(__type(__f1), __type(__f2));
- }
- template<typename _Tp>
- inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
- int>::__type
- isunordered(_Tp __f1, _Tp __f2)
- {
- typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
- return __builtin_isunordered(__type(__f1), __type(__f2));
- }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _Alloc>
- class allocator;
- template<class _CharT>
- struct char_traits;
- template<typename _CharT, typename _Traits = char_traits<_CharT>,
- typename _Alloc = allocator<_CharT> >
- class basic_string;
- template<> struct char_traits<char>;
- typedef basic_string<char> string;
- template<> struct char_traits<wchar_t>;
- typedef basic_string<wchar_t> wstring;
-}
-struct _IO_FILE;
-typedef struct _IO_FILE FILE;
-typedef struct _IO_FILE __FILE;
-typedef __builtin_va_list __gnuc_va_list;
-typedef long unsigned int size_t;
-typedef unsigned int wint_t;
-typedef struct
-{
- int __count;
- union
- {
- unsigned int __wch;
- char __wchb[4];
- } __value;
-} __mbstate_t;
-typedef __mbstate_t mbstate_t;
-extern "C" {
-struct tm;
-extern wchar_t *wcscpy (wchar_t *__restrict __dest,
- __const wchar_t *__restrict __src) throw ();
-extern wchar_t *wcsncpy (wchar_t *__restrict __dest,
- __const wchar_t *__restrict __src, size_t __n)
- throw ();
-extern wchar_t *wcscat (wchar_t *__restrict __dest,
- __const wchar_t *__restrict __src) throw ();
-extern wchar_t *wcsncat (wchar_t *__restrict __dest,
- __const wchar_t *__restrict __src, size_t __n)
- throw ();
-extern int wcscmp (__const wchar_t *__s1, __const wchar_t *__s2)
- throw () __attribute__ ((__pure__));
-extern int wcsncmp (__const wchar_t *__s1, __const wchar_t *__s2, size_t __n)
- throw () __attribute__ ((__pure__));
-extern int wcscasecmp (__const wchar_t *__s1, __const wchar_t *__s2) throw ();
-extern int wcsncasecmp (__const wchar_t *__s1, __const wchar_t *__s2,
- size_t __n) throw ();
-typedef struct __locale_struct
-{
- struct __locale_data *__locales[13];
- const unsigned short int *__ctype_b;
- const int *__ctype_tolower;
- const int *__ctype_toupper;
- const char *__names[13];
-} *__locale_t;
-typedef __locale_t locale_t;
-extern int wcscasecmp_l (__const wchar_t *__s1, __const wchar_t *__s2,
- __locale_t __loc) throw ();
-extern int wcsncasecmp_l (__const wchar_t *__s1, __const wchar_t *__s2,
- size_t __n, __locale_t __loc) throw ();
-extern int wcscoll (__const wchar_t *__s1, __const wchar_t *__s2) throw ();
-extern size_t wcsxfrm (wchar_t *__restrict __s1,
- __const wchar_t *__restrict __s2, size_t __n) throw ();
-extern int wcscoll_l (__const wchar_t *__s1, __const wchar_t *__s2,
- __locale_t __loc) throw ();
-extern size_t wcsxfrm_l (wchar_t *__s1, __const wchar_t *__s2,
- size_t __n, __locale_t __loc) throw ();
-extern wchar_t *wcsdup (__const wchar_t *__s) throw () __attribute__ ((__malloc__));
-extern "C++" wchar_t *wcschr (wchar_t *__wcs, wchar_t __wc)
- throw () __asm ("wcschr") __attribute__ ((__pure__));
-extern "C++" __const wchar_t *wcschr (__const wchar_t *__wcs, wchar_t __wc)
- throw () __asm ("wcschr") __attribute__ ((__pure__));
-extern "C++" wchar_t *wcsrchr (wchar_t *__wcs, wchar_t __wc)
- throw () __asm ("wcsrchr") __attribute__ ((__pure__));
-extern "C++" __const wchar_t *wcsrchr (__const wchar_t *__wcs, wchar_t __wc)
- throw () __asm ("wcsrchr") __attribute__ ((__pure__));
-extern wchar_t *wcschrnul (__const wchar_t *__s, wchar_t __wc)
- throw () __attribute__ ((__pure__));
-extern size_t wcscspn (__const wchar_t *__wcs, __const wchar_t *__reject)
- throw () __attribute__ ((__pure__));
-extern size_t wcsspn (__const wchar_t *__wcs, __const wchar_t *__accept)
- throw () __attribute__ ((__pure__));
-extern "C++" wchar_t *wcspbrk (wchar_t *__wcs, __const wchar_t *__accept)
- throw () __asm ("wcspbrk") __attribute__ ((__pure__));
-extern "C++" __const wchar_t *wcspbrk (__const wchar_t *__wcs,
- __const wchar_t *__accept)
- throw () __asm ("wcspbrk") __attribute__ ((__pure__));
-extern "C++" wchar_t *wcsstr (wchar_t *__haystack, __const wchar_t *__needle)
- throw () __asm ("wcsstr") __attribute__ ((__pure__));
-extern "C++" __const wchar_t *wcsstr (__const wchar_t *__haystack,
- __const wchar_t *__needle)
- throw () __asm ("wcsstr") __attribute__ ((__pure__));
-extern wchar_t *wcstok (wchar_t *__restrict __s,
- __const wchar_t *__restrict __delim,
- wchar_t **__restrict __ptr) throw ();
-extern size_t wcslen (__const wchar_t *__s) throw () __attribute__ ((__pure__));
-extern "C++" wchar_t *wcswcs (wchar_t *__haystack, __const wchar_t *__needle)
- throw () __asm ("wcswcs") __attribute__ ((__pure__));
-extern "C++" __const wchar_t *wcswcs (__const wchar_t *__haystack,
- __const wchar_t *__needle)
- throw () __asm ("wcswcs") __attribute__ ((__pure__));
-extern size_t wcsnlen (__const wchar_t *__s, size_t __maxlen)
- throw () __attribute__ ((__pure__));
-extern "C++" wchar_t *wmemchr (wchar_t *__s, wchar_t __c, size_t __n)
- throw () __asm ("wmemchr") __attribute__ ((__pure__));
-extern "C++" __const wchar_t *wmemchr (__const wchar_t *__s, wchar_t __c,
- size_t __n)
- throw () __asm ("wmemchr") __attribute__ ((__pure__));
-extern int wmemcmp (__const wchar_t *__restrict __s1,
- __const wchar_t *__restrict __s2, size_t __n)
- throw () __attribute__ ((__pure__));
-extern wchar_t *wmemcpy (wchar_t *__restrict __s1,
- __const wchar_t *__restrict __s2, size_t __n) throw ();
-extern wchar_t *wmemmove (wchar_t *__s1, __const wchar_t *__s2, size_t __n)
- throw ();
-extern wchar_t *wmemset (wchar_t *__s, wchar_t __c, size_t __n) throw ();
-extern wchar_t *wmempcpy (wchar_t *__restrict __s1,
- __const wchar_t *__restrict __s2, size_t __n)
- throw ();
-extern wint_t btowc (int __c) throw ();
-extern int wctob (wint_t __c) throw ();
-extern int mbsinit (__const mbstate_t *__ps) throw () __attribute__ ((__pure__));
-extern size_t mbrtowc (wchar_t *__restrict __pwc,
- __const char *__restrict __s, size_t __n,
- mbstate_t *__p) throw ();
-extern size_t wcrtomb (char *__restrict __s, wchar_t __wc,
- mbstate_t *__restrict __ps) throw ();
-extern size_t __mbrlen (__const char *__restrict __s, size_t __n,
- mbstate_t *__restrict __ps) throw ();
-extern size_t mbrlen (__const char *__restrict __s, size_t __n,
- mbstate_t *__restrict __ps) throw ();
-extern wint_t __btowc_alias (int __c) __asm ("btowc");
-extern __inline __attribute__ ((__gnu_inline__)) wint_t
-btowc (int __c) throw ()
-{ return (__builtin_constant_p (__c) && __c >= '\0' && __c <= '\x7f'
- ? (wint_t) __c : __btowc_alias (__c)); }
-extern int __wctob_alias (wint_t __c) __asm ("wctob");
-extern __inline __attribute__ ((__gnu_inline__)) int
-wctob (wint_t __wc) throw ()
-{ return (__builtin_constant_p (__wc) && __wc >= L'\0' && __wc <= L'\x7f'
- ? (int) __wc : __wctob_alias (__wc)); }
-extern __inline __attribute__ ((__gnu_inline__)) size_t
-mbrlen (__const char *__restrict __s, size_t __n, mbstate_t *__restrict __ps) throw ()
-{ return (__ps != __null
- ? mbrtowc (__null, __s, __n, __ps) : __mbrlen (__s, __n, __null)); }
-extern size_t mbsrtowcs (wchar_t *__restrict __dst,
- __const char **__restrict __src, size_t __len,
- mbstate_t *__restrict __ps) throw ();
-extern size_t wcsrtombs (char *__restrict __dst,
- __const wchar_t **__restrict __src, size_t __len,
- mbstate_t *__restrict __ps) throw ();
-extern size_t mbsnrtowcs (wchar_t *__restrict __dst,
- __const char **__restrict __src, size_t __nmc,
- size_t __len, mbstate_t *__restrict __ps) throw ();
-extern size_t wcsnrtombs (char *__restrict __dst,
- __const wchar_t **__restrict __src,
- size_t __nwc, size_t __len,
- mbstate_t *__restrict __ps) throw ();
-extern int wcwidth (wchar_t __c) throw ();
-extern int wcswidth (__const wchar_t *__s, size_t __n) throw ();
-extern double wcstod (__const wchar_t *__restrict __nptr,
- wchar_t **__restrict __endptr) throw ();
-extern float wcstof (__const wchar_t *__restrict __nptr,
- wchar_t **__restrict __endptr) throw ();
-extern long double wcstold (__const wchar_t *__restrict __nptr,
- wchar_t **__restrict __endptr) throw ();
-extern long int wcstol (__const wchar_t *__restrict __nptr,
- wchar_t **__restrict __endptr, int __base) throw ();
-extern unsigned long int wcstoul (__const wchar_t *__restrict __nptr,
- wchar_t **__restrict __endptr, int __base)
- throw ();
-__extension__
-extern long long int wcstoll (__const wchar_t *__restrict __nptr,
- wchar_t **__restrict __endptr, int __base)
- throw ();
-__extension__
-extern unsigned long long int wcstoull (__const wchar_t *__restrict __nptr,
- wchar_t **__restrict __endptr,
- int __base) throw ();
-__extension__
-extern long long int wcstoq (__const wchar_t *__restrict __nptr,
- wchar_t **__restrict __endptr, int __base)
- throw ();
-__extension__
-extern unsigned long long int wcstouq (__const wchar_t *__restrict __nptr,
- wchar_t **__restrict __endptr,
- int __base) throw ();
-extern long int wcstol_l (__const wchar_t *__restrict __nptr,
- wchar_t **__restrict __endptr, int __base,
- __locale_t __loc) throw ();
-extern unsigned long int wcstoul_l (__const wchar_t *__restrict __nptr,
- wchar_t **__restrict __endptr,
- int __base, __locale_t __loc) throw ();
-__extension__
-extern long long int wcstoll_l (__const wchar_t *__restrict __nptr,
- wchar_t **__restrict __endptr,
- int __base, __locale_t __loc) throw ();
-__extension__
-extern unsigned long long int wcstoull_l (__const wchar_t *__restrict __nptr,
- wchar_t **__restrict __endptr,
- int __base, __locale_t __loc)
- throw ();
-extern double wcstod_l (__const wchar_t *__restrict __nptr,
- wchar_t **__restrict __endptr, __locale_t __loc)
- throw ();
-extern float wcstof_l (__const wchar_t *__restrict __nptr,
- wchar_t **__restrict __endptr, __locale_t __loc)
- throw ();
-extern long double wcstold_l (__const wchar_t *__restrict __nptr,
- wchar_t **__restrict __endptr,
- __locale_t __loc) throw ();
-extern wchar_t *wcpcpy (wchar_t *__restrict __dest,
- __const wchar_t *__restrict __src) throw ();
-extern wchar_t *wcpncpy (wchar_t *__restrict __dest,
- __const wchar_t *__restrict __src, size_t __n)
- throw ();
-extern __FILE *open_wmemstream (wchar_t **__bufloc, size_t *__sizeloc) throw ();
-extern int fwide (__FILE *__fp, int __mode) throw ();
-extern int fwprintf (__FILE *__restrict __stream,
- __const wchar_t *__restrict __format, ...)
- ;
-extern int wprintf (__const wchar_t *__restrict __format, ...)
- ;
-extern int swprintf (wchar_t *__restrict __s, size_t __n,
- __const wchar_t *__restrict __format, ...)
- throw () ;
-extern int vfwprintf (__FILE *__restrict __s,
- __const wchar_t *__restrict __format,
- __gnuc_va_list __arg)
- ;
-extern int vwprintf (__const wchar_t *__restrict __format,
- __gnuc_va_list __arg)
- ;
-extern int vswprintf (wchar_t *__restrict __s, size_t __n,
- __const wchar_t *__restrict __format,
- __gnuc_va_list __arg)
- throw () ;
-extern int fwscanf (__FILE *__restrict __stream,
- __const wchar_t *__restrict __format, ...)
- ;
-extern int wscanf (__const wchar_t *__restrict __format, ...)
- ;
-extern int swscanf (__const wchar_t *__restrict __s,
- __const wchar_t *__restrict __format, ...)
- throw () ;
-extern int vfwscanf (__FILE *__restrict __s,
- __const wchar_t *__restrict __format,
- __gnuc_va_list __arg)
- ;
-extern int vwscanf (__const wchar_t *__restrict __format,
- __gnuc_va_list __arg)
- ;
-extern int vswscanf (__const wchar_t *__restrict __s,
- __const wchar_t *__restrict __format,
- __gnuc_va_list __arg)
- throw () ;
-extern wint_t fgetwc (__FILE *__stream);
-extern wint_t getwc (__FILE *__stream);
-extern wint_t getwchar (void);
-extern wint_t fputwc (wchar_t __wc, __FILE *__stream);
-extern wint_t putwc (wchar_t __wc, __FILE *__stream);
-extern wint_t putwchar (wchar_t __wc);
-extern wchar_t *fgetws (wchar_t *__restrict __ws, int __n,
- __FILE *__restrict __stream);
-extern int fputws (__const wchar_t *__restrict __ws,
- __FILE *__restrict __stream);
-extern wint_t ungetwc (wint_t __wc, __FILE *__stream);
-extern wint_t getwc_unlocked (__FILE *__stream);
-extern wint_t getwchar_unlocked (void);
-extern wint_t fgetwc_unlocked (__FILE *__stream);
-extern wint_t fputwc_unlocked (wchar_t __wc, __FILE *__stream);
-extern wint_t putwc_unlocked (wchar_t __wc, __FILE *__stream);
-extern wint_t putwchar_unlocked (wchar_t __wc);
-extern wchar_t *fgetws_unlocked (wchar_t *__restrict __ws, int __n,
- __FILE *__restrict __stream);
-extern int fputws_unlocked (__const wchar_t *__restrict __ws,
- __FILE *__restrict __stream);
-extern size_t wcsftime (wchar_t *__restrict __s, size_t __maxsize,
- __const wchar_t *__restrict __format,
- __const struct tm *__restrict __tp) throw ();
-extern size_t wcsftime_l (wchar_t *__restrict __s, size_t __maxsize,
- __const wchar_t *__restrict __format,
- __const struct tm *__restrict __tp,
- __locale_t __loc) throw ();
-}
-namespace std
-{
- using ::mbstate_t;
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- using ::wint_t;
- using ::btowc;
- using ::fgetwc;
- using ::fgetws;
- using ::fputwc;
- using ::fputws;
- using ::fwide;
- using ::fwprintf;
- using ::fwscanf;
- using ::getwc;
- using ::getwchar;
- using ::mbrlen;
- using ::mbrtowc;
- using ::mbsinit;
- using ::mbsrtowcs;
- using ::putwc;
- using ::putwchar;
- using ::swprintf;
- using ::swscanf;
- using ::ungetwc;
- using ::vfwprintf;
- using ::vfwscanf;
- using ::vswprintf;
- using ::vswscanf;
- using ::vwprintf;
- using ::vwscanf;
- using ::wcrtomb;
- using ::wcscat;
- using ::wcscmp;
- using ::wcscoll;
- using ::wcscpy;
- using ::wcscspn;
- using ::wcsftime;
- using ::wcslen;
- using ::wcsncat;
- using ::wcsncmp;
- using ::wcsncpy;
- using ::wcsrtombs;
- using ::wcsspn;
- using ::wcstod;
- using ::wcstof;
- using ::wcstok;
- using ::wcstol;
- using ::wcstoul;
- using ::wcsxfrm;
- using ::wctob;
- using ::wmemcmp;
- using ::wmemcpy;
- using ::wmemmove;
- using ::wmemset;
- using ::wprintf;
- using ::wscanf;
- using ::wcschr;
- using ::wcspbrk;
- using ::wcsrchr;
- using ::wcsstr;
- using ::wmemchr;
-}
-namespace __gnu_cxx
-{
- using ::wcstold;
- using ::wcstoll;
- using ::wcstoull;
-}
-namespace std
-{
- using ::__gnu_cxx::wcstold;
- using ::__gnu_cxx::wcstoll;
- using ::__gnu_cxx::wcstoull;
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- typedef long streamoff;
- typedef ptrdiff_t streamsize;
- template<typename _StateT>
- class fpos
- {
- private:
- streamoff _M_off;
- _StateT _M_state;
- public:
- fpos()
- : _M_off(0), _M_state() { }
- fpos(streamoff __off)
- : _M_off(__off), _M_state() { }
- operator streamoff() const { return _M_off; }
- void
- state(_StateT __st)
- { _M_state = __st; }
- _StateT
- state() const
- { return _M_state; }
- fpos&
- operator+=(streamoff __off)
- {
- _M_off += __off;
- return *this;
- }
- fpos&
- operator-=(streamoff __off)
- {
- _M_off -= __off;
- return *this;
- }
- fpos
- operator+(streamoff __off) const
- {
- fpos __pos(*this);
- __pos += __off;
- return __pos;
- }
- fpos
- operator-(streamoff __off) const
- {
- fpos __pos(*this);
- __pos -= __off;
- return __pos;
- }
- streamoff
- operator-(const fpos& __other) const
- { return _M_off - __other._M_off; }
- };
- template<typename _StateT>
- inline bool
- operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
- { return streamoff(__lhs) == streamoff(__rhs); }
- template<typename _StateT>
- inline bool
- operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
- { return streamoff(__lhs) != streamoff(__rhs); }
- typedef fpos<mbstate_t> streampos;
- typedef fpos<mbstate_t> wstreampos;
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- class ios_base;
- template<typename _CharT, typename _Traits = char_traits<_CharT> >
- class basic_ios;
- template<typename _CharT, typename _Traits = char_traits<_CharT> >
- class basic_streambuf;
- template<typename _CharT, typename _Traits = char_traits<_CharT> >
- class basic_istream;
- template<typename _CharT, typename _Traits = char_traits<_CharT> >
- class basic_ostream;
- template<typename _CharT, typename _Traits = char_traits<_CharT> >
- class basic_iostream;
- template<typename _CharT, typename _Traits = char_traits<_CharT>,
- typename _Alloc = allocator<_CharT> >
- class basic_stringbuf;
- template<typename _CharT, typename _Traits = char_traits<_CharT>,
- typename _Alloc = allocator<_CharT> >
- class basic_istringstream;
- template<typename _CharT, typename _Traits = char_traits<_CharT>,
- typename _Alloc = allocator<_CharT> >
- class basic_ostringstream;
- template<typename _CharT, typename _Traits = char_traits<_CharT>,
- typename _Alloc = allocator<_CharT> >
- class basic_stringstream;
- template<typename _CharT, typename _Traits = char_traits<_CharT> >
- class basic_filebuf;
- template<typename _CharT, typename _Traits = char_traits<_CharT> >
- class basic_ifstream;
- template<typename _CharT, typename _Traits = char_traits<_CharT> >
- class basic_ofstream;
- template<typename _CharT, typename _Traits = char_traits<_CharT> >
- class basic_fstream;
- template<typename _CharT, typename _Traits = char_traits<_CharT> >
- class istreambuf_iterator;
- template<typename _CharT, typename _Traits = char_traits<_CharT> >
- class ostreambuf_iterator;
- typedef basic_ios<char> ios;
- typedef basic_streambuf<char> streambuf;
- typedef basic_istream<char> istream;
- typedef basic_ostream<char> ostream;
- typedef basic_iostream<char> iostream;
- typedef basic_stringbuf<char> stringbuf;
- typedef basic_istringstream<char> istringstream;
- typedef basic_ostringstream<char> ostringstream;
- typedef basic_stringstream<char> stringstream;
- typedef basic_filebuf<char> filebuf;
- typedef basic_ifstream<char> ifstream;
- typedef basic_ofstream<char> ofstream;
- typedef basic_fstream<char> fstream;
- typedef basic_ios<wchar_t> wios;
- typedef basic_streambuf<wchar_t> wstreambuf;
- typedef basic_istream<wchar_t> wistream;
- typedef basic_ostream<wchar_t> wostream;
- typedef basic_iostream<wchar_t> wiostream;
- typedef basic_stringbuf<wchar_t> wstringbuf;
- typedef basic_istringstream<wchar_t> wistringstream;
- typedef basic_ostringstream<wchar_t> wostringstream;
- typedef basic_stringstream<wchar_t> wstringstream;
- typedef basic_filebuf<wchar_t> wfilebuf;
- typedef basic_ifstream<wchar_t> wifstream;
- typedef basic_ofstream<wchar_t> wofstream;
- typedef basic_fstream<wchar_t> wfstream;
-}
-#pragma GCC visibility push(default)
-extern "C++" {
-namespace std
-{
- class exception
- {
- public:
- exception() throw() { }
- virtual ~exception() throw();
- virtual const char* what() const throw();
- };
- class bad_exception : public exception
- {
- public:
- bad_exception() throw() { }
- virtual ~bad_exception() throw();
- virtual const char* what() const throw();
- };
- typedef void (*terminate_handler) ();
- typedef void (*unexpected_handler) ();
- terminate_handler set_terminate(terminate_handler) throw();
- void terminate() throw() __attribute__ ((__noreturn__));
- unexpected_handler set_unexpected(unexpected_handler) throw();
- void unexpected() __attribute__ ((__noreturn__));
- bool uncaught_exception() throw() __attribute__ ((__pure__));
-}
-namespace __gnu_cxx
-{
- void __verbose_terminate_handler();
-}
-}
-#pragma GCC visibility pop
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- void
- __throw_bad_exception(void) __attribute__((__noreturn__));
- void
- __throw_bad_alloc(void) __attribute__((__noreturn__));
- void
- __throw_bad_cast(void) __attribute__((__noreturn__));
- void
- __throw_bad_typeid(void) __attribute__((__noreturn__));
- void
- __throw_logic_error(const char*) __attribute__((__noreturn__));
- void
- __throw_domain_error(const char*) __attribute__((__noreturn__));
- void
- __throw_invalid_argument(const char*) __attribute__((__noreturn__));
- void
- __throw_length_error(const char*) __attribute__((__noreturn__));
- void
- __throw_out_of_range(const char*) __attribute__((__noreturn__));
- void
- __throw_runtime_error(const char*) __attribute__((__noreturn__));
- void
- __throw_range_error(const char*) __attribute__((__noreturn__));
- void
- __throw_overflow_error(const char*) __attribute__((__noreturn__));
- void
- __throw_underflow_error(const char*) __attribute__((__noreturn__));
- void
- __throw_ios_failure(const char*) __attribute__((__noreturn__));
- void
- __throw_system_error(int) __attribute__((__noreturn__));
- void
- __throw_future_error(int) __attribute__((__noreturn__));
- void
- __throw_bad_function_call() __attribute__((__noreturn__));
-}
-namespace __gnu_cxx __attribute__ ((__visibility__ ("default")))
-{
- template<typename _Value>
- struct __numeric_traits_integer
- {
- static const _Value __min = (((_Value)(-1) < 0) ? (_Value)1 << (sizeof(_Value) * 8 - ((_Value)(-1) < 0)) : (_Value)0);
- static const _Value __max = (((_Value)(-1) < 0) ? (((((_Value)1 << ((sizeof(_Value) * 8 - ((_Value)(-1) < 0)) - 1)) - 1) << 1) + 1) : ~(_Value)0);
- static const bool __is_signed = ((_Value)(-1) < 0);
- static const int __digits = (sizeof(_Value) * 8 - ((_Value)(-1) < 0));
- };
- template<typename _Value>
- const _Value __numeric_traits_integer<_Value>::__min;
- template<typename _Value>
- const _Value __numeric_traits_integer<_Value>::__max;
- template<typename _Value>
- const bool __numeric_traits_integer<_Value>::__is_signed;
- template<typename _Value>
- const int __numeric_traits_integer<_Value>::__digits;
- template<typename _Value>
- struct __numeric_traits_floating
- {
- static const int __max_digits10 = (2 + (std::__are_same<_Value, float>::__value ? 24 : std::__are_same<_Value, double>::__value ? 53 : 64) * 643L / 2136);
- static const bool __is_signed = true;
- static const int __digits10 = (std::__are_same<_Value, float>::__value ? 6 : std::__are_same<_Value, double>::__value ? 15 : 18);
- static const int __max_exponent10 = (std::__are_same<_Value, float>::__value ? 38 : std::__are_same<_Value, double>::__value ? 308 : 4932);
- };
- template<typename _Value>
- const int __numeric_traits_floating<_Value>::__max_digits10;
- template<typename _Value>
- const bool __numeric_traits_floating<_Value>::__is_signed;
- template<typename _Value>
- const int __numeric_traits_floating<_Value>::__digits10;
- template<typename _Value>
- const int __numeric_traits_floating<_Value>::__max_exponent10;
- template<typename _Value>
- struct __numeric_traits
- : public __conditional_type<std::__is_integer<_Value>::__value,
- __numeric_traits_integer<_Value>,
- __numeric_traits_floating<_Value> >::__type
- { };
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _Tp>
- inline _Tp*
- __addressof(_Tp& __r)
- {
- return reinterpret_cast<_Tp*>
- (&const_cast<char&>(reinterpret_cast<const volatile char&>(__r)));
- }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _Tp>
- inline void
- swap(_Tp& __a, _Tp& __b)
- {
- _Tp __tmp = (__a);
- __a = (__b);
- __b = (__tmp);
- }
- template<typename _Tp, size_t _Nm>
- inline void
- swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
- {
- for (size_t __n = 0; __n < _Nm; ++__n)
- swap(__a[__n], __b[__n]);
- }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<class _T1, class _T2>
- struct pair
- {
- typedef _T1 first_type;
- typedef _T2 second_type;
- _T1 first;
- _T2 second;
- pair()
- : first(), second() { }
- pair(const _T1& __a, const _T2& __b)
- : first(__a), second(__b) { }
- template<class _U1, class _U2>
- pair(const pair<_U1, _U2>& __p)
- : first(__p.first), second(__p.second) { }
- };
- template<class _T1, class _T2>
- inline bool
- operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
- { return __x.first == __y.first && __x.second == __y.second; }
- template<class _T1, class _T2>
- inline bool
- operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
- { return __x.first < __y.first
- || (!(__y.first < __x.first) && __x.second < __y.second); }
- template<class _T1, class _T2>
- inline bool
- operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
- { return !(__x == __y); }
- template<class _T1, class _T2>
- inline bool
- operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
- { return __y < __x; }
- template<class _T1, class _T2>
- inline bool
- operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
- { return !(__y < __x); }
- template<class _T1, class _T2>
- inline bool
- operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
- { return !(__x < __y); }
- template<class _T1, class _T2>
- inline pair<_T1, _T2>
- make_pair(_T1 __x, _T2 __y)
- { return pair<_T1, _T2>(__x, __y); }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- struct input_iterator_tag { };
- struct output_iterator_tag { };
- struct forward_iterator_tag : public input_iterator_tag { };
- struct bidirectional_iterator_tag : public forward_iterator_tag { };
- struct random_access_iterator_tag : public bidirectional_iterator_tag { };
- template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t,
- typename _Pointer = _Tp*, typename _Reference = _Tp&>
- struct iterator
- {
- typedef _Category iterator_category;
- typedef _Tp value_type;
- typedef _Distance difference_type;
- typedef _Pointer pointer;
- typedef _Reference reference;
- };
- template<typename _Iterator>
- struct iterator_traits
- {
- typedef typename _Iterator::iterator_category iterator_category;
- typedef typename _Iterator::value_type value_type;
- typedef typename _Iterator::difference_type difference_type;
- typedef typename _Iterator::pointer pointer;
- typedef typename _Iterator::reference reference;
- };
- template<typename _Tp>
- struct iterator_traits<_Tp*>
- {
- typedef random_access_iterator_tag iterator_category;
- typedef _Tp value_type;
- typedef ptrdiff_t difference_type;
- typedef _Tp* pointer;
- typedef _Tp& reference;
- };
- template<typename _Tp>
- struct iterator_traits<const _Tp*>
- {
- typedef random_access_iterator_tag iterator_category;
- typedef _Tp value_type;
- typedef ptrdiff_t difference_type;
- typedef const _Tp* pointer;
- typedef const _Tp& reference;
- };
- template<typename _Iter>
- inline typename iterator_traits<_Iter>::iterator_category
- __iterator_category(const _Iter&)
- { return typename iterator_traits<_Iter>::iterator_category(); }
- template<typename _Iterator, bool _HasBase>
- struct _Iter_base
- {
- typedef _Iterator iterator_type;
- static iterator_type _S_base(_Iterator __it)
- { return __it; }
- };
- template<typename _Iterator>
- struct _Iter_base<_Iterator, true>
- {
- typedef typename _Iterator::iterator_type iterator_type;
- static iterator_type _S_base(_Iterator __it)
- { return __it.base(); }
- };
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _InputIterator>
- inline typename iterator_traits<_InputIterator>::difference_type
- __distance(_InputIterator __first, _InputIterator __last,
- input_iterator_tag)
- {
- typename iterator_traits<_InputIterator>::difference_type __n = 0;
- while (__first != __last)
- {
- ++__first;
- ++__n;
- }
- return __n;
- }
- template<typename _RandomAccessIterator>
- inline typename iterator_traits<_RandomAccessIterator>::difference_type
- __distance(_RandomAccessIterator __first, _RandomAccessIterator __last,
- random_access_iterator_tag)
- {
- return __last - __first;
- }
- template<typename _InputIterator>
- inline typename iterator_traits<_InputIterator>::difference_type
- distance(_InputIterator __first, _InputIterator __last)
- {
- return std::__distance(__first, __last,
- std::__iterator_category(__first));
- }
- template<typename _InputIterator, typename _Distance>
- inline void
- __advance(_InputIterator& __i, _Distance __n, input_iterator_tag)
- {
- while (__n--)
- ++__i;
- }
- template<typename _BidirectionalIterator, typename _Distance>
- inline void
- __advance(_BidirectionalIterator& __i, _Distance __n,
- bidirectional_iterator_tag)
- {
- if (__n > 0)
- while (__n--)
- ++__i;
- else
- while (__n++)
- --__i;
- }
- template<typename _RandomAccessIterator, typename _Distance>
- inline void
- __advance(_RandomAccessIterator& __i, _Distance __n,
- random_access_iterator_tag)
- {
- __i += __n;
- }
- template<typename _InputIterator, typename _Distance>
- inline void
- advance(_InputIterator& __i, _Distance __n)
- {
- typename iterator_traits<_InputIterator>::difference_type __d = __n;
- std::__advance(__i, __d, std::__iterator_category(__i));
- }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _Iterator>
- class reverse_iterator
- : public iterator<typename iterator_traits<_Iterator>::iterator_category,
- typename iterator_traits<_Iterator>::value_type,
- typename iterator_traits<_Iterator>::difference_type,
- typename iterator_traits<_Iterator>::pointer,
- typename iterator_traits<_Iterator>::reference>
- {
- protected:
- _Iterator current;
- typedef iterator_traits<_Iterator> __traits_type;
- public:
- typedef _Iterator iterator_type;
- typedef typename __traits_type::difference_type difference_type;
- typedef typename __traits_type::pointer pointer;
- typedef typename __traits_type::reference reference;
- reverse_iterator() : current() { }
- explicit
- reverse_iterator(iterator_type __x) : current(__x) { }
- reverse_iterator(const reverse_iterator& __x)
- : current(__x.current) { }
- template<typename _Iter>
- reverse_iterator(const reverse_iterator<_Iter>& __x)
- : current(__x.base()) { }
- iterator_type
- base() const
- { return current; }
- reference
- operator*() const
- {
- _Iterator __tmp = current;
- return *--__tmp;
- }
- pointer
- operator->() const
- { return &(operator*()); }
- reverse_iterator&
- operator++()
- {
- --current;
- return *this;
- }
- reverse_iterator
- operator++(int)
- {
- reverse_iterator __tmp = *this;
- --current;
- return __tmp;
- }
- reverse_iterator&
- operator--()
- {
- ++current;
- return *this;
- }
- reverse_iterator
- operator--(int)
- {
- reverse_iterator __tmp = *this;
- ++current;
- return __tmp;
- }
- reverse_iterator
- operator+(difference_type __n) const
- { return reverse_iterator(current - __n); }
- reverse_iterator&
- operator+=(difference_type __n)
- {
- current -= __n;
- return *this;
- }
- reverse_iterator
- operator-(difference_type __n) const
- { return reverse_iterator(current + __n); }
- reverse_iterator&
- operator-=(difference_type __n)
- {
- current += __n;
- return *this;
- }
- reference
- operator[](difference_type __n) const
- { return *(*this + __n); }
- };
- template<typename _Iterator>
- inline bool
- operator==(const reverse_iterator<_Iterator>& __x,
- const reverse_iterator<_Iterator>& __y)
- { return __x.base() == __y.base(); }
- template<typename _Iterator>
- inline bool
- operator<(const reverse_iterator<_Iterator>& __x,
- const reverse_iterator<_Iterator>& __y)
- { return __y.base() < __x.base(); }
- template<typename _Iterator>
- inline bool
- operator!=(const reverse_iterator<_Iterator>& __x,
- const reverse_iterator<_Iterator>& __y)
- { return !(__x == __y); }
- template<typename _Iterator>
- inline bool
- operator>(const reverse_iterator<_Iterator>& __x,
- const reverse_iterator<_Iterator>& __y)
- { return __y < __x; }
- template<typename _Iterator>
- inline bool
- operator<=(const reverse_iterator<_Iterator>& __x,
- const reverse_iterator<_Iterator>& __y)
- { return !(__y < __x); }
- template<typename _Iterator>
- inline bool
- operator>=(const reverse_iterator<_Iterator>& __x,
- const reverse_iterator<_Iterator>& __y)
- { return !(__x < __y); }
- template<typename _Iterator>
- inline typename reverse_iterator<_Iterator>::difference_type
- operator-(const reverse_iterator<_Iterator>& __x,
- const reverse_iterator<_Iterator>& __y)
- { return __y.base() - __x.base(); }
- template<typename _Iterator>
- inline reverse_iterator<_Iterator>
- operator+(typename reverse_iterator<_Iterator>::difference_type __n,
- const reverse_iterator<_Iterator>& __x)
- { return reverse_iterator<_Iterator>(__x.base() - __n); }
- template<typename _IteratorL, typename _IteratorR>
- inline bool
- operator==(const reverse_iterator<_IteratorL>& __x,
- const reverse_iterator<_IteratorR>& __y)
- { return __x.base() == __y.base(); }
- template<typename _IteratorL, typename _IteratorR>
- inline bool
- operator<(const reverse_iterator<_IteratorL>& __x,
- const reverse_iterator<_IteratorR>& __y)
- { return __y.base() < __x.base(); }
- template<typename _IteratorL, typename _IteratorR>
- inline bool
- operator!=(const reverse_iterator<_IteratorL>& __x,
- const reverse_iterator<_IteratorR>& __y)
- { return !(__x == __y); }
- template<typename _IteratorL, typename _IteratorR>
- inline bool
- operator>(const reverse_iterator<_IteratorL>& __x,
- const reverse_iterator<_IteratorR>& __y)
- { return __y < __x; }
- template<typename _IteratorL, typename _IteratorR>
- inline bool
- operator<=(const reverse_iterator<_IteratorL>& __x,
- const reverse_iterator<_IteratorR>& __y)
- { return !(__y < __x); }
- template<typename _IteratorL, typename _IteratorR>
- inline bool
- operator>=(const reverse_iterator<_IteratorL>& __x,
- const reverse_iterator<_IteratorR>& __y)
- { return !(__x < __y); }
- template<typename _IteratorL, typename _IteratorR>
- inline typename reverse_iterator<_IteratorL>::difference_type
- operator-(const reverse_iterator<_IteratorL>& __x,
- const reverse_iterator<_IteratorR>& __y)
- { return __y.base() - __x.base(); }
- template<typename _Container>
- class back_insert_iterator
- : public iterator<output_iterator_tag, void, void, void, void>
- {
- protected:
- _Container* container;
- public:
- typedef _Container container_type;
- explicit
- back_insert_iterator(_Container& __x) : container(&__x) { }
- back_insert_iterator&
- operator=(typename _Container::const_reference __value)
- {
- container->push_back(__value);
- return *this;
- }
- back_insert_iterator&
- operator*()
- { return *this; }
- back_insert_iterator&
- operator++()
- { return *this; }
- back_insert_iterator
- operator++(int)
- { return *this; }
- };
- template<typename _Container>
- inline back_insert_iterator<_Container>
- back_inserter(_Container& __x)
- { return back_insert_iterator<_Container>(__x); }
- template<typename _Container>
- class front_insert_iterator
- : public iterator<output_iterator_tag, void, void, void, void>
- {
- protected:
- _Container* container;
- public:
- typedef _Container container_type;
- explicit front_insert_iterator(_Container& __x) : container(&__x) { }
- front_insert_iterator&
- operator=(typename _Container::const_reference __value)
- {
- container->push_front(__value);
- return *this;
- }
- front_insert_iterator&
- operator*()
- { return *this; }
- front_insert_iterator&
- operator++()
- { return *this; }
- front_insert_iterator
- operator++(int)
- { return *this; }
- };
- template<typename _Container>
- inline front_insert_iterator<_Container>
- front_inserter(_Container& __x)
- { return front_insert_iterator<_Container>(__x); }
- template<typename _Container>
- class insert_iterator
- : public iterator<output_iterator_tag, void, void, void, void>
- {
- protected:
- _Container* container;
- typename _Container::iterator iter;
- public:
- typedef _Container container_type;
- insert_iterator(_Container& __x, typename _Container::iterator __i)
- : container(&__x), iter(__i) {}
- insert_iterator&
- operator=(typename _Container::const_reference __value)
- {
- iter = container->insert(iter, __value);
- ++iter;
- return *this;
- }
- insert_iterator&
- operator*()
- { return *this; }
- insert_iterator&
- operator++()
- { return *this; }
- insert_iterator&
- operator++(int)
- { return *this; }
- };
- template<typename _Container, typename _Iterator>
- inline insert_iterator<_Container>
- inserter(_Container& __x, _Iterator __i)
- {
- return insert_iterator<_Container>(__x,
- typename _Container::iterator(__i));
- }
-}
-namespace __gnu_cxx __attribute__ ((__visibility__ ("default")))
-{
- using std::iterator_traits;
- using std::iterator;
- template<typename _Iterator, typename _Container>
- class __normal_iterator
- {
- protected:
- _Iterator _M_current;
- typedef iterator_traits<_Iterator> __traits_type;
- public:
- typedef _Iterator iterator_type;
- typedef typename __traits_type::iterator_category iterator_category;
- typedef typename __traits_type::value_type value_type;
- typedef typename __traits_type::difference_type difference_type;
- typedef typename __traits_type::reference reference;
- typedef typename __traits_type::pointer pointer;
- __normal_iterator() : _M_current(_Iterator()) { }
- explicit
- __normal_iterator(const _Iterator& __i) : _M_current(__i) { }
- template<typename _Iter>
- __normal_iterator(const __normal_iterator<_Iter,
- typename __enable_if<
- (std::__are_same<_Iter, typename _Container::pointer>::__value),
- _Container>::__type>& __i)
- : _M_current(__i.base()) { }
- reference
- operator*() const
- { return *_M_current; }
- pointer
- operator->() const
- { return _M_current; }
- __normal_iterator&
- operator++()
- {
- ++_M_current;
- return *this;
- }
- __normal_iterator
- operator++(int)
- { return __normal_iterator(_M_current++); }
- __normal_iterator&
- operator--()
- {
- --_M_current;
- return *this;
- }
- __normal_iterator
- operator--(int)
- { return __normal_iterator(_M_current--); }
- reference
- operator[](const difference_type& __n) const
- { return _M_current[__n]; }
- __normal_iterator&
- operator+=(const difference_type& __n)
- { _M_current += __n; return *this; }
- __normal_iterator
- operator+(const difference_type& __n) const
- { return __normal_iterator(_M_current + __n); }
- __normal_iterator&
- operator-=(const difference_type& __n)
- { _M_current -= __n; return *this; }
- __normal_iterator
- operator-(const difference_type& __n) const
- { return __normal_iterator(_M_current - __n); }
- const _Iterator&
- base() const
- { return _M_current; }
- };
- template<typename _IteratorL, typename _IteratorR, typename _Container>
- inline bool
- operator==(const __normal_iterator<_IteratorL, _Container>& __lhs,
- const __normal_iterator<_IteratorR, _Container>& __rhs)
- { return __lhs.base() == __rhs.base(); }
- template<typename _Iterator, typename _Container>
- inline bool
- operator==(const __normal_iterator<_Iterator, _Container>& __lhs,
- const __normal_iterator<_Iterator, _Container>& __rhs)
- { return __lhs.base() == __rhs.base(); }
- template<typename _IteratorL, typename _IteratorR, typename _Container>
- inline bool
- operator!=(const __normal_iterator<_IteratorL, _Container>& __lhs,
- const __normal_iterator<_IteratorR, _Container>& __rhs)
- { return __lhs.base() != __rhs.base(); }
- template<typename _Iterator, typename _Container>
- inline bool
- operator!=(const __normal_iterator<_Iterator, _Container>& __lhs,
- const __normal_iterator<_Iterator, _Container>& __rhs)
- { return __lhs.base() != __rhs.base(); }
- template<typename _IteratorL, typename _IteratorR, typename _Container>
- inline bool
- operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
- const __normal_iterator<_IteratorR, _Container>& __rhs)
- { return __lhs.base() < __rhs.base(); }
- template<typename _Iterator, typename _Container>
- inline bool
- operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
- const __normal_iterator<_Iterator, _Container>& __rhs)
- { return __lhs.base() < __rhs.base(); }
- template<typename _IteratorL, typename _IteratorR, typename _Container>
- inline bool
- operator>(const __normal_iterator<_IteratorL, _Container>& __lhs,
- const __normal_iterator<_IteratorR, _Container>& __rhs)
- { return __lhs.base() > __rhs.base(); }
- template<typename _Iterator, typename _Container>
- inline bool
- operator>(const __normal_iterator<_Iterator, _Container>& __lhs,
- const __normal_iterator<_Iterator, _Container>& __rhs)
- { return __lhs.base() > __rhs.base(); }
- template<typename _IteratorL, typename _IteratorR, typename _Container>
- inline bool
- operator<=(const __normal_iterator<_IteratorL, _Container>& __lhs,
- const __normal_iterator<_IteratorR, _Container>& __rhs)
- { return __lhs.base() <= __rhs.base(); }
- template<typename _Iterator, typename _Container>
- inline bool
- operator<=(const __normal_iterator<_Iterator, _Container>& __lhs,
- const __normal_iterator<_Iterator, _Container>& __rhs)
- { return __lhs.base() <= __rhs.base(); }
- template<typename _IteratorL, typename _IteratorR, typename _Container>
- inline bool
- operator>=(const __normal_iterator<_IteratorL, _Container>& __lhs,
- const __normal_iterator<_IteratorR, _Container>& __rhs)
- { return __lhs.base() >= __rhs.base(); }
- template<typename _Iterator, typename _Container>
- inline bool
- operator>=(const __normal_iterator<_Iterator, _Container>& __lhs,
- const __normal_iterator<_Iterator, _Container>& __rhs)
- { return __lhs.base() >= __rhs.base(); }
- template<typename _IteratorL, typename _IteratorR, typename _Container>
- inline typename __normal_iterator<_IteratorL, _Container>::difference_type
- operator-(const __normal_iterator<_IteratorL, _Container>& __lhs,
- const __normal_iterator<_IteratorR, _Container>& __rhs)
- { return __lhs.base() - __rhs.base(); }
- template<typename _Iterator, typename _Container>
- inline typename __normal_iterator<_Iterator, _Container>::difference_type
- operator-(const __normal_iterator<_Iterator, _Container>& __lhs,
- const __normal_iterator<_Iterator, _Container>& __rhs)
- { return __lhs.base() - __rhs.base(); }
- template<typename _Iterator, typename _Container>
- inline __normal_iterator<_Iterator, _Container>
- operator+(typename __normal_iterator<_Iterator, _Container>::difference_type
- __n, const __normal_iterator<_Iterator, _Container>& __i)
- { return __normal_iterator<_Iterator, _Container>(__i.base() + __n); }
-}
-namespace std
-{
- namespace __debug { }
-}
-namespace __gnu_debug
-{
- using namespace std::__debug;
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<bool _BoolType>
- struct __iter_swap
- {
- template<typename _ForwardIterator1, typename _ForwardIterator2>
- static void
- iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
- {
- typedef typename iterator_traits<_ForwardIterator1>::value_type
- _ValueType1;
- _ValueType1 __tmp = (*__a);
- *__a = (*__b);
- *__b = (__tmp);
- }
- };
- template<>
- struct __iter_swap<true>
- {
- template<typename _ForwardIterator1, typename _ForwardIterator2>
- static void
- iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
- {
- swap(*__a, *__b);
- }
- };
- template<typename _ForwardIterator1, typename _ForwardIterator2>
- inline void
- iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
- {
- typedef typename iterator_traits<_ForwardIterator1>::value_type
- _ValueType1;
- typedef typename iterator_traits<_ForwardIterator2>::value_type
- _ValueType2;
- typedef typename iterator_traits<_ForwardIterator1>::reference
- _ReferenceType1;
- typedef typename iterator_traits<_ForwardIterator2>::reference
- _ReferenceType2;
- std::__iter_swap<__are_same<_ValueType1, _ValueType2>::__value
- && __are_same<_ValueType1&, _ReferenceType1>::__value
- && __are_same<_ValueType2&, _ReferenceType2>::__value>::
- iter_swap(__a, __b);
- }
- template<typename _ForwardIterator1, typename _ForwardIterator2>
- _ForwardIterator2
- swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
- _ForwardIterator2 __first2)
- {
- ;
- for (; __first1 != __last1; ++__first1, ++__first2)
- std::iter_swap(__first1, __first2);
- return __first2;
- }
- template<typename _Tp>
- inline const _Tp&
- min(const _Tp& __a, const _Tp& __b)
- {
- if (__b < __a)
- return __b;
- return __a;
- }
- template<typename _Tp>
- inline const _Tp&
- max(const _Tp& __a, const _Tp& __b)
- {
- if (__a < __b)
- return __b;
- return __a;
- }
- template<typename _Tp, typename _Compare>
- inline const _Tp&
- min(const _Tp& __a, const _Tp& __b, _Compare __comp)
- {
- if (__comp(__b, __a))
- return __b;
- return __a;
- }
- template<typename _Tp, typename _Compare>
- inline const _Tp&
- max(const _Tp& __a, const _Tp& __b, _Compare __comp)
- {
- if (__comp(__a, __b))
- return __b;
- return __a;
- }
- template<typename _Iterator>
- struct _Niter_base
- : _Iter_base<_Iterator, __is_normal_iterator<_Iterator>::__value>
- { };
- template<typename _Iterator>
- inline typename _Niter_base<_Iterator>::iterator_type
- __niter_base(_Iterator __it)
- { return std::_Niter_base<_Iterator>::_S_base(__it); }
- template<typename _Iterator>
- struct _Miter_base
- : _Iter_base<_Iterator, __is_move_iterator<_Iterator>::__value>
- { };
- template<typename _Iterator>
- inline typename _Miter_base<_Iterator>::iterator_type
- __miter_base(_Iterator __it)
- { return std::_Miter_base<_Iterator>::_S_base(__it); }
- template<bool, bool, typename>
- struct __copy_move
- {
- template<typename _II, typename _OI>
- static _OI
- __copy_m(_II __first, _II __last, _OI __result)
- {
- for (; __first != __last; ++__result, ++__first)
- *__result = *__first;
- return __result;
- }
- };
- template<>
- struct __copy_move<false, false, random_access_iterator_tag>
- {
- template<typename _II, typename _OI>
- static _OI
- __copy_m(_II __first, _II __last, _OI __result)
- {
- typedef typename iterator_traits<_II>::difference_type _Distance;
- for(_Distance __n = __last - __first; __n > 0; --__n)
- {
- *__result = *__first;
- ++__first;
- ++__result;
- }
- return __result;
- }
- };
- template<bool _IsMove>
- struct __copy_move<_IsMove, true, random_access_iterator_tag>
- {
- template<typename _Tp>
- static _Tp*
- __copy_m(const _Tp* __first, const _Tp* __last, _Tp* __result)
- {
- const ptrdiff_t _Num = __last - __first;
- if (_Num)
- __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
- return __result + _Num;
- }
- };
- template<bool _IsMove, typename _II, typename _OI>
- inline _OI
- __copy_move_a(_II __first, _II __last, _OI __result)
- {
- typedef typename iterator_traits<_II>::value_type _ValueTypeI;
- typedef typename iterator_traits<_OI>::value_type _ValueTypeO;
- typedef typename iterator_traits<_II>::iterator_category _Category;
- const bool __simple = (__is_trivial(_ValueTypeI)
- && __is_pointer<_II>::__value
- && __is_pointer<_OI>::__value
- && __are_same<_ValueTypeI, _ValueTypeO>::__value);
- return std::__copy_move<_IsMove, __simple,
- _Category>::__copy_m(__first, __last, __result);
- }
- template<typename _CharT>
- struct char_traits;
- template<typename _CharT, typename _Traits>
- class istreambuf_iterator;
- template<typename _CharT, typename _Traits>
- class ostreambuf_iterator;
- template<bool _IsMove, typename _CharT>
- typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
- ostreambuf_iterator<_CharT, char_traits<_CharT> > >::__type
- __copy_move_a2(_CharT*, _CharT*,
- ostreambuf_iterator<_CharT, char_traits<_CharT> >);
- template<bool _IsMove, typename _CharT>
- typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
- ostreambuf_iterator<_CharT, char_traits<_CharT> > >::__type
- __copy_move_a2(const _CharT*, const _CharT*,
- ostreambuf_iterator<_CharT, char_traits<_CharT> >);
- template<bool _IsMove, typename _CharT>
- typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
- _CharT*>::__type
- __copy_move_a2(istreambuf_iterator<_CharT, char_traits<_CharT> >,
- istreambuf_iterator<_CharT, char_traits<_CharT> >, _CharT*);
- template<bool _IsMove, typename _II, typename _OI>
- inline _OI
- __copy_move_a2(_II __first, _II __last, _OI __result)
- {
- return _OI(std::__copy_move_a<_IsMove>(std::__niter_base(__first),
- std::__niter_base(__last),
- std::__niter_base(__result)));
- }
- template<typename _II, typename _OI>
- inline _OI
- copy(_II __first, _II __last, _OI __result)
- {
- ;
- return (std::__copy_move_a2<__is_move_iterator<_II>::__value>
- (std::__miter_base(__first), std::__miter_base(__last),
- __result));
- }
- template<bool, bool, typename>
- struct __copy_move_backward
- {
- template<typename _BI1, typename _BI2>
- static _BI2
- __copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result)
- {
- while (__first != __last)
- *--__result = *--__last;
- return __result;
- }
- };
- template<>
- struct __copy_move_backward<false, false, random_access_iterator_tag>
- {
- template<typename _BI1, typename _BI2>
- static _BI2
- __copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result)
- {
- typename iterator_traits<_BI1>::difference_type __n;
- for (__n = __last - __first; __n > 0; --__n)
- *--__result = *--__last;
- return __result;
- }
- };
- template<bool _IsMove>
- struct __copy_move_backward<_IsMove, true, random_access_iterator_tag>
- {
- template<typename _Tp>
- static _Tp*
- __copy_move_b(const _Tp* __first, const _Tp* __last, _Tp* __result)
- {
- const ptrdiff_t _Num = __last - __first;
- if (_Num)
- __builtin_memmove(__result - _Num, __first, sizeof(_Tp) * _Num);
- return __result - _Num;
- }
- };
- template<bool _IsMove, typename _BI1, typename _BI2>
- inline _BI2
- __copy_move_backward_a(_BI1 __first, _BI1 __last, _BI2 __result)
- {
- typedef typename iterator_traits<_BI1>::value_type _ValueType1;
- typedef typename iterator_traits<_BI2>::value_type _ValueType2;
- typedef typename iterator_traits<_BI1>::iterator_category _Category;
- const bool __simple = (__is_trivial(_ValueType1)
- && __is_pointer<_BI1>::__value
- && __is_pointer<_BI2>::__value
- && __are_same<_ValueType1, _ValueType2>::__value);
- return std::__copy_move_backward<_IsMove, __simple,
- _Category>::__copy_move_b(__first,
- __last,
- __result);
- }
- template<bool _IsMove, typename _BI1, typename _BI2>
- inline _BI2
- __copy_move_backward_a2(_BI1 __first, _BI1 __last, _BI2 __result)
- {
- return _BI2(std::__copy_move_backward_a<_IsMove>
- (std::__niter_base(__first), std::__niter_base(__last),
- std::__niter_base(__result)));
- }
- template<typename _BI1, typename _BI2>
- inline _BI2
- copy_backward(_BI1 __first, _BI1 __last, _BI2 __result)
- {
- ;
- return (std::__copy_move_backward_a2<__is_move_iterator<_BI1>::__value>
- (std::__miter_base(__first), std::__miter_base(__last),
- __result));
- }
- template<typename _ForwardIterator, typename _Tp>
- inline typename
- __gnu_cxx::__enable_if<!__is_scalar<_Tp>::__value, void>::__type
- __fill_a(_ForwardIterator __first, _ForwardIterator __last,
- const _Tp& __value)
- {
- for (; __first != __last; ++__first)
- *__first = __value;
- }
- template<typename _ForwardIterator, typename _Tp>
- inline typename
- __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, void>::__type
- __fill_a(_ForwardIterator __first, _ForwardIterator __last,
- const _Tp& __value)
- {
- const _Tp __tmp = __value;
- for (; __first != __last; ++__first)
- *__first = __tmp;
- }
- template<typename _Tp>
- inline typename
- __gnu_cxx::__enable_if<__is_byte<_Tp>::__value, void>::__type
- __fill_a(_Tp* __first, _Tp* __last, const _Tp& __c)
- {
- const _Tp __tmp = __c;
- __builtin_memset(__first, static_cast<unsigned char>(__tmp),
- __last - __first);
- }
- template<typename _ForwardIterator, typename _Tp>
- inline void
- fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
- {
- ;
- std::__fill_a(std::__niter_base(__first), std::__niter_base(__last),
- __value);
- }
- template<typename _OutputIterator, typename _Size, typename _Tp>
- inline typename
- __gnu_cxx::__enable_if<!__is_scalar<_Tp>::__value, _OutputIterator>::__type
- __fill_n_a(_OutputIterator __first, _Size __n, const _Tp& __value)
- {
- for (__decltype(__n + 0) __niter = __n;
- __niter > 0; --__niter, ++__first)
- *__first = __value;
- return __first;
- }
- template<typename _OutputIterator, typename _Size, typename _Tp>
- inline typename
- __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, _OutputIterator>::__type
- __fill_n_a(_OutputIterator __first, _Size __n, const _Tp& __value)
- {
- const _Tp __tmp = __value;
- for (__decltype(__n + 0) __niter = __n;
- __niter > 0; --__niter, ++__first)
- *__first = __tmp;
- return __first;
- }
- template<typename _Size, typename _Tp>
- inline typename
- __gnu_cxx::__enable_if<__is_byte<_Tp>::__value, _Tp*>::__type
- __fill_n_a(_Tp* __first, _Size __n, const _Tp& __c)
- {
- std::__fill_a(__first, __first + __n, __c);
- return __first + __n;
- }
- template<typename _OI, typename _Size, typename _Tp>
- inline _OI
- fill_n(_OI __first, _Size __n, const _Tp& __value)
- {
- return _OI(std::__fill_n_a(std::__niter_base(__first), __n, __value));
- }
- template<bool _BoolType>
- struct __equal
- {
- template<typename _II1, typename _II2>
- static bool
- equal(_II1 __first1, _II1 __last1, _II2 __first2)
- {
- for (; __first1 != __last1; ++__first1, ++__first2)
- if (!(*__first1 == *__first2))
- return false;
- return true;
- }
- };
- template<>
- struct __equal<true>
- {
- template<typename _Tp>
- static bool
- equal(const _Tp* __first1, const _Tp* __last1, const _Tp* __first2)
- {
- return !__builtin_memcmp(__first1, __first2, sizeof(_Tp)
- * (__last1 - __first1));
- }
- };
- template<typename _II1, typename _II2>
- inline bool
- __equal_aux(_II1 __first1, _II1 __last1, _II2 __first2)
- {
- typedef typename iterator_traits<_II1>::value_type _ValueType1;
- typedef typename iterator_traits<_II2>::value_type _ValueType2;
- const bool __simple = (__is_integer<_ValueType1>::__value
- && __is_pointer<_II1>::__value
- && __is_pointer<_II2>::__value
- && __are_same<_ValueType1, _ValueType2>::__value);
- return std::__equal<__simple>::equal(__first1, __last1, __first2);
- }
- template<typename, typename>
- struct __lc_rai
- {
- template<typename _II1, typename _II2>
- static _II1
- __newlast1(_II1, _II1 __last1, _II2, _II2)
- { return __last1; }
- template<typename _II>
- static bool
- __cnd2(_II __first, _II __last)
- { return __first != __last; }
- };
- template<>
- struct __lc_rai<random_access_iterator_tag, random_access_iterator_tag>
- {
- template<typename _RAI1, typename _RAI2>
- static _RAI1
- __newlast1(_RAI1 __first1, _RAI1 __last1,
- _RAI2 __first2, _RAI2 __last2)
- {
- const typename iterator_traits<_RAI1>::difference_type
- __diff1 = __last1 - __first1;
- const typename iterator_traits<_RAI2>::difference_type
- __diff2 = __last2 - __first2;
- return __diff2 < __diff1 ? __first1 + __diff2 : __last1;
- }
- template<typename _RAI>
- static bool
- __cnd2(_RAI, _RAI)
- { return true; }
- };
- template<bool _BoolType>
- struct __lexicographical_compare
- {
- template<typename _II1, typename _II2>
- static bool __lc(_II1, _II1, _II2, _II2);
- };
- template<bool _BoolType>
- template<typename _II1, typename _II2>
- bool
- __lexicographical_compare<_BoolType>::
- __lc(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2)
- {
- typedef typename iterator_traits<_II1>::iterator_category _Category1;
- typedef typename iterator_traits<_II2>::iterator_category _Category2;
- typedef std::__lc_rai<_Category1, _Category2> __rai_type;
- __last1 = __rai_type::__newlast1(__first1, __last1,
- __first2, __last2);
- for (; __first1 != __last1 && __rai_type::__cnd2(__first2, __last2);
- ++__first1, ++__first2)
- {
- if (*__first1 < *__first2)
- return true;
- if (*__first2 < *__first1)
- return false;
- }
- return __first1 == __last1 && __first2 != __last2;
- }
- template<>
- struct __lexicographical_compare<true>
- {
- template<typename _Tp, typename _Up>
- static bool
- __lc(const _Tp* __first1, const _Tp* __last1,
- const _Up* __first2, const _Up* __last2)
- {
- const size_t __len1 = __last1 - __first1;
- const size_t __len2 = __last2 - __first2;
- const int __result = __builtin_memcmp(__first1, __first2,
- std::min(__len1, __len2));
- return __result != 0 ? __result < 0 : __len1 < __len2;
- }
- };
- template<typename _II1, typename _II2>
- inline bool
- __lexicographical_compare_aux(_II1 __first1, _II1 __last1,
- _II2 __first2, _II2 __last2)
- {
- typedef typename iterator_traits<_II1>::value_type _ValueType1;
- typedef typename iterator_traits<_II2>::value_type _ValueType2;
- const bool __simple =
- (__is_byte<_ValueType1>::__value && __is_byte<_ValueType2>::__value
- && !__gnu_cxx::__numeric_traits<_ValueType1>::__is_signed
- && !__gnu_cxx::__numeric_traits<_ValueType2>::__is_signed
- && __is_pointer<_II1>::__value
- && __is_pointer<_II2>::__value);
- return std::__lexicographical_compare<__simple>::__lc(__first1, __last1,
- __first2, __last2);
- }
- template<typename _ForwardIterator, typename _Tp>
- _ForwardIterator
- lower_bound(_ForwardIterator __first, _ForwardIterator __last,
- const _Tp& __val)
- {
- typedef typename iterator_traits<_ForwardIterator>::value_type
- _ValueType;
- typedef typename iterator_traits<_ForwardIterator>::difference_type
- _DistanceType;
- ;
- _DistanceType __len = std::distance(__first, __last);
- while (__len > 0)
- {
- _DistanceType __half = __len >> 1;
- _ForwardIterator __middle = __first;
- std::advance(__middle, __half);
- if (*__middle < __val)
- {
- __first = __middle;
- ++__first;
- __len = __len - __half - 1;
- }
- else
- __len = __half;
- }
- return __first;
- }
- template<typename _Size>
- inline _Size
- __lg(_Size __n)
- {
- _Size __k;
- for (__k = 0; __n != 0; __n >>= 1)
- ++__k;
- return __k - 1;
- }
- inline int
- __lg(int __n)
- { return sizeof(int) * 8 - 1 - __builtin_clz(__n); }
- inline long
- __lg(long __n)
- { return sizeof(long) * 8 - 1 - __builtin_clzl(__n); }
- inline long long
- __lg(long long __n)
- { return sizeof(long long) * 8 - 1 - __builtin_clzll(__n); }
- template<typename _II1, typename _II2>
- inline bool
- equal(_II1 __first1, _II1 __last1, _II2 __first2)
- {
- ;
- return std::__equal_aux(std::__niter_base(__first1),
- std::__niter_base(__last1),
- std::__niter_base(__first2));
- }
- template<typename _IIter1, typename _IIter2, typename _BinaryPredicate>
- inline bool
- equal(_IIter1 __first1, _IIter1 __last1,
- _IIter2 __first2, _BinaryPredicate __binary_pred)
- {
- ;
- for (; __first1 != __last1; ++__first1, ++__first2)
- if (!bool(__binary_pred(*__first1, *__first2)))
- return false;
- return true;
- }
- template<typename _II1, typename _II2>
- inline bool
- lexicographical_compare(_II1 __first1, _II1 __last1,
- _II2 __first2, _II2 __last2)
- {
- typedef typename iterator_traits<_II1>::value_type _ValueType1;
- typedef typename iterator_traits<_II2>::value_type _ValueType2;
- ;
- ;
- return std::__lexicographical_compare_aux(std::__niter_base(__first1),
- std::__niter_base(__last1),
- std::__niter_base(__first2),
- std::__niter_base(__last2));
- }
- template<typename _II1, typename _II2, typename _Compare>
- bool
- lexicographical_compare(_II1 __first1, _II1 __last1,
- _II2 __first2, _II2 __last2, _Compare __comp)
- {
- typedef typename iterator_traits<_II1>::iterator_category _Category1;
- typedef typename iterator_traits<_II2>::iterator_category _Category2;
- typedef std::__lc_rai<_Category1, _Category2> __rai_type;
- ;
- ;
- __last1 = __rai_type::__newlast1(__first1, __last1, __first2, __last2);
- for (; __first1 != __last1 && __rai_type::__cnd2(__first2, __last2);
- ++__first1, ++__first2)
- {
- if (__comp(*__first1, *__first2))
- return true;
- if (__comp(*__first2, *__first1))
- return false;
- }
- return __first1 == __last1 && __first2 != __last2;
- }
- template<typename _InputIterator1, typename _InputIterator2>
- pair<_InputIterator1, _InputIterator2>
- mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2)
- {
- ;
- while (__first1 != __last1 && *__first1 == *__first2)
- {
- ++__first1;
- ++__first2;
- }
- return pair<_InputIterator1, _InputIterator2>(__first1, __first2);
- }
- template<typename _InputIterator1, typename _InputIterator2,
- typename _BinaryPredicate>
- pair<_InputIterator1, _InputIterator2>
- mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _BinaryPredicate __binary_pred)
- {
- ;
- while (__first1 != __last1 && bool(__binary_pred(*__first1, *__first2)))
- {
- ++__first1;
- ++__first2;
- }
- return pair<_InputIterator1, _InputIterator2>(__first1, __first2);
- }
-}
-namespace __gnu_cxx __attribute__ ((__visibility__ ("default")))
-{
- template<typename _CharT>
- struct _Char_types
- {
- typedef unsigned long int_type;
- typedef std::streampos pos_type;
- typedef std::streamoff off_type;
- typedef std::mbstate_t state_type;
- };
- template<typename _CharT>
- struct char_traits
- {
- typedef _CharT char_type;
- typedef typename _Char_types<_CharT>::int_type int_type;
- typedef typename _Char_types<_CharT>::pos_type pos_type;
- typedef typename _Char_types<_CharT>::off_type off_type;
- typedef typename _Char_types<_CharT>::state_type state_type;
- static void
- assign(char_type& __c1, const char_type& __c2)
- { __c1 = __c2; }
- static bool
- eq(const char_type& __c1, const char_type& __c2)
- { return __c1 == __c2; }
- static bool
- lt(const char_type& __c1, const char_type& __c2)
- { return __c1 < __c2; }
- static int
- compare(const char_type* __s1, const char_type* __s2, std::size_t __n);
- static std::size_t
- length(const char_type* __s);
- static const char_type*
- find(const char_type* __s, std::size_t __n, const char_type& __a);
- static char_type*
- move(char_type* __s1, const char_type* __s2, std::size_t __n);
- static char_type*
- copy(char_type* __s1, const char_type* __s2, std::size_t __n);
- static char_type*
- assign(char_type* __s, std::size_t __n, char_type __a);
- static char_type
- to_char_type(const int_type& __c)
- { return static_cast<char_type>(__c); }
- static int_type
- to_int_type(const char_type& __c)
- { return static_cast<int_type>(__c); }
- static bool
- eq_int_type(const int_type& __c1, const int_type& __c2)
- { return __c1 == __c2; }
- static int_type
- eof()
- { return static_cast<int_type>(-1); }
- static int_type
- not_eof(const int_type& __c)
- { return !eq_int_type(__c, eof()) ? __c : to_int_type(char_type()); }
- };
- template<typename _CharT>
- int
- char_traits<_CharT>::
- compare(const char_type* __s1, const char_type* __s2, std::size_t __n)
- {
- for (std::size_t __i = 0; __i < __n; ++__i)
- if (lt(__s1[__i], __s2[__i]))
- return -1;
- else if (lt(__s2[__i], __s1[__i]))
- return 1;
- return 0;
- }
- template<typename _CharT>
- std::size_t
- char_traits<_CharT>::
- length(const char_type* __p)
- {
- std::size_t __i = 0;
- while (!eq(__p[__i], char_type()))
- ++__i;
- return __i;
- }
- template<typename _CharT>
- const typename char_traits<_CharT>::char_type*
- char_traits<_CharT>::
- find(const char_type* __s, std::size_t __n, const char_type& __a)
- {
- for (std::size_t __i = 0; __i < __n; ++__i)
- if (eq(__s[__i], __a))
- return __s + __i;
- return 0;
- }
- template<typename _CharT>
- typename char_traits<_CharT>::char_type*
- char_traits<_CharT>::
- move(char_type* __s1, const char_type* __s2, std::size_t __n)
- {
- return static_cast<_CharT*>(__builtin_memmove(__s1, __s2,
- __n * sizeof(char_type)));
- }
- template<typename _CharT>
- typename char_traits<_CharT>::char_type*
- char_traits<_CharT>::
- copy(char_type* __s1, const char_type* __s2, std::size_t __n)
- {
- std::copy(__s2, __s2 + __n, __s1);
- return __s1;
- }
- template<typename _CharT>
- typename char_traits<_CharT>::char_type*
- char_traits<_CharT>::
- assign(char_type* __s, std::size_t __n, char_type __a)
- {
- std::fill_n(__s, __n, __a);
- return __s;
- }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<class _CharT>
- struct char_traits : public __gnu_cxx::char_traits<_CharT>
- { };
- template<>
- struct char_traits<char>
- {
- typedef char char_type;
- typedef int int_type;
- typedef streampos pos_type;
- typedef streamoff off_type;
- typedef mbstate_t state_type;
- static void
- assign(char_type& __c1, const char_type& __c2)
- { __c1 = __c2; }
- static bool
- eq(const char_type& __c1, const char_type& __c2)
- { return __c1 == __c2; }
- static bool
- lt(const char_type& __c1, const char_type& __c2)
- { return __c1 < __c2; }
- static int
- compare(const char_type* __s1, const char_type* __s2, size_t __n)
- { return __builtin_memcmp(__s1, __s2, __n); }
- static size_t
- length(const char_type* __s)
- { return __builtin_strlen(__s); }
- static const char_type*
- find(const char_type* __s, size_t __n, const char_type& __a)
- { return static_cast<const char_type*>(__builtin_memchr(__s, __a, __n)); }
- static char_type*
- move(char_type* __s1, const char_type* __s2, size_t __n)
- { return static_cast<char_type*>(__builtin_memmove(__s1, __s2, __n)); }
- static char_type*
- copy(char_type* __s1, const char_type* __s2, size_t __n)
- { return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n)); }
- static char_type*
- assign(char_type* __s, size_t __n, char_type __a)
- { return static_cast<char_type*>(__builtin_memset(__s, __a, __n)); }
- static char_type
- to_char_type(const int_type& __c)
- { return static_cast<char_type>(__c); }
- static int_type
- to_int_type(const char_type& __c)
- { return static_cast<int_type>(static_cast<unsigned char>(__c)); }
- static bool
- eq_int_type(const int_type& __c1, const int_type& __c2)
- { return __c1 == __c2; }
- static int_type
- eof()
- { return static_cast<int_type>(-1); }
- static int_type
- not_eof(const int_type& __c)
- { return (__c == eof()) ? 0 : __c; }
- };
- template<>
- struct char_traits<wchar_t>
- {
- typedef wchar_t char_type;
- typedef wint_t int_type;
- typedef streamoff off_type;
- typedef wstreampos pos_type;
- typedef mbstate_t state_type;
- static void
- assign(char_type& __c1, const char_type& __c2)
- { __c1 = __c2; }
- static bool
- eq(const char_type& __c1, const char_type& __c2)
- { return __c1 == __c2; }
- static bool
- lt(const char_type& __c1, const char_type& __c2)
- { return __c1 < __c2; }
- static int
- compare(const char_type* __s1, const char_type* __s2, size_t __n)
- { return wmemcmp(__s1, __s2, __n); }
- static size_t
- length(const char_type* __s)
- { return wcslen(__s); }
- static const char_type*
- find(const char_type* __s, size_t __n, const char_type& __a)
- { return wmemchr(__s, __a, __n); }
- static char_type*
- move(char_type* __s1, const char_type* __s2, size_t __n)
- { return wmemmove(__s1, __s2, __n); }
- static char_type*
- copy(char_type* __s1, const char_type* __s2, size_t __n)
- { return wmemcpy(__s1, __s2, __n); }
- static char_type*
- assign(char_type* __s, size_t __n, char_type __a)
- { return wmemset(__s, __a, __n); }
- static char_type
- to_char_type(const int_type& __c)
- { return char_type(__c); }
- static int_type
- to_int_type(const char_type& __c)
- { return int_type(__c); }
- static bool
- eq_int_type(const int_type& __c1, const int_type& __c2)
- { return __c1 == __c2; }
- static int_type
- eof()
- { return static_cast<int_type>((0xffffffffu)); }
- static int_type
- not_eof(const int_type& __c)
- { return eq_int_type(__c, eof()) ? 0 : __c; }
- };
-}
-enum
-{
- __LC_CTYPE = 0,
- __LC_NUMERIC = 1,
- __LC_TIME = 2,
- __LC_COLLATE = 3,
- __LC_MONETARY = 4,
- __LC_MESSAGES = 5,
- __LC_ALL = 6,
- __LC_PAPER = 7,
- __LC_NAME = 8,
- __LC_ADDRESS = 9,
- __LC_TELEPHONE = 10,
- __LC_MEASUREMENT = 11,
- __LC_IDENTIFICATION = 12
-};
-extern "C" {
-struct lconv
-{
- char *decimal_point;
- char *thousands_sep;
- char *grouping;
- char *int_curr_symbol;
- char *currency_symbol;
- char *mon_decimal_point;
- char *mon_thousands_sep;
- char *mon_grouping;
- char *positive_sign;
- char *negative_sign;
- char int_frac_digits;
- char frac_digits;
- char p_cs_precedes;
- char p_sep_by_space;
- char n_cs_precedes;
- char n_sep_by_space;
- char p_sign_posn;
- char n_sign_posn;
- char int_p_cs_precedes;
- char int_p_sep_by_space;
- char int_n_cs_precedes;
- char int_n_sep_by_space;
- char int_p_sign_posn;
- char int_n_sign_posn;
-};
-extern char *setlocale (int __category, __const char *__locale) throw ();
-extern struct lconv *localeconv (void) throw ();
-extern __locale_t newlocale (int __category_mask, __const char *__locale,
- __locale_t __base) throw ();
-extern __locale_t duplocale (__locale_t __dataset) throw ();
-extern void freelocale (__locale_t __dataset) throw ();
-extern __locale_t uselocale (__locale_t __dataset) throw ();
-}
-namespace std
-{
- using ::lconv;
- using ::setlocale;
- using ::localeconv;
-}
-namespace __gnu_cxx __attribute__ ((__visibility__ ("default")))
-{
- extern "C" __typeof(uselocale) __uselocale;
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- typedef __locale_t __c_locale;
- inline int
- __convert_from_v(const __c_locale& __cloc __attribute__ ((__unused__)),
- char* __out,
- const int __size __attribute__ ((__unused__)),
- const char* __fmt, ...)
- {
- __c_locale __old = __gnu_cxx::__uselocale(__cloc);
- __builtin_va_list __args;
- __builtin_va_start(__args, __fmt);
- const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
- __builtin_va_end(__args);
- __gnu_cxx::__uselocale(__old);
- return __ret;
- }
-}
-typedef unsigned char __u_char;
-typedef unsigned short int __u_short;
-typedef unsigned int __u_int;
-typedef unsigned long int __u_long;
-typedef signed char __int8_t;
-typedef unsigned char __uint8_t;
-typedef signed short int __int16_t;
-typedef unsigned short int __uint16_t;
-typedef signed int __int32_t;
-typedef unsigned int __uint32_t;
-typedef signed long int __int64_t;
-typedef unsigned long int __uint64_t;
-typedef long int __quad_t;
-typedef unsigned long int __u_quad_t;
-typedef unsigned long int __dev_t;
-typedef unsigned int __uid_t;
-typedef unsigned int __gid_t;
-typedef unsigned long int __ino_t;
-typedef unsigned long int __ino64_t;
-typedef unsigned int __mode_t;
-typedef unsigned long int __nlink_t;
-typedef long int __off_t;
-typedef long int __off64_t;
-typedef int __pid_t;
-typedef struct { int __val[2]; } __fsid_t;
-typedef long int __clock_t;
-typedef unsigned long int __rlim_t;
-typedef unsigned long int __rlim64_t;
-typedef unsigned int __id_t;
-typedef long int __time_t;
-typedef unsigned int __useconds_t;
-typedef long int __suseconds_t;
-typedef int __daddr_t;
-typedef long int __swblk_t;
-typedef int __key_t;
-typedef int __clockid_t;
-typedef void * __timer_t;
-typedef long int __blksize_t;
-typedef long int __blkcnt_t;
-typedef long int __blkcnt64_t;
-typedef unsigned long int __fsblkcnt_t;
-typedef unsigned long int __fsblkcnt64_t;
-typedef unsigned long int __fsfilcnt_t;
-typedef unsigned long int __fsfilcnt64_t;
-typedef long int __ssize_t;
-typedef __off64_t __loff_t;
-typedef __quad_t *__qaddr_t;
-typedef char *__caddr_t;
-typedef long int __intptr_t;
-typedef unsigned int __socklen_t;
-extern "C" {
-enum
-{
- _ISupper = ((0) < 8 ? ((1 << (0)) << 8) : ((1 << (0)) >> 8)),
- _ISlower = ((1) < 8 ? ((1 << (1)) << 8) : ((1 << (1)) >> 8)),
- _ISalpha = ((2) < 8 ? ((1 << (2)) << 8) : ((1 << (2)) >> 8)),
- _ISdigit = ((3) < 8 ? ((1 << (3)) << 8) : ((1 << (3)) >> 8)),
- _ISxdigit = ((4) < 8 ? ((1 << (4)) << 8) : ((1 << (4)) >> 8)),
- _ISspace = ((5) < 8 ? ((1 << (5)) << 8) : ((1 << (5)) >> 8)),
- _ISprint = ((6) < 8 ? ((1 << (6)) << 8) : ((1 << (6)) >> 8)),
- _ISgraph = ((7) < 8 ? ((1 << (7)) << 8) : ((1 << (7)) >> 8)),
- _ISblank = ((8) < 8 ? ((1 << (8)) << 8) : ((1 << (8)) >> 8)),
- _IScntrl = ((9) < 8 ? ((1 << (9)) << 8) : ((1 << (9)) >> 8)),
- _ISpunct = ((10) < 8 ? ((1 << (10)) << 8) : ((1 << (10)) >> 8)),
- _ISalnum = ((11) < 8 ? ((1 << (11)) << 8) : ((1 << (11)) >> 8))
-};
-extern __const unsigned short int **__ctype_b_loc (void)
- throw () __attribute__ ((__const));
-extern __const __int32_t **__ctype_tolower_loc (void)
- throw () __attribute__ ((__const));
-extern __const __int32_t **__ctype_toupper_loc (void)
- throw () __attribute__ ((__const));
-extern int isalnum (int) throw ();
-extern int isalpha (int) throw ();
-extern int iscntrl (int) throw ();
-extern int isdigit (int) throw ();
-extern int islower (int) throw ();
-extern int isgraph (int) throw ();
-extern int isprint (int) throw ();
-extern int ispunct (int) throw ();
-extern int isspace (int) throw ();
-extern int isupper (int) throw ();
-extern int isxdigit (int) throw ();
-extern int tolower (int __c) throw ();
-extern int toupper (int __c) throw ();
-extern int isblank (int) throw ();
-extern int isctype (int __c, int __mask) throw ();
-extern int isascii (int __c) throw ();
-extern int toascii (int __c) throw ();
-extern int _toupper (int) throw ();
-extern int _tolower (int) throw ();
-extern int isalnum_l (int, __locale_t) throw ();
-extern int isalpha_l (int, __locale_t) throw ();
-extern int iscntrl_l (int, __locale_t) throw ();
-extern int isdigit_l (int, __locale_t) throw ();
-extern int islower_l (int, __locale_t) throw ();
-extern int isgraph_l (int, __locale_t) throw ();
-extern int isprint_l (int, __locale_t) throw ();
-extern int ispunct_l (int, __locale_t) throw ();
-extern int isspace_l (int, __locale_t) throw ();
-extern int isupper_l (int, __locale_t) throw ();
-extern int isxdigit_l (int, __locale_t) throw ();
-extern int isblank_l (int, __locale_t) throw ();
-extern int __tolower_l (int __c, __locale_t __l) throw ();
-extern int tolower_l (int __c, __locale_t __l) throw ();
-extern int __toupper_l (int __c, __locale_t __l) throw ();
-extern int toupper_l (int __c, __locale_t __l) throw ();
-}
-namespace std
-{
- using ::isalnum;
- using ::isalpha;
- using ::iscntrl;
- using ::isdigit;
- using ::isgraph;
- using ::islower;
- using ::isprint;
- using ::ispunct;
- using ::isspace;
- using ::isupper;
- using ::isxdigit;
- using ::tolower;
- using ::toupper;
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- class locale;
- template<typename _Facet>
- bool
- has_facet(const locale&) throw();
- template<typename _Facet>
- const _Facet&
- use_facet(const locale&);
- template<typename _CharT>
- bool
- isspace(_CharT, const locale&);
- template<typename _CharT>
- bool
- isprint(_CharT, const locale&);
- template<typename _CharT>
- bool
- iscntrl(_CharT, const locale&);
- template<typename _CharT>
- bool
- isupper(_CharT, const locale&);
- template<typename _CharT>
- bool
- islower(_CharT, const locale&);
- template<typename _CharT>
- bool
- isalpha(_CharT, const locale&);
- template<typename _CharT>
- bool
- isdigit(_CharT, const locale&);
- template<typename _CharT>
- bool
- ispunct(_CharT, const locale&);
- template<typename _CharT>
- bool
- isxdigit(_CharT, const locale&);
- template<typename _CharT>
- bool
- isalnum(_CharT, const locale&);
- template<typename _CharT>
- bool
- isgraph(_CharT, const locale&);
- template<typename _CharT>
- _CharT
- toupper(_CharT, const locale&);
- template<typename _CharT>
- _CharT
- tolower(_CharT, const locale&);
- class ctype_base;
- template<typename _CharT>
- class ctype;
- template<> class ctype<char>;
- template<> class ctype<wchar_t>;
- template<typename _CharT>
- class ctype_byname;
- class codecvt_base;
- template<typename _InternT, typename _ExternT, typename _StateT>
- class codecvt;
- template<> class codecvt<char, char, mbstate_t>;
- template<> class codecvt<wchar_t, char, mbstate_t>;
- template<typename _InternT, typename _ExternT, typename _StateT>
- class codecvt_byname;
- template<typename _CharT, typename _InIter = istreambuf_iterator<_CharT> >
- class num_get;
- template<typename _CharT, typename _OutIter = ostreambuf_iterator<_CharT> >
- class num_put;
- template<typename _CharT> class numpunct;
- template<typename _CharT> class numpunct_byname;
- template<typename _CharT>
- class collate;
- template<typename _CharT> class
- collate_byname;
- class time_base;
- template<typename _CharT, typename _InIter = istreambuf_iterator<_CharT> >
- class time_get;
- template<typename _CharT, typename _InIter = istreambuf_iterator<_CharT> >
- class time_get_byname;
- template<typename _CharT, typename _OutIter = ostreambuf_iterator<_CharT> >
- class time_put;
- template<typename _CharT, typename _OutIter = ostreambuf_iterator<_CharT> >
- class time_put_byname;
- class money_base;
- template<typename _CharT, typename _InIter = istreambuf_iterator<_CharT> >
- class money_get;
- template<typename _CharT, typename _OutIter = ostreambuf_iterator<_CharT> >
- class money_put;
- template<typename _CharT, bool _Intl = false>
- class moneypunct;
- template<typename _CharT, bool _Intl = false>
- class moneypunct_byname;
- class messages_base;
- template<typename _CharT>
- class messages;
- template<typename _CharT>
- class messages_byname;
-}
-#pragma GCC visibility push(default)
-typedef __time_t time_t;
-struct timespec
- {
- __time_t tv_sec;
- long int tv_nsec;
- };
-typedef __pid_t pid_t;
-struct sched_param
- {
- int __sched_priority;
- };
-extern "C" {
-extern int clone (int (*__fn) (void *__arg), void *__child_stack,
- int __flags, void *__arg, ...) throw ();
-extern int unshare (int __flags) throw ();
-extern int sched_getcpu (void) throw ();
-}
-struct __sched_param
- {
- int __sched_priority;
- };
-typedef unsigned long int __cpu_mask;
-typedef struct
-{
- __cpu_mask __bits[1024 / (8 * sizeof (__cpu_mask))];
-} cpu_set_t;
-extern "C" {
-extern int __sched_cpucount (size_t __setsize, const cpu_set_t *__setp)
- throw ();
-extern cpu_set_t *__sched_cpualloc (size_t __count) throw () ;
-extern void __sched_cpufree (cpu_set_t *__set) throw ();
-}
-extern "C" {
-extern int sched_setparam (__pid_t __pid, __const struct sched_param *__param)
- throw ();
-extern int sched_getparam (__pid_t __pid, struct sched_param *__param) throw ();
-extern int sched_setscheduler (__pid_t __pid, int __policy,
- __const struct sched_param *__param) throw ();
-extern int sched_getscheduler (__pid_t __pid) throw ();
-extern int sched_yield (void) throw ();
-extern int sched_get_priority_max (int __algorithm) throw ();
-extern int sched_get_priority_min (int __algorithm) throw ();
-extern int sched_rr_get_interval (__pid_t __pid, struct timespec *__t) throw ();
-extern int sched_setaffinity (__pid_t __pid, size_t __cpusetsize,
- __const cpu_set_t *__cpuset) throw ();
-extern int sched_getaffinity (__pid_t __pid, size_t __cpusetsize,
- cpu_set_t *__cpuset) throw ();
-}
-extern "C" {
-typedef __clock_t clock_t;
-typedef __clockid_t clockid_t;
-typedef __timer_t timer_t;
-struct tm
-{
- int tm_sec;
- int tm_min;
- int tm_hour;
- int tm_mday;
- int tm_mon;
- int tm_year;
- int tm_wday;
- int tm_yday;
- int tm_isdst;
- long int tm_gmtoff;
- __const char *tm_zone;
-};
-struct itimerspec
- {
- struct timespec it_interval;
- struct timespec it_value;
- };
-struct sigevent;
-extern clock_t clock (void) throw ();
-extern time_t time (time_t *__timer) throw ();
-extern double difftime (time_t __time1, time_t __time0)
- throw () __attribute__ ((__const__));
-extern time_t mktime (struct tm *__tp) throw ();
-extern size_t strftime (char *__restrict __s, size_t __maxsize,
- __const char *__restrict __format,
- __const struct tm *__restrict __tp) throw ();
-extern char *strptime (__const char *__restrict __s,
- __const char *__restrict __fmt, struct tm *__tp)
- throw ();
-extern size_t strftime_l (char *__restrict __s, size_t __maxsize,
- __const char *__restrict __format,
- __const struct tm *__restrict __tp,
- __locale_t __loc) throw ();
-extern char *strptime_l (__const char *__restrict __s,
- __const char *__restrict __fmt, struct tm *__tp,
- __locale_t __loc) throw ();
-extern struct tm *gmtime (__const time_t *__timer) throw ();
-extern struct tm *localtime (__const time_t *__timer) throw ();
-extern struct tm *gmtime_r (__const time_t *__restrict __timer,
- struct tm *__restrict __tp) throw ();
-extern struct tm *localtime_r (__const time_t *__restrict __timer,
- struct tm *__restrict __tp) throw ();
-extern char *asctime (__const struct tm *__tp) throw ();
-extern char *ctime (__const time_t *__timer) throw ();
-extern char *asctime_r (__const struct tm *__restrict __tp,
- char *__restrict __buf) throw ();
-extern char *ctime_r (__const time_t *__restrict __timer,
- char *__restrict __buf) throw ();
-extern char *__tzname[2];
-extern int __daylight;
-extern long int __timezone;
-extern char *tzname[2];
-extern void tzset (void) throw ();
-extern int daylight;
-extern long int timezone;
-extern int stime (__const time_t *__when) throw ();
-extern time_t timegm (struct tm *__tp) throw ();
-extern time_t timelocal (struct tm *__tp) throw ();
-extern int dysize (int __year) throw () __attribute__ ((__const__));
-extern int nanosleep (__const struct timespec *__requested_time,
- struct timespec *__remaining);
-extern int clock_getres (clockid_t __clock_id, struct timespec *__res) throw ();
-extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) throw ();
-extern int clock_settime (clockid_t __clock_id, __const struct timespec *__tp)
- throw ();
-extern int clock_nanosleep (clockid_t __clock_id, int __flags,
- __const struct timespec *__req,
- struct timespec *__rem);
-extern int clock_getcpuclockid (pid_t __pid, clockid_t *__clock_id) throw ();
-extern int timer_create (clockid_t __clock_id,
- struct sigevent *__restrict __evp,
- timer_t *__restrict __timerid) throw ();
-extern int timer_delete (timer_t __timerid) throw ();
-extern int timer_settime (timer_t __timerid, int __flags,
- __const struct itimerspec *__restrict __value,
- struct itimerspec *__restrict __ovalue) throw ();
-extern int timer_gettime (timer_t __timerid, struct itimerspec *__value)
- throw ();
-extern int timer_getoverrun (timer_t __timerid) throw ();
-extern int getdate_err;
-extern struct tm *getdate (__const char *__string);
-extern int getdate_r (__const char *__restrict __string,
- struct tm *__restrict __resbufp);
-}
-typedef unsigned long int pthread_t;
-typedef union
-{
- char __size[56];
- long int __align;
-} pthread_attr_t;
-typedef struct __pthread_internal_list
-{
- struct __pthread_internal_list *__prev;
- struct __pthread_internal_list *__next;
-} __pthread_list_t;
-typedef union
-{
- struct __pthread_mutex_s
- {
- int __lock;
- unsigned int __count;
- int __owner;
- unsigned int __nusers;
- int __kind;
- int __spins;
- __pthread_list_t __list;
- } __data;
- char __size[40];
- long int __align;
-} pthread_mutex_t;
-typedef union
-{
- char __size[4];
- int __align;
-} pthread_mutexattr_t;
-typedef union
-{
- struct
- {
- int __lock;
- unsigned int __futex;
- __extension__ unsigned long long int __total_seq;
- __extension__ unsigned long long int __wakeup_seq;
- __extension__ unsigned long long int __woken_seq;
- void *__mutex;
- unsigned int __nwaiters;
- unsigned int __broadcast_seq;
- } __data;
- char __size[48];
- __extension__ long long int __align;
-} pthread_cond_t;
-typedef union
-{
- char __size[4];
- int __align;
-} pthread_condattr_t;
-typedef unsigned int pthread_key_t;
-typedef int pthread_once_t;
-typedef union
-{
- struct
- {
- int __lock;
- unsigned int __nr_readers;
- unsigned int __readers_wakeup;
- unsigned int __writer_wakeup;
- unsigned int __nr_readers_queued;
- unsigned int __nr_writers_queued;
- int __writer;
- int __shared;
- unsigned long int __pad1;
- unsigned long int __pad2;
- unsigned int __flags;
- } __data;
- char __size[56];
- long int __align;
-} pthread_rwlock_t;
-typedef union
-{
- char __size[8];
- long int __align;
-} pthread_rwlockattr_t;
-typedef volatile int pthread_spinlock_t;
-typedef union
-{
- char __size[32];
- long int __align;
-} pthread_barrier_t;
-typedef union
-{
- char __size[4];
- int __align;
-} pthread_barrierattr_t;
-typedef long int __jmp_buf[8];
-enum
-{
- PTHREAD_CREATE_JOINABLE,
- PTHREAD_CREATE_DETACHED
-};
-enum
-{
- PTHREAD_MUTEX_TIMED_NP,
- PTHREAD_MUTEX_RECURSIVE_NP,
- PTHREAD_MUTEX_ERRORCHECK_NP,
- PTHREAD_MUTEX_ADAPTIVE_NP
- ,
- PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP,
- PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,
- PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP,
- PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL
- , PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_TIMED_NP
-};
-enum
-{
- PTHREAD_MUTEX_STALLED,
- PTHREAD_MUTEX_STALLED_NP = PTHREAD_MUTEX_STALLED,
- PTHREAD_MUTEX_ROBUST,
- PTHREAD_MUTEX_ROBUST_NP = PTHREAD_MUTEX_ROBUST
-};
-enum
-{
- PTHREAD_PRIO_NONE,
- PTHREAD_PRIO_INHERIT,
- PTHREAD_PRIO_PROTECT
-};
-enum
-{
- PTHREAD_RWLOCK_PREFER_READER_NP,
- PTHREAD_RWLOCK_PREFER_WRITER_NP,
- PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,
- PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_READER_NP
-};
-enum
-{
- PTHREAD_INHERIT_SCHED,
- PTHREAD_EXPLICIT_SCHED
-};
-enum
-{
- PTHREAD_SCOPE_SYSTEM,
- PTHREAD_SCOPE_PROCESS
-};
-enum
-{
- PTHREAD_PROCESS_PRIVATE,
- PTHREAD_PROCESS_SHARED
-};
-struct _pthread_cleanup_buffer
-{
- void (*__routine) (void *);
- void *__arg;
- int __canceltype;
- struct _pthread_cleanup_buffer *__prev;
-};
-enum
-{
- PTHREAD_CANCEL_ENABLE,
- PTHREAD_CANCEL_DISABLE
-};
-enum
-{
- PTHREAD_CANCEL_DEFERRED,
- PTHREAD_CANCEL_ASYNCHRONOUS
-};
-extern "C" {
-extern int pthread_create (pthread_t *__restrict __newthread,
- __const pthread_attr_t *__restrict __attr,
- void *(*__start_routine) (void *),
- void *__restrict __arg) throw () __attribute__ ((__nonnull__ (1, 3)));
-extern void pthread_exit (void *__retval) __attribute__ ((__noreturn__));
-extern int pthread_join (pthread_t __th, void **__thread_return);
-extern int pthread_tryjoin_np (pthread_t __th, void **__thread_return) throw ();
-extern int pthread_timedjoin_np (pthread_t __th, void **__thread_return,
- __const struct timespec *__abstime);
-extern int pthread_detach (pthread_t __th) throw ();
-extern pthread_t pthread_self (void) throw () __attribute__ ((__const__));
-extern int pthread_equal (pthread_t __thread1, pthread_t __thread2) throw ();
-extern int pthread_attr_init (pthread_attr_t *__attr) throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_attr_destroy (pthread_attr_t *__attr)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_attr_getdetachstate (__const pthread_attr_t *__attr,
- int *__detachstate)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int pthread_attr_setdetachstate (pthread_attr_t *__attr,
- int __detachstate)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_attr_getguardsize (__const pthread_attr_t *__attr,
- size_t *__guardsize)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int pthread_attr_setguardsize (pthread_attr_t *__attr,
- size_t __guardsize)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_attr_getschedparam (__const pthread_attr_t *__restrict
- __attr,
- struct sched_param *__restrict __param)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int pthread_attr_setschedparam (pthread_attr_t *__restrict __attr,
- __const struct sched_param *__restrict
- __param) throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int pthread_attr_getschedpolicy (__const pthread_attr_t *__restrict
- __attr, int *__restrict __policy)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int pthread_attr_setschedpolicy (pthread_attr_t *__attr, int __policy)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_attr_getinheritsched (__const pthread_attr_t *__restrict
- __attr, int *__restrict __inherit)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int pthread_attr_setinheritsched (pthread_attr_t *__attr,
- int __inherit)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_attr_getscope (__const pthread_attr_t *__restrict __attr,
- int *__restrict __scope)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int pthread_attr_setscope (pthread_attr_t *__attr, int __scope)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_attr_getstackaddr (__const pthread_attr_t *__restrict
- __attr, void **__restrict __stackaddr)
- throw () __attribute__ ((__nonnull__ (1, 2))) __attribute__ ((__deprecated__));
-extern int pthread_attr_setstackaddr (pthread_attr_t *__attr,
- void *__stackaddr)
- throw () __attribute__ ((__nonnull__ (1))) __attribute__ ((__deprecated__));
-extern int pthread_attr_getstacksize (__const pthread_attr_t *__restrict
- __attr, size_t *__restrict __stacksize)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int pthread_attr_setstacksize (pthread_attr_t *__attr,
- size_t __stacksize)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_attr_getstack (__const pthread_attr_t *__restrict __attr,
- void **__restrict __stackaddr,
- size_t *__restrict __stacksize)
- throw () __attribute__ ((__nonnull__ (1, 2, 3)));
-extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
- size_t __stacksize) throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr,
- size_t __cpusetsize,
- __const cpu_set_t *__cpuset)
- throw () __attribute__ ((__nonnull__ (1, 3)));
-extern int pthread_attr_getaffinity_np (__const pthread_attr_t *__attr,
- size_t __cpusetsize,
- cpu_set_t *__cpuset)
- throw () __attribute__ ((__nonnull__ (1, 3)));
-extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr)
- throw () __attribute__ ((__nonnull__ (2)));
-extern int pthread_setschedparam (pthread_t __target_thread, int __policy,
- __const struct sched_param *__param)
- throw () __attribute__ ((__nonnull__ (3)));
-extern int pthread_getschedparam (pthread_t __target_thread,
- int *__restrict __policy,
- struct sched_param *__restrict __param)
- throw () __attribute__ ((__nonnull__ (2, 3)));
-extern int pthread_setschedprio (pthread_t __target_thread, int __prio)
- throw ();
-extern int pthread_getname_np (pthread_t __target_thread, char *__buf,
- size_t __buflen)
- throw () __attribute__ ((__nonnull__ (2)));
-extern int pthread_setname_np (pthread_t __target_thread, __const char *__name)
- throw () __attribute__ ((__nonnull__ (2)));
-extern int pthread_getconcurrency (void) throw ();
-extern int pthread_setconcurrency (int __level) throw ();
-extern int pthread_yield (void) throw ();
-extern int pthread_setaffinity_np (pthread_t __th, size_t __cpusetsize,
- __const cpu_set_t *__cpuset)
- throw () __attribute__ ((__nonnull__ (3)));
-extern int pthread_getaffinity_np (pthread_t __th, size_t __cpusetsize,
- cpu_set_t *__cpuset)
- throw () __attribute__ ((__nonnull__ (3)));
-extern int pthread_once (pthread_once_t *__once_control,
- void (*__init_routine) (void)) __attribute__ ((__nonnull__ (1, 2)));
-extern int pthread_setcancelstate (int __state, int *__oldstate);
-extern int pthread_setcanceltype (int __type, int *__oldtype);
-extern int pthread_cancel (pthread_t __th);
-extern void pthread_testcancel (void);
-typedef struct
-{
- struct
- {
- __jmp_buf __cancel_jmp_buf;
- int __mask_was_saved;
- } __cancel_jmp_buf[1];
- void *__pad[4];
-} __pthread_unwind_buf_t __attribute__ ((__aligned__));
-struct __pthread_cleanup_frame
-{
- void (*__cancel_routine) (void *);
- void *__cancel_arg;
- int __do_it;
- int __cancel_type;
-};
-class __pthread_cleanup_class
-{
- void (*__cancel_routine) (void *);
- void *__cancel_arg;
- int __do_it;
- int __cancel_type;
- public:
- __pthread_cleanup_class (void (*__fct) (void *), void *__arg)
- : __cancel_routine (__fct), __cancel_arg (__arg), __do_it (1) { }
- ~__pthread_cleanup_class () { if (__do_it) __cancel_routine (__cancel_arg); }
- void __setdoit (int __newval) { __do_it = __newval; }
- void __defer () { pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED,
- &__cancel_type); }
- void __restore () const { pthread_setcanceltype (__cancel_type, 0); }
-};
-struct __jmp_buf_tag;
-extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) throw ();
-extern int pthread_mutex_init (pthread_mutex_t *__mutex,
- __const pthread_mutexattr_t *__mutexattr)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_mutex_destroy (pthread_mutex_t *__mutex)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_mutex_trylock (pthread_mutex_t *__mutex)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_mutex_lock (pthread_mutex_t *__mutex)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,
- __const struct timespec *__restrict
- __abstime) throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int pthread_mutex_unlock (pthread_mutex_t *__mutex)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_mutex_getprioceiling (__const pthread_mutex_t *
- __restrict __mutex,
- int *__restrict __prioceiling)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict __mutex,
- int __prioceiling,
- int *__restrict __old_ceiling)
- throw () __attribute__ ((__nonnull__ (1, 3)));
-extern int pthread_mutex_consistent (pthread_mutex_t *__mutex)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_mutex_consistent_np (pthread_mutex_t *__mutex)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_mutexattr_init (pthread_mutexattr_t *__attr)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_mutexattr_destroy (pthread_mutexattr_t *__attr)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_mutexattr_getpshared (__const pthread_mutexattr_t *
- __restrict __attr,
- int *__restrict __pshared)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int pthread_mutexattr_setpshared (pthread_mutexattr_t *__attr,
- int __pshared)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_mutexattr_gettype (__const pthread_mutexattr_t *__restrict
- __attr, int *__restrict __kind)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_mutexattr_getprotocol (__const pthread_mutexattr_t *
- __restrict __attr,
- int *__restrict __protocol)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int pthread_mutexattr_setprotocol (pthread_mutexattr_t *__attr,
- int __protocol)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_mutexattr_getprioceiling (__const pthread_mutexattr_t *
- __restrict __attr,
- int *__restrict __prioceiling)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *__attr,
- int __prioceiling)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_mutexattr_getrobust (__const pthread_mutexattr_t *__attr,
- int *__robustness)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int pthread_mutexattr_getrobust_np (__const pthread_mutexattr_t *__attr,
- int *__robustness)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int pthread_mutexattr_setrobust (pthread_mutexattr_t *__attr,
- int __robustness)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_mutexattr_setrobust_np (pthread_mutexattr_t *__attr,
- int __robustness)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
- __const pthread_rwlockattr_t *__restrict
- __attr) throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,
- __const struct timespec *__restrict
- __abstime) throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,
- __const struct timespec *__restrict
- __abstime) throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_rwlockattr_getpshared (__const pthread_rwlockattr_t *
- __restrict __attr,
- int *__restrict __pshared)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *__attr,
- int __pshared)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_rwlockattr_getkind_np (__const pthread_rwlockattr_t *
- __restrict __attr,
- int *__restrict __pref)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr,
- int __pref) throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_cond_init (pthread_cond_t *__restrict __cond,
- __const pthread_condattr_t *__restrict
- __cond_attr) throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_cond_destroy (pthread_cond_t *__cond)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_cond_signal (pthread_cond_t *__cond)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_cond_broadcast (pthread_cond_t *__cond)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
- pthread_mutex_t *__restrict __mutex)
- __attribute__ ((__nonnull__ (1, 2)));
-extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
- pthread_mutex_t *__restrict __mutex,
- __const struct timespec *__restrict
- __abstime) __attribute__ ((__nonnull__ (1, 2, 3)));
-extern int pthread_condattr_init (pthread_condattr_t *__attr)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_condattr_destroy (pthread_condattr_t *__attr)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_condattr_getpshared (__const pthread_condattr_t *
- __restrict __attr,
- int *__restrict __pshared)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int pthread_condattr_setpshared (pthread_condattr_t *__attr,
- int __pshared) throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_condattr_getclock (__const pthread_condattr_t *
- __restrict __attr,
- __clockid_t *__restrict __clock_id)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int pthread_condattr_setclock (pthread_condattr_t *__attr,
- __clockid_t __clock_id)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_spin_destroy (pthread_spinlock_t *__lock)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_spin_lock (pthread_spinlock_t *__lock)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_spin_trylock (pthread_spinlock_t *__lock)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_spin_unlock (pthread_spinlock_t *__lock)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier,
- __const pthread_barrierattr_t *__restrict
- __attr, unsigned int __count)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_barrier_destroy (pthread_barrier_t *__barrier)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_barrier_wait (pthread_barrier_t *__barrier)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_barrierattr_getpshared (__const pthread_barrierattr_t *
- __restrict __attr,
- int *__restrict __pshared)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr,
- int __pshared)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_key_create (pthread_key_t *__key,
- void (*__destr_function) (void *))
- throw () __attribute__ ((__nonnull__ (1)));
-extern int pthread_key_delete (pthread_key_t __key) throw ();
-extern void *pthread_getspecific (pthread_key_t __key) throw ();
-extern int pthread_setspecific (pthread_key_t __key,
- __const void *__pointer) throw () ;
-extern int pthread_getcpuclockid (pthread_t __thread_id,
- __clockid_t *__clock_id)
- throw () __attribute__ ((__nonnull__ (2)));
-extern int pthread_atfork (void (*__prepare) (void),
- void (*__parent) (void),
- void (*__child) (void)) throw ();
-extern __inline __attribute__ ((__gnu_inline__)) int
-pthread_equal (pthread_t __thread1, pthread_t __thread2) throw ()
-{
- return __thread1 == __thread2;
-}
-}
-extern "C" {
-typedef __ssize_t ssize_t;
-typedef __gid_t gid_t;
-typedef __uid_t uid_t;
-typedef __off_t off_t;
-typedef __off64_t off64_t;
-typedef __useconds_t useconds_t;
-typedef __intptr_t intptr_t;
-typedef __socklen_t socklen_t;
-extern int access (__const char *__name, int __type) throw () __attribute__ ((__nonnull__ (1)));
-extern int euidaccess (__const char *__name, int __type)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int eaccess (__const char *__name, int __type)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int faccessat (int __fd, __const char *__file, int __type, int __flag)
- throw () __attribute__ ((__nonnull__ (2))) ;
-extern __off_t lseek (int __fd, __off_t __offset, int __whence) throw ();
-extern __off64_t lseek64 (int __fd, __off64_t __offset, int __whence)
- throw ();
-extern int close (int __fd);
-extern ssize_t read (int __fd, void *__buf, size_t __nbytes) ;
-extern ssize_t write (int __fd, __const void *__buf, size_t __n) ;
-extern ssize_t pread (int __fd, void *__buf, size_t __nbytes,
- __off_t __offset) ;
-extern ssize_t pwrite (int __fd, __const void *__buf, size_t __n,
- __off_t __offset) ;
-extern ssize_t pread64 (int __fd, void *__buf, size_t __nbytes,
- __off64_t __offset) ;
-extern ssize_t pwrite64 (int __fd, __const void *__buf, size_t __n,
- __off64_t __offset) ;
-extern int pipe (int __pipedes[2]) throw () ;
-extern int pipe2 (int __pipedes[2], int __flags) throw () ;
-extern unsigned int alarm (unsigned int __seconds) throw ();
-extern unsigned int sleep (unsigned int __seconds);
-extern __useconds_t ualarm (__useconds_t __value, __useconds_t __interval)
- throw ();
-extern int usleep (__useconds_t __useconds);
-extern int pause (void);
-extern int chown (__const char *__file, __uid_t __owner, __gid_t __group)
- throw () __attribute__ ((__nonnull__ (1))) ;
-extern int fchown (int __fd, __uid_t __owner, __gid_t __group) throw () ;
-extern int lchown (__const char *__file, __uid_t __owner, __gid_t __group)
- throw () __attribute__ ((__nonnull__ (1))) ;
-extern int fchownat (int __fd, __const char *__file, __uid_t __owner,
- __gid_t __group, int __flag)
- throw () __attribute__ ((__nonnull__ (2))) ;
-extern int chdir (__const char *__path) throw () __attribute__ ((__nonnull__ (1))) ;
-extern int fchdir (int __fd) throw () ;
-extern char *getcwd (char *__buf, size_t __size) throw () ;
-extern char *get_current_dir_name (void) throw ();
-extern char *getwd (char *__buf)
- throw () __attribute__ ((__nonnull__ (1))) __attribute__ ((__deprecated__)) ;
-extern int dup (int __fd) throw () ;
-extern int dup2 (int __fd, int __fd2) throw ();
-extern int dup3 (int __fd, int __fd2, int __flags) throw ();
-extern char **__environ;
-extern char **environ;
-extern int execve (__const char *__path, char *__const __argv[],
- char *__const __envp[]) throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int fexecve (int __fd, char *__const __argv[], char *__const __envp[])
- throw () __attribute__ ((__nonnull__ (2)));
-extern int execv (__const char *__path, char *__const __argv[])
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int execle (__const char *__path, __const char *__arg, ...)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int execl (__const char *__path, __const char *__arg, ...)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int execvp (__const char *__file, char *__const __argv[])
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int execlp (__const char *__file, __const char *__arg, ...)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int execvpe (__const char *__file, char *__const __argv[],
- char *__const __envp[])
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int nice (int __inc) throw () ;
-extern void _exit (int __status) __attribute__ ((__noreturn__));
-enum
- {
- _PC_LINK_MAX,
- _PC_MAX_CANON,
- _PC_MAX_INPUT,
- _PC_NAME_MAX,
- _PC_PATH_MAX,
- _PC_PIPE_BUF,
- _PC_CHOWN_RESTRICTED,
- _PC_NO_TRUNC,
- _PC_VDISABLE,
- _PC_SYNC_IO,
- _PC_ASYNC_IO,
- _PC_PRIO_IO,
- _PC_SOCK_MAXBUF,
- _PC_FILESIZEBITS,
- _PC_REC_INCR_XFER_SIZE,
- _PC_REC_MAX_XFER_SIZE,
- _PC_REC_MIN_XFER_SIZE,
- _PC_REC_XFER_ALIGN,
- _PC_ALLOC_SIZE_MIN,
- _PC_SYMLINK_MAX,
- _PC_2_SYMLINKS
- };
-enum
- {
- _SC_ARG_MAX,
- _SC_CHILD_MAX,
- _SC_CLK_TCK,
- _SC_NGROUPS_MAX,
- _SC_OPEN_MAX,
- _SC_STREAM_MAX,
- _SC_TZNAME_MAX,
- _SC_JOB_CONTROL,
- _SC_SAVED_IDS,
- _SC_REALTIME_SIGNALS,
- _SC_PRIORITY_SCHEDULING,
- _SC_TIMERS,
- _SC_ASYNCHRONOUS_IO,
- _SC_PRIORITIZED_IO,
- _SC_SYNCHRONIZED_IO,
- _SC_FSYNC,
- _SC_MAPPED_FILES,
- _SC_MEMLOCK,
- _SC_MEMLOCK_RANGE,
- _SC_MEMORY_PROTECTION,
- _SC_MESSAGE_PASSING,
- _SC_SEMAPHORES,
- _SC_SHARED_MEMORY_OBJECTS,
- _SC_AIO_LISTIO_MAX,
- _SC_AIO_MAX,
- _SC_AIO_PRIO_DELTA_MAX,
- _SC_DELAYTIMER_MAX,
- _SC_MQ_OPEN_MAX,
- _SC_MQ_PRIO_MAX,
- _SC_VERSION,
- _SC_PAGESIZE,
- _SC_RTSIG_MAX,
- _SC_SEM_NSEMS_MAX,
- _SC_SEM_VALUE_MAX,
- _SC_SIGQUEUE_MAX,
- _SC_TIMER_MAX,
- _SC_BC_BASE_MAX,
- _SC_BC_DIM_MAX,
- _SC_BC_SCALE_MAX,
- _SC_BC_STRING_MAX,
- _SC_COLL_WEIGHTS_MAX,
- _SC_EQUIV_CLASS_MAX,
- _SC_EXPR_NEST_MAX,
- _SC_LINE_MAX,
- _SC_RE_DUP_MAX,
- _SC_CHARCLASS_NAME_MAX,
- _SC_2_VERSION,
- _SC_2_C_BIND,
- _SC_2_C_DEV,
- _SC_2_FORT_DEV,
- _SC_2_FORT_RUN,
- _SC_2_SW_DEV,
- _SC_2_LOCALEDEF,
- _SC_PII,
- _SC_PII_XTI,
- _SC_PII_SOCKET,
- _SC_PII_INTERNET,
- _SC_PII_OSI,
- _SC_POLL,
- _SC_SELECT,
- _SC_UIO_MAXIOV,
- _SC_IOV_MAX = _SC_UIO_MAXIOV,
- _SC_PII_INTERNET_STREAM,
- _SC_PII_INTERNET_DGRAM,
- _SC_PII_OSI_COTS,
- _SC_PII_OSI_CLTS,
- _SC_PII_OSI_M,
- _SC_T_IOV_MAX,
- _SC_THREADS,
- _SC_THREAD_SAFE_FUNCTIONS,
- _SC_GETGR_R_SIZE_MAX,
- _SC_GETPW_R_SIZE_MAX,
- _SC_LOGIN_NAME_MAX,
- _SC_TTY_NAME_MAX,
- _SC_THREAD_DESTRUCTOR_ITERATIONS,
- _SC_THREAD_KEYS_MAX,
- _SC_THREAD_STACK_MIN,
- _SC_THREAD_THREADS_MAX,
- _SC_THREAD_ATTR_STACKADDR,
- _SC_THREAD_ATTR_STACKSIZE,
- _SC_THREAD_PRIORITY_SCHEDULING,
- _SC_THREAD_PRIO_INHERIT,
- _SC_THREAD_PRIO_PROTECT,
- _SC_THREAD_PROCESS_SHARED,
- _SC_NPROCESSORS_CONF,
- _SC_NPROCESSORS_ONLN,
- _SC_PHYS_PAGES,
- _SC_AVPHYS_PAGES,
- _SC_ATEXIT_MAX,
- _SC_PASS_MAX,
- _SC_XOPEN_VERSION,
- _SC_XOPEN_XCU_VERSION,
- _SC_XOPEN_UNIX,
- _SC_XOPEN_CRYPT,
- _SC_XOPEN_ENH_I18N,
- _SC_XOPEN_SHM,
- _SC_2_CHAR_TERM,
- _SC_2_C_VERSION,
- _SC_2_UPE,
- _SC_XOPEN_XPG2,
- _SC_XOPEN_XPG3,
- _SC_XOPEN_XPG4,
- _SC_CHAR_BIT,
- _SC_CHAR_MAX,
- _SC_CHAR_MIN,
- _SC_INT_MAX,
- _SC_INT_MIN,
- _SC_LONG_BIT,
- _SC_WORD_BIT,
- _SC_MB_LEN_MAX,
- _SC_NZERO,
- _SC_SSIZE_MAX,
- _SC_SCHAR_MAX,
- _SC_SCHAR_MIN,
- _SC_SHRT_MAX,
- _SC_SHRT_MIN,
- _SC_UCHAR_MAX,
- _SC_UINT_MAX,
- _SC_ULONG_MAX,
- _SC_USHRT_MAX,
- _SC_NL_ARGMAX,
- _SC_NL_LANGMAX,
- _SC_NL_MSGMAX,
- _SC_NL_NMAX,
- _SC_NL_SETMAX,
- _SC_NL_TEXTMAX,
- _SC_XBS5_ILP32_OFF32,
- _SC_XBS5_ILP32_OFFBIG,
- _SC_XBS5_LP64_OFF64,
- _SC_XBS5_LPBIG_OFFBIG,
- _SC_XOPEN_LEGACY,
- _SC_XOPEN_REALTIME,
- _SC_XOPEN_REALTIME_THREADS,
- _SC_ADVISORY_INFO,
- _SC_BARRIERS,
- _SC_BASE,
- _SC_C_LANG_SUPPORT,
- _SC_C_LANG_SUPPORT_R,
- _SC_CLOCK_SELECTION,
- _SC_CPUTIME,
- _SC_THREAD_CPUTIME,
- _SC_DEVICE_IO,
- _SC_DEVICE_SPECIFIC,
- _SC_DEVICE_SPECIFIC_R,
- _SC_FD_MGMT,
- _SC_FIFO,
- _SC_PIPE,
- _SC_FILE_ATTRIBUTES,
- _SC_FILE_LOCKING,
- _SC_FILE_SYSTEM,
- _SC_MONOTONIC_CLOCK,
- _SC_MULTI_PROCESS,
- _SC_SINGLE_PROCESS,
- _SC_NETWORKING,
- _SC_READER_WRITER_LOCKS,
- _SC_SPIN_LOCKS,
- _SC_REGEXP,
- _SC_REGEX_VERSION,
- _SC_SHELL,
- _SC_SIGNALS,
- _SC_SPAWN,
- _SC_SPORADIC_SERVER,
- _SC_THREAD_SPORADIC_SERVER,
- _SC_SYSTEM_DATABASE,
- _SC_SYSTEM_DATABASE_R,
- _SC_TIMEOUTS,
- _SC_TYPED_MEMORY_OBJECTS,
- _SC_USER_GROUPS,
- _SC_USER_GROUPS_R,
- _SC_2_PBS,
- _SC_2_PBS_ACCOUNTING,
- _SC_2_PBS_LOCATE,
- _SC_2_PBS_MESSAGE,
- _SC_2_PBS_TRACK,
- _SC_SYMLOOP_MAX,
- _SC_STREAMS,
- _SC_2_PBS_CHECKPOINT,
- _SC_V6_ILP32_OFF32,
- _SC_V6_ILP32_OFFBIG,
- _SC_V6_LP64_OFF64,
- _SC_V6_LPBIG_OFFBIG,
- _SC_HOST_NAME_MAX,
- _SC_TRACE,
- _SC_TRACE_EVENT_FILTER,
- _SC_TRACE_INHERIT,
- _SC_TRACE_LOG,
- _SC_LEVEL1_ICACHE_SIZE,
- _SC_LEVEL1_ICACHE_ASSOC,
- _SC_LEVEL1_ICACHE_LINESIZE,
- _SC_LEVEL1_DCACHE_SIZE,
- _SC_LEVEL1_DCACHE_ASSOC,
- _SC_LEVEL1_DCACHE_LINESIZE,
- _SC_LEVEL2_CACHE_SIZE,
- _SC_LEVEL2_CACHE_ASSOC,
- _SC_LEVEL2_CACHE_LINESIZE,
- _SC_LEVEL3_CACHE_SIZE,
- _SC_LEVEL3_CACHE_ASSOC,
- _SC_LEVEL3_CACHE_LINESIZE,
- _SC_LEVEL4_CACHE_SIZE,
- _SC_LEVEL4_CACHE_ASSOC,
- _SC_LEVEL4_CACHE_LINESIZE,
- _SC_IPV6 = _SC_LEVEL1_ICACHE_SIZE + 50,
- _SC_RAW_SOCKETS,
- _SC_V7_ILP32_OFF32,
- _SC_V7_ILP32_OFFBIG,
- _SC_V7_LP64_OFF64,
- _SC_V7_LPBIG_OFFBIG,
- _SC_SS_REPL_MAX,
- _SC_TRACE_EVENT_NAME_MAX,
- _SC_TRACE_NAME_MAX,
- _SC_TRACE_SYS_MAX,
- _SC_TRACE_USER_EVENT_MAX,
- _SC_XOPEN_STREAMS,
- _SC_THREAD_ROBUST_PRIO_INHERIT,
- _SC_THREAD_ROBUST_PRIO_PROTECT
- };
-enum
- {
- _CS_PATH,
- _CS_V6_WIDTH_RESTRICTED_ENVS,
- _CS_GNU_LIBC_VERSION,
- _CS_GNU_LIBPTHREAD_VERSION,
- _CS_V5_WIDTH_RESTRICTED_ENVS,
- _CS_V7_WIDTH_RESTRICTED_ENVS,
- _CS_LFS_CFLAGS = 1000,
- _CS_LFS_LDFLAGS,
- _CS_LFS_LIBS,
- _CS_LFS_LINTFLAGS,
- _CS_LFS64_CFLAGS,
- _CS_LFS64_LDFLAGS,
- _CS_LFS64_LIBS,
- _CS_LFS64_LINTFLAGS,
- _CS_XBS5_ILP32_OFF32_CFLAGS = 1100,
- _CS_XBS5_ILP32_OFF32_LDFLAGS,
- _CS_XBS5_ILP32_OFF32_LIBS,
- _CS_XBS5_ILP32_OFF32_LINTFLAGS,
- _CS_XBS5_ILP32_OFFBIG_CFLAGS,
- _CS_XBS5_ILP32_OFFBIG_LDFLAGS,
- _CS_XBS5_ILP32_OFFBIG_LIBS,
- _CS_XBS5_ILP32_OFFBIG_LINTFLAGS,
- _CS_XBS5_LP64_OFF64_CFLAGS,
- _CS_XBS5_LP64_OFF64_LDFLAGS,
- _CS_XBS5_LP64_OFF64_LIBS,
- _CS_XBS5_LP64_OFF64_LINTFLAGS,
- _CS_XBS5_LPBIG_OFFBIG_CFLAGS,
- _CS_XBS5_LPBIG_OFFBIG_LDFLAGS,
- _CS_XBS5_LPBIG_OFFBIG_LIBS,
- _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS,
- _CS_POSIX_V6_ILP32_OFF32_CFLAGS,
- _CS_POSIX_V6_ILP32_OFF32_LDFLAGS,
- _CS_POSIX_V6_ILP32_OFF32_LIBS,
- _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS,
- _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS,
- _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS,
- _CS_POSIX_V6_ILP32_OFFBIG_LIBS,
- _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS,
- _CS_POSIX_V6_LP64_OFF64_CFLAGS,
- _CS_POSIX_V6_LP64_OFF64_LDFLAGS,
- _CS_POSIX_V6_LP64_OFF64_LIBS,
- _CS_POSIX_V6_LP64_OFF64_LINTFLAGS,
- _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS,
- _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS,
- _CS_POSIX_V6_LPBIG_OFFBIG_LIBS,
- _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS,
- _CS_POSIX_V7_ILP32_OFF32_CFLAGS,
- _CS_POSIX_V7_ILP32_OFF32_LDFLAGS,
- _CS_POSIX_V7_ILP32_OFF32_LIBS,
- _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS,
- _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS,
- _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS,
- _CS_POSIX_V7_ILP32_OFFBIG_LIBS,
- _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS,
- _CS_POSIX_V7_LP64_OFF64_CFLAGS,
- _CS_POSIX_V7_LP64_OFF64_LDFLAGS,
- _CS_POSIX_V7_LP64_OFF64_LIBS,
- _CS_POSIX_V7_LP64_OFF64_LINTFLAGS,
- _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS,
- _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS,
- _CS_POSIX_V7_LPBIG_OFFBIG_LIBS,
- _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS,
- _CS_V6_ENV,
- _CS_V7_ENV
- };
-extern long int pathconf (__const char *__path, int __name)
- throw () __attribute__ ((__nonnull__ (1)));
-extern long int fpathconf (int __fd, int __name) throw ();
-extern long int sysconf (int __name) throw ();
-extern size_t confstr (int __name, char *__buf, size_t __len) throw ();
-extern __pid_t getpid (void) throw ();
-extern __pid_t getppid (void) throw ();
-extern __pid_t getpgrp (void) throw ();
-extern __pid_t __getpgid (__pid_t __pid) throw ();
-extern __pid_t getpgid (__pid_t __pid) throw ();
-extern int setpgid (__pid_t __pid, __pid_t __pgid) throw ();
-extern int setpgrp (void) throw ();
-extern __pid_t setsid (void) throw ();
-extern __pid_t getsid (__pid_t __pid) throw ();
-extern __uid_t getuid (void) throw ();
-extern __uid_t geteuid (void) throw ();
-extern __gid_t getgid (void) throw ();
-extern __gid_t getegid (void) throw ();
-extern int getgroups (int __size, __gid_t __list[]) throw () ;
-extern int group_member (__gid_t __gid) throw ();
-extern int setuid (__uid_t __uid) throw ();
-extern int setreuid (__uid_t __ruid, __uid_t __euid) throw ();
-extern int seteuid (__uid_t __uid) throw ();
-extern int setgid (__gid_t __gid) throw ();
-extern int setregid (__gid_t __rgid, __gid_t __egid) throw ();
-extern int setegid (__gid_t __gid) throw ();
-extern int getresuid (__uid_t *__ruid, __uid_t *__euid, __uid_t *__suid)
- throw ();
-extern int getresgid (__gid_t *__rgid, __gid_t *__egid, __gid_t *__sgid)
- throw ();
-extern int setresuid (__uid_t __ruid, __uid_t __euid, __uid_t __suid)
- throw ();
-extern int setresgid (__gid_t __rgid, __gid_t __egid, __gid_t __sgid)
- throw ();
-extern __pid_t fork (void) throw ();
-extern __pid_t vfork (void) throw ();
-extern char *ttyname (int __fd) throw ();
-extern int ttyname_r (int __fd, char *__buf, size_t __buflen)
- throw () __attribute__ ((__nonnull__ (2))) ;
-extern int isatty (int __fd) throw ();
-extern int ttyslot (void) throw ();
-extern int link (__const char *__from, __const char *__to)
- throw () __attribute__ ((__nonnull__ (1, 2))) ;
-extern int linkat (int __fromfd, __const char *__from, int __tofd,
- __const char *__to, int __flags)
- throw () __attribute__ ((__nonnull__ (2, 4))) ;
-extern int symlink (__const char *__from, __const char *__to)
- throw () __attribute__ ((__nonnull__ (1, 2))) ;
-extern ssize_t readlink (__const char *__restrict __path,
- char *__restrict __buf, size_t __len)
- throw () __attribute__ ((__nonnull__ (1, 2))) ;
-extern int symlinkat (__const char *__from, int __tofd,
- __const char *__to) throw () __attribute__ ((__nonnull__ (1, 3))) ;
-extern ssize_t readlinkat (int __fd, __const char *__restrict __path,
- char *__restrict __buf, size_t __len)
- throw () __attribute__ ((__nonnull__ (2, 3))) ;
-extern int unlink (__const char *__name) throw () __attribute__ ((__nonnull__ (1)));
-extern int unlinkat (int __fd, __const char *__name, int __flag)
- throw () __attribute__ ((__nonnull__ (2)));
-extern int rmdir (__const char *__path) throw () __attribute__ ((__nonnull__ (1)));
-extern __pid_t tcgetpgrp (int __fd) throw ();
-extern int tcsetpgrp (int __fd, __pid_t __pgrp_id) throw ();
-extern char *getlogin (void);
-extern int getlogin_r (char *__name, size_t __name_len) __attribute__ ((__nonnull__ (1)));
-extern int setlogin (__const char *__name) throw () __attribute__ ((__nonnull__ (1)));
-extern "C" {
-extern char *optarg;
-extern int optind;
-extern int opterr;
-extern int optopt;
-extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
- throw ();
-}
-extern int gethostname (char *__name, size_t __len) throw () __attribute__ ((__nonnull__ (1)));
-extern int sethostname (__const char *__name, size_t __len)
- throw () __attribute__ ((__nonnull__ (1))) ;
-extern int sethostid (long int __id) throw () ;
-extern int getdomainname (char *__name, size_t __len)
- throw () __attribute__ ((__nonnull__ (1))) ;
-extern int setdomainname (__const char *__name, size_t __len)
- throw () __attribute__ ((__nonnull__ (1))) ;
-extern int vhangup (void) throw ();
-extern int revoke (__const char *__file) throw () __attribute__ ((__nonnull__ (1))) ;
-extern int profil (unsigned short int *__sample_buffer, size_t __size,
- size_t __offset, unsigned int __scale)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int acct (__const char *__name) throw ();
-extern char *getusershell (void) throw ();
-extern void endusershell (void) throw ();
-extern void setusershell (void) throw ();
-extern int daemon (int __nochdir, int __noclose) throw () ;
-extern int chroot (__const char *__path) throw () __attribute__ ((__nonnull__ (1))) ;
-extern char *getpass (__const char *__prompt) __attribute__ ((__nonnull__ (1)));
-extern int fsync (int __fd);
-extern long int gethostid (void);
-extern void sync (void) throw ();
-extern int getpagesize (void) throw () __attribute__ ((__const__));
-extern int getdtablesize (void) throw ();
-extern int truncate (__const char *__file, __off_t __length)
- throw () __attribute__ ((__nonnull__ (1))) ;
-extern int truncate64 (__const char *__file, __off64_t __length)
- throw () __attribute__ ((__nonnull__ (1))) ;
-extern int ftruncate (int __fd, __off_t __length) throw () ;
-extern int ftruncate64 (int __fd, __off64_t __length) throw () ;
-extern int brk (void *__addr) throw () ;
-extern void *sbrk (intptr_t __delta) throw ();
-extern long int syscall (long int __sysno, ...) throw ();
-extern int lockf (int __fd, int __cmd, __off_t __len) ;
-extern int lockf64 (int __fd, int __cmd, __off64_t __len) ;
-extern int fdatasync (int __fildes);
-extern char *crypt (__const char *__key, __const char *__salt)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern void encrypt (char *__libc_block, int __edflag) throw () __attribute__ ((__nonnull__ (1)));
-extern void swab (__const void *__restrict __from, void *__restrict __to,
- ssize_t __n) throw () __attribute__ ((__nonnull__ (1, 2)));
-extern char *ctermid (char *__s) throw ();
-}
-typedef pthread_t __gthread_t;
-typedef pthread_key_t __gthread_key_t;
-typedef pthread_once_t __gthread_once_t;
-typedef pthread_mutex_t __gthread_mutex_t;
-typedef pthread_mutex_t __gthread_recursive_mutex_t;
-typedef pthread_cond_t __gthread_cond_t;
-typedef struct timespec __gthread_time_t;
-static __typeof(pthread_once) __gthrw_pthread_once __attribute__ ((__weakref__("pthread_once")));
-static __typeof(pthread_getspecific) __gthrw_pthread_getspecific __attribute__ ((__weakref__("pthread_getspecific")));
-static __typeof(pthread_setspecific) __gthrw_pthread_setspecific __attribute__ ((__weakref__("pthread_setspecific")));
-static __typeof(pthread_create) __gthrw_pthread_create __attribute__ ((__weakref__("pthread_create")));
-static __typeof(pthread_join) __gthrw_pthread_join __attribute__ ((__weakref__("pthread_join")));
-static __typeof(pthread_equal) __gthrw_pthread_equal __attribute__ ((__weakref__("pthread_equal")));
-static __typeof(pthread_self) __gthrw_pthread_self __attribute__ ((__weakref__("pthread_self")));
-static __typeof(pthread_detach) __gthrw_pthread_detach __attribute__ ((__weakref__("pthread_detach")));
-static __typeof(pthread_cancel) __gthrw_pthread_cancel __attribute__ ((__weakref__("pthread_cancel")));
-static __typeof(sched_yield) __gthrw_sched_yield __attribute__ ((__weakref__("sched_yield")));
-static __typeof(pthread_mutex_lock) __gthrw_pthread_mutex_lock __attribute__ ((__weakref__("pthread_mutex_lock")));
-static __typeof(pthread_mutex_trylock) __gthrw_pthread_mutex_trylock __attribute__ ((__weakref__("pthread_mutex_trylock")));
-static __typeof(pthread_mutex_timedlock) __gthrw_pthread_mutex_timedlock __attribute__ ((__weakref__("pthread_mutex_timedlock")));
-static __typeof(pthread_mutex_unlock) __gthrw_pthread_mutex_unlock __attribute__ ((__weakref__("pthread_mutex_unlock")));
-static __typeof(pthread_mutex_init) __gthrw_pthread_mutex_init __attribute__ ((__weakref__("pthread_mutex_init")));
-static __typeof(pthread_mutex_destroy) __gthrw_pthread_mutex_destroy __attribute__ ((__weakref__("pthread_mutex_destroy")));
-static __typeof(pthread_cond_broadcast) __gthrw_pthread_cond_broadcast __attribute__ ((__weakref__("pthread_cond_broadcast")));
-static __typeof(pthread_cond_signal) __gthrw_pthread_cond_signal __attribute__ ((__weakref__("pthread_cond_signal")));
-static __typeof(pthread_cond_wait) __gthrw_pthread_cond_wait __attribute__ ((__weakref__("pthread_cond_wait")));
-static __typeof(pthread_cond_timedwait) __gthrw_pthread_cond_timedwait __attribute__ ((__weakref__("pthread_cond_timedwait")));
-static __typeof(pthread_cond_destroy) __gthrw_pthread_cond_destroy __attribute__ ((__weakref__("pthread_cond_destroy")));
-static __typeof(pthread_key_create) __gthrw_pthread_key_create __attribute__ ((__weakref__("pthread_key_create")));
-static __typeof(pthread_key_delete) __gthrw_pthread_key_delete __attribute__ ((__weakref__("pthread_key_delete")));
-static __typeof(pthread_mutexattr_init) __gthrw_pthread_mutexattr_init __attribute__ ((__weakref__("pthread_mutexattr_init")));
-static __typeof(pthread_mutexattr_settype) __gthrw_pthread_mutexattr_settype __attribute__ ((__weakref__("pthread_mutexattr_settype")));
-static __typeof(pthread_mutexattr_destroy) __gthrw_pthread_mutexattr_destroy __attribute__ ((__weakref__("pthread_mutexattr_destroy")));
-static inline int
-__gthread_active_p (void)
-{
- static void *const __gthread_active_ptr
- = __extension__ (void *) &
- __gthrw_pthread_cancel;
- return __gthread_active_ptr != 0;
-}
-static inline int
-__gthread_create (__gthread_t *__threadid, void *(*__func) (void*),
- void *__args)
-{
- return __gthrw_pthread_create (__threadid, __null, __func, __args);
-}
-static inline int
-__gthread_join (__gthread_t __threadid, void **__value_ptr)
-{
- return __gthrw_pthread_join (__threadid, __value_ptr);
-}
-static inline int
-__gthread_detach (__gthread_t __threadid)
-{
- return __gthrw_pthread_detach (__threadid);
-}
-static inline int
-__gthread_equal (__gthread_t __t1, __gthread_t __t2)
-{
- return __gthrw_pthread_equal (__t1, __t2);
-}
-static inline __gthread_t
-__gthread_self (void)
-{
- return __gthrw_pthread_self ();
-}
-static inline int
-__gthread_yield (void)
-{
- return __gthrw_sched_yield ();
-}
-static inline int
-__gthread_once (__gthread_once_t *__once, void (*__func) (void))
-{
- if (__gthread_active_p ())
- return __gthrw_pthread_once (__once, __func);
- else
- return -1;
-}
-static inline int
-__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *))
-{
- return __gthrw_pthread_key_create (__key, __dtor);
-}
-static inline int
-__gthread_key_delete (__gthread_key_t __key)
-{
- return __gthrw_pthread_key_delete (__key);
-}
-static inline void *
-__gthread_getspecific (__gthread_key_t __key)
-{
- return __gthrw_pthread_getspecific (__key);
-}
-static inline int
-__gthread_setspecific (__gthread_key_t __key, const void *__ptr)
-{
- return __gthrw_pthread_setspecific (__key, __ptr);
-}
-static inline int
-__gthread_mutex_destroy (__gthread_mutex_t *__mutex)
-{
- if (__gthread_active_p ())
- return __gthrw_pthread_mutex_destroy (__mutex);
- else
- return 0;
-}
-static inline int
-__gthread_mutex_lock (__gthread_mutex_t *__mutex)
-{
- if (__gthread_active_p ())
- return __gthrw_pthread_mutex_lock (__mutex);
- else
- return 0;
-}
-static inline int
-__gthread_mutex_trylock (__gthread_mutex_t *__mutex)
-{
- if (__gthread_active_p ())
- return __gthrw_pthread_mutex_trylock (__mutex);
- else
- return 0;
-}
-static inline int
-__gthread_mutex_timedlock (__gthread_mutex_t *__mutex,
- const __gthread_time_t *__abs_timeout)
-{
- if (__gthread_active_p ())
- return __gthrw_pthread_mutex_timedlock (__mutex, __abs_timeout);
- else
- return 0;
-}
-static inline int
-__gthread_mutex_unlock (__gthread_mutex_t *__mutex)
-{
- if (__gthread_active_p ())
- return __gthrw_pthread_mutex_unlock (__mutex);
- else
- return 0;
-}
-static inline int
-__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
-{
- return __gthread_mutex_lock (__mutex);
-}
-static inline int
-__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
-{
- return __gthread_mutex_trylock (__mutex);
-}
-static inline int
-__gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex,
- const __gthread_time_t *__abs_timeout)
-{
- return __gthread_mutex_timedlock (__mutex, __abs_timeout);
-}
-static inline int
-__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
-{
- return __gthread_mutex_unlock (__mutex);
-}
-static inline int
-__gthread_cond_broadcast (__gthread_cond_t *__cond)
-{
- return __gthrw_pthread_cond_broadcast (__cond);
-}
-static inline int
-__gthread_cond_signal (__gthread_cond_t *__cond)
-{
- return __gthrw_pthread_cond_signal (__cond);
-}
-static inline int
-__gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex)
-{
- return __gthrw_pthread_cond_wait (__cond, __mutex);
-}
-static inline int
-__gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex,
- const __gthread_time_t *__abs_timeout)
-{
- return __gthrw_pthread_cond_timedwait (__cond, __mutex, __abs_timeout);
-}
-static inline int
-__gthread_cond_wait_recursive (__gthread_cond_t *__cond,
- __gthread_recursive_mutex_t *__mutex)
-{
- return __gthread_cond_wait (__cond, __mutex);
-}
-static inline int
-__gthread_cond_timedwait_recursive (__gthread_cond_t *__cond,
- __gthread_recursive_mutex_t *__mutex,
- const __gthread_time_t *__abs_timeout)
-{
- return __gthread_cond_timedwait (__cond, __mutex, __abs_timeout);
-}
-static inline int
-__gthread_cond_destroy (__gthread_cond_t* __cond)
-{
- return __gthrw_pthread_cond_destroy (__cond);
-}
-#pragma GCC visibility pop
-typedef int _Atomic_word;
-namespace __gnu_cxx __attribute__ ((__visibility__ ("default")))
-{
- static inline _Atomic_word
- __exchange_and_add(volatile _Atomic_word* __mem, int __val)
- { return __sync_fetch_and_add(__mem, __val); }
- static inline void
- __atomic_add(volatile _Atomic_word* __mem, int __val)
- { __sync_fetch_and_add(__mem, __val); }
- static inline _Atomic_word
- __exchange_and_add_single(_Atomic_word* __mem, int __val)
- {
- _Atomic_word __result = *__mem;
- *__mem += __val;
- return __result;
- }
- static inline void
- __atomic_add_single(_Atomic_word* __mem, int __val)
- { *__mem += __val; }
- static inline _Atomic_word
- __attribute__ ((__unused__))
- __exchange_and_add_dispatch(_Atomic_word* __mem, int __val)
- {
- if (__gthread_active_p())
- return __exchange_and_add(__mem, __val);
- else
- return __exchange_and_add_single(__mem, __val);
- }
- static inline void
- __attribute__ ((__unused__))
- __atomic_add_dispatch(_Atomic_word* __mem, int __val)
- {
- if (__gthread_active_p())
- __atomic_add(__mem, __val);
- else
- __atomic_add_single(__mem, __val);
- }
-}
-#pragma GCC visibility push(default)
-extern "C++" {
-namespace std
-{
- class bad_alloc : public exception
- {
- public:
- bad_alloc() throw() { }
- virtual ~bad_alloc() throw();
- virtual const char* what() const throw();
- };
- struct nothrow_t { };
- extern const nothrow_t nothrow;
- typedef void (*new_handler)();
- new_handler set_new_handler(new_handler) throw();
-}
-void* operator new(std::size_t) throw (std::bad_alloc);
-void* operator new[](std::size_t) throw (std::bad_alloc);
-void operator delete(void*) throw();
-void operator delete[](void*) throw();
-void* operator new(std::size_t, const std::nothrow_t&) throw();
-void* operator new[](std::size_t, const std::nothrow_t&) throw();
-void operator delete(void*, const std::nothrow_t&) throw();
-void operator delete[](void*, const std::nothrow_t&) throw();
-inline void* operator new(std::size_t, void* __p) throw() { return __p; }
-inline void* operator new[](std::size_t, void* __p) throw() { return __p; }
-inline void operator delete (void*, void*) throw() { }
-inline void operator delete[](void*, void*) throw() { }
-}
-#pragma GCC visibility pop
-namespace __gnu_cxx __attribute__ ((__visibility__ ("default")))
-{
- using std::size_t;
- using std::ptrdiff_t;
- template<typename _Tp>
- class new_allocator
- {
- public:
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
- typedef _Tp* pointer;
- typedef const _Tp* const_pointer;
- typedef _Tp& reference;
- typedef const _Tp& const_reference;
- typedef _Tp value_type;
- template<typename _Tp1>
- struct rebind
- { typedef new_allocator<_Tp1> other; };
- new_allocator() throw() { }
- new_allocator(const new_allocator&) throw() { }
- template<typename _Tp1>
- new_allocator(const new_allocator<_Tp1>&) throw() { }
- ~new_allocator() throw() { }
- pointer
- address(reference __x) const { return std::__addressof(__x); }
- const_pointer
- address(const_reference __x) const { return std::__addressof(__x); }
- pointer
- allocate(size_type __n, const void* = 0)
- {
- if (__n > this->max_size())
- std::__throw_bad_alloc();
- return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));
- }
- void
- deallocate(pointer __p, size_type)
- { ::operator delete(__p); }
- size_type
- max_size() const throw()
- { return size_t(-1) / sizeof(_Tp); }
- void
- construct(pointer __p, const _Tp& __val)
- { ::new((void *)__p) _Tp(__val); }
- void
- destroy(pointer __p) { __p->~_Tp(); }
- };
- template<typename _Tp>
- inline bool
- operator==(const new_allocator<_Tp>&, const new_allocator<_Tp>&)
- { return true; }
- template<typename _Tp>
- inline bool
- operator!=(const new_allocator<_Tp>&, const new_allocator<_Tp>&)
- { return false; }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _Tp>
- class allocator;
- template<>
- class allocator<void>
- {
- public:
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
- typedef void* pointer;
- typedef const void* const_pointer;
- typedef void value_type;
- template<typename _Tp1>
- struct rebind
- { typedef allocator<_Tp1> other; };
- };
- template<typename _Tp>
- class allocator: public __gnu_cxx::new_allocator<_Tp>
- {
- public:
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
- typedef _Tp* pointer;
- typedef const _Tp* const_pointer;
- typedef _Tp& reference;
- typedef const _Tp& const_reference;
- typedef _Tp value_type;
- template<typename _Tp1>
- struct rebind
- { typedef allocator<_Tp1> other; };
- allocator() throw() { }
- allocator(const allocator& __a) throw()
- : __gnu_cxx::new_allocator<_Tp>(__a) { }
- template<typename _Tp1>
- allocator(const allocator<_Tp1>&) throw() { }
- ~allocator() throw() { }
- };
- template<typename _T1, typename _T2>
- inline bool
- operator==(const allocator<_T1>&, const allocator<_T2>&)
- { return true; }
- template<typename _Tp>
- inline bool
- operator==(const allocator<_Tp>&, const allocator<_Tp>&)
- { return true; }
- template<typename _T1, typename _T2>
- inline bool
- operator!=(const allocator<_T1>&, const allocator<_T2>&)
- { return false; }
- template<typename _Tp>
- inline bool
- operator!=(const allocator<_Tp>&, const allocator<_Tp>&)
- { return false; }
- extern template class allocator<char>;
- extern template class allocator<wchar_t>;
- template<typename _Alloc, bool = __is_empty(_Alloc)>
- struct __alloc_swap
- { static void _S_do_it(_Alloc&, _Alloc&) { } };
- template<typename _Alloc>
- struct __alloc_swap<_Alloc, false>
- {
- static void
- _S_do_it(_Alloc& __one, _Alloc& __two)
- {
- if (__one != __two)
- swap(__one, __two);
- }
- };
- template<typename _Alloc, bool = __is_empty(_Alloc)>
- struct __alloc_neq
- {
- static bool
- _S_do_it(const _Alloc&, const _Alloc&)
- { return false; }
- };
- template<typename _Alloc>
- struct __alloc_neq<_Alloc, false>
- {
- static bool
- _S_do_it(const _Alloc& __one, const _Alloc& __two)
- { return __one != __two; }
- };
-}
-#pragma GCC visibility push(default)
-namespace __cxxabiv1
-{
- class __forced_unwind
- {
- virtual ~__forced_unwind() throw();
- virtual void __pure_dummy() = 0;
- };
-}
-#pragma GCC visibility pop
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _CharT, typename _Traits>
- inline void
- __ostream_write(basic_ostream<_CharT, _Traits>& __out,
- const _CharT* __s, streamsize __n)
- {
- typedef basic_ostream<_CharT, _Traits> __ostream_type;
- typedef typename __ostream_type::ios_base __ios_base;
- const streamsize __put = __out.rdbuf()->sputn(__s, __n);
- if (__put != __n)
- __out.setstate(__ios_base::badbit);
- }
- template<typename _CharT, typename _Traits>
- inline void
- __ostream_fill(basic_ostream<_CharT, _Traits>& __out, streamsize __n)
- {
- typedef basic_ostream<_CharT, _Traits> __ostream_type;
- typedef typename __ostream_type::ios_base __ios_base;
- const _CharT __c = __out.fill();
- for (; __n > 0; --__n)
- {
- const typename _Traits::int_type __put = __out.rdbuf()->sputc(__c);
- if (_Traits::eq_int_type(__put, _Traits::eof()))
- {
- __out.setstate(__ios_base::badbit);
- break;
- }
- }
- }
- template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>&
- __ostream_insert(basic_ostream<_CharT, _Traits>& __out,
- const _CharT* __s, streamsize __n)
- {
- typedef basic_ostream<_CharT, _Traits> __ostream_type;
- typedef typename __ostream_type::ios_base __ios_base;
- typename __ostream_type::sentry __cerb(__out);
- if (__cerb)
- {
- try
- {
- const streamsize __w = __out.width();
- if (__w > __n)
- {
- const bool __left = ((__out.flags()
- & __ios_base::adjustfield)
- == __ios_base::left);
- if (!__left)
- __ostream_fill(__out, __w - __n);
- if (__out.good())
- __ostream_write(__out, __s, __n);
- if (__left && __out.good())
- __ostream_fill(__out, __w - __n);
- }
- else
- __ostream_write(__out, __s, __n);
- __out.width(0);
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- __out._M_setstate(__ios_base::badbit);
- throw;
- }
- catch(...)
- { __out._M_setstate(__ios_base::badbit); }
- }
- return __out;
- }
- extern template ostream& __ostream_insert(ostream&, const char*, streamsize);
- extern template wostream& __ostream_insert(wostream&, const wchar_t*,
- streamsize);
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _Arg, typename _Result>
- struct unary_function
- {
- typedef _Arg argument_type;
- typedef _Result result_type;
- };
- template<typename _Arg1, typename _Arg2, typename _Result>
- struct binary_function
- {
- typedef _Arg1 first_argument_type;
- typedef _Arg2 second_argument_type;
- typedef _Result result_type;
- };
- template<typename _Tp>
- struct plus : public binary_function<_Tp, _Tp, _Tp>
- {
- _Tp
- operator()(const _Tp& __x, const _Tp& __y) const
- { return __x + __y; }
- };
- template<typename _Tp>
- struct minus : public binary_function<_Tp, _Tp, _Tp>
- {
- _Tp
- operator()(const _Tp& __x, const _Tp& __y) const
- { return __x - __y; }
- };
- template<typename _Tp>
- struct multiplies : public binary_function<_Tp, _Tp, _Tp>
- {
- _Tp
- operator()(const _Tp& __x, const _Tp& __y) const
- { return __x * __y; }
- };
- template<typename _Tp>
- struct divides : public binary_function<_Tp, _Tp, _Tp>
- {
- _Tp
- operator()(const _Tp& __x, const _Tp& __y) const
- { return __x / __y; }
- };
- template<typename _Tp>
- struct modulus : public binary_function<_Tp, _Tp, _Tp>
- {
- _Tp
- operator()(const _Tp& __x, const _Tp& __y) const
- { return __x % __y; }
- };
- template<typename _Tp>
- struct negate : public unary_function<_Tp, _Tp>
- {
- _Tp
- operator()(const _Tp& __x) const
- { return -__x; }
- };
- template<typename _Tp>
- struct equal_to : public binary_function<_Tp, _Tp, bool>
- {
- bool
- operator()(const _Tp& __x, const _Tp& __y) const
- { return __x == __y; }
- };
- template<typename _Tp>
- struct not_equal_to : public binary_function<_Tp, _Tp, bool>
- {
- bool
- operator()(const _Tp& __x, const _Tp& __y) const
- { return __x != __y; }
- };
- template<typename _Tp>
- struct greater : public binary_function<_Tp, _Tp, bool>
- {
- bool
- operator()(const _Tp& __x, const _Tp& __y) const
- { return __x > __y; }
- };
- template<typename _Tp>
- struct less : public binary_function<_Tp, _Tp, bool>
- {
- bool
- operator()(const _Tp& __x, const _Tp& __y) const
- { return __x < __y; }
- };
- template<typename _Tp>
- struct greater_equal : public binary_function<_Tp, _Tp, bool>
- {
- bool
- operator()(const _Tp& __x, const _Tp& __y) const
- { return __x >= __y; }
- };
- template<typename _Tp>
- struct less_equal : public binary_function<_Tp, _Tp, bool>
- {
- bool
- operator()(const _Tp& __x, const _Tp& __y) const
- { return __x <= __y; }
- };
- template<typename _Tp>
- struct logical_and : public binary_function<_Tp, _Tp, bool>
- {
- bool
- operator()(const _Tp& __x, const _Tp& __y) const
- { return __x && __y; }
- };
- template<typename _Tp>
- struct logical_or : public binary_function<_Tp, _Tp, bool>
- {
- bool
- operator()(const _Tp& __x, const _Tp& __y) const
- { return __x || __y; }
- };
- template<typename _Tp>
- struct logical_not : public unary_function<_Tp, bool>
- {
- bool
- operator()(const _Tp& __x) const
- { return !__x; }
- };
- template<typename _Tp>
- struct bit_and : public binary_function<_Tp, _Tp, _Tp>
- {
- _Tp
- operator()(const _Tp& __x, const _Tp& __y) const
- { return __x & __y; }
- };
- template<typename _Tp>
- struct bit_or : public binary_function<_Tp, _Tp, _Tp>
- {
- _Tp
- operator()(const _Tp& __x, const _Tp& __y) const
- { return __x | __y; }
- };
- template<typename _Tp>
- struct bit_xor : public binary_function<_Tp, _Tp, _Tp>
- {
- _Tp
- operator()(const _Tp& __x, const _Tp& __y) const
- { return __x ^ __y; }
- };
- template<typename _Predicate>
- class unary_negate
- : public unary_function<typename _Predicate::argument_type, bool>
- {
- protected:
- _Predicate _M_pred;
- public:
- explicit
- unary_negate(const _Predicate& __x) : _M_pred(__x) { }
- bool
- operator()(const typename _Predicate::argument_type& __x) const
- { return !_M_pred(__x); }
- };
- template<typename _Predicate>
- inline unary_negate<_Predicate>
- not1(const _Predicate& __pred)
- { return unary_negate<_Predicate>(__pred); }
- template<typename _Predicate>
- class binary_negate
- : public binary_function<typename _Predicate::first_argument_type,
- typename _Predicate::second_argument_type, bool>
- {
- protected:
- _Predicate _M_pred;
- public:
- explicit
- binary_negate(const _Predicate& __x) : _M_pred(__x) { }
- bool
- operator()(const typename _Predicate::first_argument_type& __x,
- const typename _Predicate::second_argument_type& __y) const
- { return !_M_pred(__x, __y); }
- };
- template<typename _Predicate>
- inline binary_negate<_Predicate>
- not2(const _Predicate& __pred)
- { return binary_negate<_Predicate>(__pred); }
- template<typename _Arg, typename _Result>
- class pointer_to_unary_function : public unary_function<_Arg, _Result>
- {
- protected:
- _Result (*_M_ptr)(_Arg);
- public:
- pointer_to_unary_function() { }
- explicit
- pointer_to_unary_function(_Result (*__x)(_Arg))
- : _M_ptr(__x) { }
- _Result
- operator()(_Arg __x) const
- { return _M_ptr(__x); }
- };
- template<typename _Arg, typename _Result>
- inline pointer_to_unary_function<_Arg, _Result>
- ptr_fun(_Result (*__x)(_Arg))
- { return pointer_to_unary_function<_Arg, _Result>(__x); }
- template<typename _Arg1, typename _Arg2, typename _Result>
- class pointer_to_binary_function
- : public binary_function<_Arg1, _Arg2, _Result>
- {
- protected:
- _Result (*_M_ptr)(_Arg1, _Arg2);
- public:
- pointer_to_binary_function() { }
- explicit
- pointer_to_binary_function(_Result (*__x)(_Arg1, _Arg2))
- : _M_ptr(__x) { }
- _Result
- operator()(_Arg1 __x, _Arg2 __y) const
- { return _M_ptr(__x, __y); }
- };
- template<typename _Arg1, typename _Arg2, typename _Result>
- inline pointer_to_binary_function<_Arg1, _Arg2, _Result>
- ptr_fun(_Result (*__x)(_Arg1, _Arg2))
- { return pointer_to_binary_function<_Arg1, _Arg2, _Result>(__x); }
- template<typename _Tp>
- struct _Identity : public unary_function<_Tp,_Tp>
- {
- _Tp&
- operator()(_Tp& __x) const
- { return __x; }
- const _Tp&
- operator()(const _Tp& __x) const
- { return __x; }
- };
- template<typename _Pair>
- struct _Select1st : public unary_function<_Pair,
- typename _Pair::first_type>
- {
- typename _Pair::first_type&
- operator()(_Pair& __x) const
- { return __x.first; }
- const typename _Pair::first_type&
- operator()(const _Pair& __x) const
- { return __x.first; }
- };
- template<typename _Pair>
- struct _Select2nd : public unary_function<_Pair,
- typename _Pair::second_type>
- {
- typename _Pair::second_type&
- operator()(_Pair& __x) const
- { return __x.second; }
- const typename _Pair::second_type&
- operator()(const _Pair& __x) const
- { return __x.second; }
- };
- template<typename _Ret, typename _Tp>
- class mem_fun_t : public unary_function<_Tp*, _Ret>
- {
- public:
- explicit
- mem_fun_t(_Ret (_Tp::*__pf)())
- : _M_f(__pf) { }
- _Ret
- operator()(_Tp* __p) const
- { return (__p->*_M_f)(); }
- private:
- _Ret (_Tp::*_M_f)();
- };
- template<typename _Ret, typename _Tp>
- class const_mem_fun_t : public unary_function<const _Tp*, _Ret>
- {
- public:
- explicit
- const_mem_fun_t(_Ret (_Tp::*__pf)() const)
- : _M_f(__pf) { }
- _Ret
- operator()(const _Tp* __p) const
- { return (__p->*_M_f)(); }
- private:
- _Ret (_Tp::*_M_f)() const;
- };
- template<typename _Ret, typename _Tp>
- class mem_fun_ref_t : public unary_function<_Tp, _Ret>
- {
- public:
- explicit
- mem_fun_ref_t(_Ret (_Tp::*__pf)())
- : _M_f(__pf) { }
- _Ret
- operator()(_Tp& __r) const
- { return (__r.*_M_f)(); }
- private:
- _Ret (_Tp::*_M_f)();
- };
- template<typename _Ret, typename _Tp>
- class const_mem_fun_ref_t : public unary_function<_Tp, _Ret>
- {
- public:
- explicit
- const_mem_fun_ref_t(_Ret (_Tp::*__pf)() const)
- : _M_f(__pf) { }
- _Ret
- operator()(const _Tp& __r) const
- { return (__r.*_M_f)(); }
- private:
- _Ret (_Tp::*_M_f)() const;
- };
- template<typename _Ret, typename _Tp, typename _Arg>
- class mem_fun1_t : public binary_function<_Tp*, _Arg, _Ret>
- {
- public:
- explicit
- mem_fun1_t(_Ret (_Tp::*__pf)(_Arg))
- : _M_f(__pf) { }
- _Ret
- operator()(_Tp* __p, _Arg __x) const
- { return (__p->*_M_f)(__x); }
- private:
- _Ret (_Tp::*_M_f)(_Arg);
- };
- template<typename _Ret, typename _Tp, typename _Arg>
- class const_mem_fun1_t : public binary_function<const _Tp*, _Arg, _Ret>
- {
- public:
- explicit
- const_mem_fun1_t(_Ret (_Tp::*__pf)(_Arg) const)
- : _M_f(__pf) { }
- _Ret
- operator()(const _Tp* __p, _Arg __x) const
- { return (__p->*_M_f)(__x); }
- private:
- _Ret (_Tp::*_M_f)(_Arg) const;
- };
- template<typename _Ret, typename _Tp, typename _Arg>
- class mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret>
- {
- public:
- explicit
- mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg))
- : _M_f(__pf) { }
- _Ret
- operator()(_Tp& __r, _Arg __x) const
- { return (__r.*_M_f)(__x); }
- private:
- _Ret (_Tp::*_M_f)(_Arg);
- };
- template<typename _Ret, typename _Tp, typename _Arg>
- class const_mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret>
- {
- public:
- explicit
- const_mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg) const)
- : _M_f(__pf) { }
- _Ret
- operator()(const _Tp& __r, _Arg __x) const
- { return (__r.*_M_f)(__x); }
- private:
- _Ret (_Tp::*_M_f)(_Arg) const;
- };
- template<typename _Ret, typename _Tp>
- inline mem_fun_t<_Ret, _Tp>
- mem_fun(_Ret (_Tp::*__f)())
- { return mem_fun_t<_Ret, _Tp>(__f); }
- template<typename _Ret, typename _Tp>
- inline const_mem_fun_t<_Ret, _Tp>
- mem_fun(_Ret (_Tp::*__f)() const)
- { return const_mem_fun_t<_Ret, _Tp>(__f); }
- template<typename _Ret, typename _Tp>
- inline mem_fun_ref_t<_Ret, _Tp>
- mem_fun_ref(_Ret (_Tp::*__f)())
- { return mem_fun_ref_t<_Ret, _Tp>(__f); }
- template<typename _Ret, typename _Tp>
- inline const_mem_fun_ref_t<_Ret, _Tp>
- mem_fun_ref(_Ret (_Tp::*__f)() const)
- { return const_mem_fun_ref_t<_Ret, _Tp>(__f); }
- template<typename _Ret, typename _Tp, typename _Arg>
- inline mem_fun1_t<_Ret, _Tp, _Arg>
- mem_fun(_Ret (_Tp::*__f)(_Arg))
- { return mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
- template<typename _Ret, typename _Tp, typename _Arg>
- inline const_mem_fun1_t<_Ret, _Tp, _Arg>
- mem_fun(_Ret (_Tp::*__f)(_Arg) const)
- { return const_mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
- template<typename _Ret, typename _Tp, typename _Arg>
- inline mem_fun1_ref_t<_Ret, _Tp, _Arg>
- mem_fun_ref(_Ret (_Tp::*__f)(_Arg))
- { return mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
- template<typename _Ret, typename _Tp, typename _Arg>
- inline const_mem_fun1_ref_t<_Ret, _Tp, _Arg>
- mem_fun_ref(_Ret (_Tp::*__f)(_Arg) const)
- { return const_mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _Operation>
- class binder1st
- : public unary_function<typename _Operation::second_argument_type,
- typename _Operation::result_type>
- {
- protected:
- _Operation op;
- typename _Operation::first_argument_type value;
- public:
- binder1st(const _Operation& __x,
- const typename _Operation::first_argument_type& __y)
- : op(__x), value(__y) { }
- typename _Operation::result_type
- operator()(const typename _Operation::second_argument_type& __x) const
- { return op(value, __x); }
- typename _Operation::result_type
- operator()(typename _Operation::second_argument_type& __x) const
- { return op(value, __x); }
- } ;
- template<typename _Operation, typename _Tp>
- inline binder1st<_Operation>
- bind1st(const _Operation& __fn, const _Tp& __x)
- {
- typedef typename _Operation::first_argument_type _Arg1_type;
- return binder1st<_Operation>(__fn, _Arg1_type(__x));
- }
- template<typename _Operation>
- class binder2nd
- : public unary_function<typename _Operation::first_argument_type,
- typename _Operation::result_type>
- {
- protected:
- _Operation op;
- typename _Operation::second_argument_type value;
- public:
- binder2nd(const _Operation& __x,
- const typename _Operation::second_argument_type& __y)
- : op(__x), value(__y) { }
- typename _Operation::result_type
- operator()(const typename _Operation::first_argument_type& __x) const
- { return op(__x, value); }
- typename _Operation::result_type
- operator()(typename _Operation::first_argument_type& __x) const
- { return op(__x, value); }
- } ;
- template<typename _Operation, typename _Tp>
- inline binder2nd<_Operation>
- bind2nd(const _Operation& __fn, const _Tp& __x)
- {
- typedef typename _Operation::second_argument_type _Arg2_type;
- return binder2nd<_Operation>(__fn, _Arg2_type(__x));
- }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _CharT, typename _Traits, typename _Alloc>
- class basic_string
- {
- typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
- public:
- typedef _Traits traits_type;
- typedef typename _Traits::char_type value_type;
- typedef _Alloc allocator_type;
- typedef typename _CharT_alloc_type::size_type size_type;
- typedef typename _CharT_alloc_type::difference_type difference_type;
- typedef typename _CharT_alloc_type::reference reference;
- typedef typename _CharT_alloc_type::const_reference const_reference;
- typedef typename _CharT_alloc_type::pointer pointer;
- typedef typename _CharT_alloc_type::const_pointer const_pointer;
- typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
- typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
- const_iterator;
- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
- typedef std::reverse_iterator<iterator> reverse_iterator;
- private:
- struct _Rep_base
- {
- size_type _M_length;
- size_type _M_capacity;
- _Atomic_word _M_refcount;
- };
- struct _Rep : _Rep_base
- {
- typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
- static const size_type _S_max_size;
- static const _CharT _S_terminal;
- static size_type _S_empty_rep_storage[];
- static _Rep&
- _S_empty_rep()
- {
- void* __p = reinterpret_cast<void*>(&_S_empty_rep_storage);
- return *reinterpret_cast<_Rep*>(__p);
- }
- bool
- _M_is_leaked() const
- { return this->_M_refcount < 0; }
- bool
- _M_is_shared() const
- { return this->_M_refcount > 0; }
- void
- _M_set_leaked()
- { this->_M_refcount = -1; }
- void
- _M_set_sharable()
- { this->_M_refcount = 0; }
- void
- _M_set_length_and_sharable(size_type __n)
- {
- if (__builtin_expect(this != &_S_empty_rep(), false))
- {
- this->_M_set_sharable();
- this->_M_length = __n;
- traits_type::assign(this->_M_refdata()[__n], _S_terminal);
- }
- }
- _CharT*
- _M_refdata() throw()
- { return reinterpret_cast<_CharT*>(this + 1); }
- _CharT*
- _M_grab(const _Alloc& __alloc1, const _Alloc& __alloc2)
- {
- return (!_M_is_leaked() && __alloc1 == __alloc2)
- ? _M_refcopy() : _M_clone(__alloc1);
- }
- static _Rep*
- _S_create(size_type, size_type, const _Alloc&);
- void
- _M_dispose(const _Alloc& __a)
- {
- if (__builtin_expect(this != &_S_empty_rep(), false))
- {
- ;
- if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
- -1) <= 0)
- {
- ;
- _M_destroy(__a);
- }
- }
- }
- void
- _M_destroy(const _Alloc&) throw();
- _CharT*
- _M_refcopy() throw()
- {
- if (__builtin_expect(this != &_S_empty_rep(), false))
- __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
- return _M_refdata();
- }
- _CharT*
- _M_clone(const _Alloc&, size_type __res = 0);
- };
- struct _Alloc_hider : _Alloc
- {
- _Alloc_hider(_CharT* __dat, const _Alloc& __a)
- : _Alloc(__a), _M_p(__dat) { }
- _CharT* _M_p;
- };
- public:
- static const size_type npos = static_cast<size_type>(-1);
- private:
- mutable _Alloc_hider _M_dataplus;
- _CharT*
- _M_data() const
- { return _M_dataplus._M_p; }
- _CharT*
- _M_data(_CharT* __p)
- { return (_M_dataplus._M_p = __p); }
- _Rep*
- _M_rep() const
- { return &((reinterpret_cast<_Rep*> (_M_data()))[-1]); }
- iterator
- _M_ibegin() const
- { return iterator(_M_data()); }
- iterator
- _M_iend() const
- { return iterator(_M_data() + this->size()); }
- void
- _M_leak()
- {
- if (!_M_rep()->_M_is_leaked())
- _M_leak_hard();
- }
- size_type
- _M_check(size_type __pos, const char* __s) const
- {
- if (__pos > this->size())
- __throw_out_of_range((__s));
- return __pos;
- }
- void
- _M_check_length(size_type __n1, size_type __n2, const char* __s) const
- {
- if (this->max_size() - (this->size() - __n1) < __n2)
- __throw_length_error((__s));
- }
- size_type
- _M_limit(size_type __pos, size_type __off) const
- {
- const bool __testoff = __off < this->size() - __pos;
- return __testoff ? __off : this->size() - __pos;
- }
- bool
- _M_disjunct(const _CharT* __s) const
- {
- return (less<const _CharT*>()(__s, _M_data())
- || less<const _CharT*>()(_M_data() + this->size(), __s));
- }
- static void
- _M_copy(_CharT* __d, const _CharT* __s, size_type __n)
- {
- if (__n == 1)
- traits_type::assign(*__d, *__s);
- else
- traits_type::copy(__d, __s, __n);
- }
- static void
- _M_move(_CharT* __d, const _CharT* __s, size_type __n)
- {
- if (__n == 1)
- traits_type::assign(*__d, *__s);
- else
- traits_type::move(__d, __s, __n);
- }
- static void
- _M_assign(_CharT* __d, size_type __n, _CharT __c)
- {
- if (__n == 1)
- traits_type::assign(*__d, __c);
- else
- traits_type::assign(__d, __n, __c);
- }
- template<class _Iterator>
- static void
- _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
- {
- for (; __k1 != __k2; ++__k1, ++__p)
- traits_type::assign(*__p, *__k1);
- }
- static void
- _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2)
- { _S_copy_chars(__p, __k1.base(), __k2.base()); }
- static void
- _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
- { _S_copy_chars(__p, __k1.base(), __k2.base()); }
- static void
- _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2)
- { _M_copy(__p, __k1, __k2 - __k1); }
- static void
- _S_copy_chars(_CharT* __p, const _CharT* __k1, const _CharT* __k2)
- { _M_copy(__p, __k1, __k2 - __k1); }
- static int
- _S_compare(size_type __n1, size_type __n2)
- {
- const difference_type __d = difference_type(__n1 - __n2);
- if (__d > __gnu_cxx::__numeric_traits<int>::__max)
- return __gnu_cxx::__numeric_traits<int>::__max;
- else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
- return __gnu_cxx::__numeric_traits<int>::__min;
- else
- return int(__d);
- }
- void
- _M_mutate(size_type __pos, size_type __len1, size_type __len2);
- void
- _M_leak_hard();
- static _Rep&
- _S_empty_rep()
- { return _Rep::_S_empty_rep(); }
- public:
- basic_string()
- : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
- explicit
- basic_string(const _Alloc& __a);
- basic_string(const basic_string& __str);
- basic_string(const basic_string& __str, size_type __pos,
- size_type __n = npos);
- basic_string(const basic_string& __str, size_type __pos,
- size_type __n, const _Alloc& __a);
- basic_string(const _CharT* __s, size_type __n,
- const _Alloc& __a = _Alloc());
- basic_string(const _CharT* __s, const _Alloc& __a = _Alloc());
- basic_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc());
- template<class _InputIterator>
- basic_string(_InputIterator __beg, _InputIterator __end,
- const _Alloc& __a = _Alloc());
- ~basic_string()
- { _M_rep()->_M_dispose(this->get_allocator()); }
- basic_string&
- operator=(const basic_string& __str)
- { return this->assign(__str); }
- basic_string&
- operator=(const _CharT* __s)
- { return this->assign(__s); }
- basic_string&
- operator=(_CharT __c)
- {
- this->assign(1, __c);
- return *this;
- }
- iterator
- begin()
- {
- _M_leak();
- return iterator(_M_data());
- }
- const_iterator
- begin() const
- { return const_iterator(_M_data()); }
- iterator
- end()
- {
- _M_leak();
- return iterator(_M_data() + this->size());
- }
- const_iterator
- end() const
- { return const_iterator(_M_data() + this->size()); }
- reverse_iterator
- rbegin()
- { return reverse_iterator(this->end()); }
- const_reverse_iterator
- rbegin() const
- { return const_reverse_iterator(this->end()); }
- reverse_iterator
- rend()
- { return reverse_iterator(this->begin()); }
- const_reverse_iterator
- rend() const
- { return const_reverse_iterator(this->begin()); }
- public:
- size_type
- size() const
- { return _M_rep()->_M_length; }
- size_type
- length() const
- { return _M_rep()->_M_length; }
- size_type
- max_size() const
- { return _Rep::_S_max_size; }
- void
- resize(size_type __n, _CharT __c);
- void
- resize(size_type __n)
- { this->resize(__n, _CharT()); }
- size_type
- capacity() const
- { return _M_rep()->_M_capacity; }
- void
- reserve(size_type __res_arg = 0);
- void
- clear()
- { _M_mutate(0, this->size(), 0); }
- bool
- empty() const
- { return this->size() == 0; }
- const_reference
- operator[] (size_type __pos) const
- {
- ;
- return _M_data()[__pos];
- }
- reference
- operator[](size_type __pos)
- {
- ;
- ;
- _M_leak();
- return _M_data()[__pos];
- }
- const_reference
- at(size_type __n) const
- {
- if (__n >= this->size())
- __throw_out_of_range(("basic_string::at"));
- return _M_data()[__n];
- }
- reference
- at(size_type __n)
- {
- if (__n >= size())
- __throw_out_of_range(("basic_string::at"));
- _M_leak();
- return _M_data()[__n];
- }
- basic_string&
- operator+=(const basic_string& __str)
- { return this->append(__str); }
- basic_string&
- operator+=(const _CharT* __s)
- { return this->append(__s); }
- basic_string&
- operator+=(_CharT __c)
- {
- this->push_back(__c);
- return *this;
- }
- basic_string&
- append(const basic_string& __str);
- basic_string&
- append(const basic_string& __str, size_type __pos, size_type __n);
- basic_string&
- append(const _CharT* __s, size_type __n);
- basic_string&
- append(const _CharT* __s)
- {
- ;
- return this->append(__s, traits_type::length(__s));
- }
- basic_string&
- append(size_type __n, _CharT __c);
- template<class _InputIterator>
- basic_string&
- append(_InputIterator __first, _InputIterator __last)
- { return this->replace(_M_iend(), _M_iend(), __first, __last); }
- void
- push_back(_CharT __c)
- {
- const size_type __len = 1 + this->size();
- if (__len > this->capacity() || _M_rep()->_M_is_shared())
- this->reserve(__len);
- traits_type::assign(_M_data()[this->size()], __c);
- _M_rep()->_M_set_length_and_sharable(__len);
- }
- basic_string&
- assign(const basic_string& __str);
- basic_string&
- assign(const basic_string& __str, size_type __pos, size_type __n)
- { return this->assign(__str._M_data()
- + __str._M_check(__pos, "basic_string::assign"),
- __str._M_limit(__pos, __n)); }
- basic_string&
- assign(const _CharT* __s, size_type __n);
- basic_string&
- assign(const _CharT* __s)
- {
- ;
- return this->assign(__s, traits_type::length(__s));
- }
- basic_string&
- assign(size_type __n, _CharT __c)
- { return _M_replace_aux(size_type(0), this->size(), __n, __c); }
- template<class _InputIterator>
- basic_string&
- assign(_InputIterator __first, _InputIterator __last)
- { return this->replace(_M_ibegin(), _M_iend(), __first, __last); }
- void
- insert(iterator __p, size_type __n, _CharT __c)
- { this->replace(__p, __p, __n, __c); }
- template<class _InputIterator>
- void
- insert(iterator __p, _InputIterator __beg, _InputIterator __end)
- { this->replace(__p, __p, __beg, __end); }
- basic_string&
- insert(size_type __pos1, const basic_string& __str)
- { return this->insert(__pos1, __str, size_type(0), __str.size()); }
- basic_string&
- insert(size_type __pos1, const basic_string& __str,
- size_type __pos2, size_type __n)
- { return this->insert(__pos1, __str._M_data()
- + __str._M_check(__pos2, "basic_string::insert"),
- __str._M_limit(__pos2, __n)); }
- basic_string&
- insert(size_type __pos, const _CharT* __s, size_type __n);
- basic_string&
- insert(size_type __pos, const _CharT* __s)
- {
- ;
- return this->insert(__pos, __s, traits_type::length(__s));
- }
- basic_string&
- insert(size_type __pos, size_type __n, _CharT __c)
- { return _M_replace_aux(_M_check(__pos, "basic_string::insert"),
- size_type(0), __n, __c); }
- iterator
- insert(iterator __p, _CharT __c)
- {
- ;
- const size_type __pos = __p - _M_ibegin();
- _M_replace_aux(__pos, size_type(0), size_type(1), __c);
- _M_rep()->_M_set_leaked();
- return iterator(_M_data() + __pos);
- }
- basic_string&
- erase(size_type __pos = 0, size_type __n = npos)
- {
- _M_mutate(_M_check(__pos, "basic_string::erase"),
- _M_limit(__pos, __n), size_type(0));
- return *this;
- }
- iterator
- erase(iterator __position)
- {
- ;
- const size_type __pos = __position - _M_ibegin();
- _M_mutate(__pos, size_type(1), size_type(0));
- _M_rep()->_M_set_leaked();
- return iterator(_M_data() + __pos);
- }
- iterator
- erase(iterator __first, iterator __last);
- basic_string&
- replace(size_type __pos, size_type __n, const basic_string& __str)
- { return this->replace(__pos, __n, __str._M_data(), __str.size()); }
- basic_string&
- replace(size_type __pos1, size_type __n1, const basic_string& __str,
- size_type __pos2, size_type __n2)
- { return this->replace(__pos1, __n1, __str._M_data()
- + __str._M_check(__pos2, "basic_string::replace"),
- __str._M_limit(__pos2, __n2)); }
- basic_string&
- replace(size_type __pos, size_type __n1, const _CharT* __s,
- size_type __n2);
- basic_string&
- replace(size_type __pos, size_type __n1, const _CharT* __s)
- {
- ;
- return this->replace(__pos, __n1, __s, traits_type::length(__s));
- }
- basic_string&
- replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
- { return _M_replace_aux(_M_check(__pos, "basic_string::replace"),
- _M_limit(__pos, __n1), __n2, __c); }
- basic_string&
- replace(iterator __i1, iterator __i2, const basic_string& __str)
- { return this->replace(__i1, __i2, __str._M_data(), __str.size()); }
- basic_string&
- replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n)
- {
- ;
- return this->replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
- }
- basic_string&
- replace(iterator __i1, iterator __i2, const _CharT* __s)
- {
- ;
- return this->replace(__i1, __i2, __s, traits_type::length(__s));
- }
- basic_string&
- replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
- {
- ;
- return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
- }
- template<class _InputIterator>
- basic_string&
- replace(iterator __i1, iterator __i2,
- _InputIterator __k1, _InputIterator __k2)
- {
- ;
- ;
- typedef typename std::__is_integer<_InputIterator>::__type _Integral;
- return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
- }
- basic_string&
- replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
- {
- ;
- ;
- return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
- __k1, __k2 - __k1);
- }
- basic_string&
- replace(iterator __i1, iterator __i2,
- const _CharT* __k1, const _CharT* __k2)
- {
- ;
- ;
- return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
- __k1, __k2 - __k1);
- }
- basic_string&
- replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
- {
- ;
- ;
- return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
- __k1.base(), __k2 - __k1);
- }
- basic_string&
- replace(iterator __i1, iterator __i2,
- const_iterator __k1, const_iterator __k2)
- {
- ;
- ;
- return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
- __k1.base(), __k2 - __k1);
- }
- private:
- template<class _Integer>
- basic_string&
- _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
- _Integer __val, __true_type)
- { return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
- template<class _InputIterator>
- basic_string&
- _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
- _InputIterator __k2, __false_type);
- basic_string&
- _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
- _CharT __c);
- basic_string&
- _M_replace_safe(size_type __pos1, size_type __n1, const _CharT* __s,
- size_type __n2);
- template<class _InIterator>
- static _CharT*
- _S_construct_aux(_InIterator __beg, _InIterator __end,
- const _Alloc& __a, __false_type)
- {
- typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
- return _S_construct(__beg, __end, __a, _Tag());
- }
- template<class _Integer>
- static _CharT*
- _S_construct_aux(_Integer __beg, _Integer __end,
- const _Alloc& __a, __true_type)
- { return _S_construct_aux_2(static_cast<size_type>(__beg),
- __end, __a); }
- static _CharT*
- _S_construct_aux_2(size_type __req, _CharT __c, const _Alloc& __a)
- { return _S_construct(__req, __c, __a); }
- template<class _InIterator>
- static _CharT*
- _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a)
- {
- typedef typename std::__is_integer<_InIterator>::__type _Integral;
- return _S_construct_aux(__beg, __end, __a, _Integral());
- }
- template<class _InIterator>
- static _CharT*
- _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
- input_iterator_tag);
- template<class _FwdIterator>
- static _CharT*
- _S_construct(_FwdIterator __beg, _FwdIterator __end, const _Alloc& __a,
- forward_iterator_tag);
- static _CharT*
- _S_construct(size_type __req, _CharT __c, const _Alloc& __a);
- public:
- size_type
- copy(_CharT* __s, size_type __n, size_type __pos = 0) const;
- void
- swap(basic_string& __s);
- const _CharT*
- c_str() const
- { return _M_data(); }
- const _CharT*
- data() const
- { return _M_data(); }
- allocator_type
- get_allocator() const
- { return _M_dataplus; }
- size_type
- find(const _CharT* __s, size_type __pos, size_type __n) const;
- size_type
- find(const basic_string& __str, size_type __pos = 0) const
- { return this->find(__str.data(), __pos, __str.size()); }
- size_type
- find(const _CharT* __s, size_type __pos = 0) const
- {
- ;
- return this->find(__s, __pos, traits_type::length(__s));
- }
- size_type
- find(_CharT __c, size_type __pos = 0) const;
- size_type
- rfind(const basic_string& __str, size_type __pos = npos) const
- { return this->rfind(__str.data(), __pos, __str.size()); }
- size_type
- rfind(const _CharT* __s, size_type __pos, size_type __n) const;
- size_type
- rfind(const _CharT* __s, size_type __pos = npos) const
- {
- ;
- return this->rfind(__s, __pos, traits_type::length(__s));
- }
- size_type
- rfind(_CharT __c, size_type __pos = npos) const;
- size_type
- find_first_of(const basic_string& __str, size_type __pos = 0) const
- { return this->find_first_of(__str.data(), __pos, __str.size()); }
- size_type
- find_first_of(const _CharT* __s, size_type __pos, size_type __n) const;
- size_type
- find_first_of(const _CharT* __s, size_type __pos = 0) const
- {
- ;
- return this->find_first_of(__s, __pos, traits_type::length(__s));
- }
- size_type
- find_first_of(_CharT __c, size_type __pos = 0) const
- { return this->find(__c, __pos); }
- size_type
- find_last_of(const basic_string& __str, size_type __pos = npos) const
- { return this->find_last_of(__str.data(), __pos, __str.size()); }
- size_type
- find_last_of(const _CharT* __s, size_type __pos, size_type __n) const;
- size_type
- find_last_of(const _CharT* __s, size_type __pos = npos) const
- {
- ;
- return this->find_last_of(__s, __pos, traits_type::length(__s));
- }
- size_type
- find_last_of(_CharT __c, size_type __pos = npos) const
- { return this->rfind(__c, __pos); }
- size_type
- find_first_not_of(const basic_string& __str, size_type __pos = 0) const
- { return this->find_first_not_of(__str.data(), __pos, __str.size()); }
- size_type
- find_first_not_of(const _CharT* __s, size_type __pos,
- size_type __n) const;
- size_type
- find_first_not_of(const _CharT* __s, size_type __pos = 0) const
- {
- ;
- return this->find_first_not_of(__s, __pos, traits_type::length(__s));
- }
- size_type
- find_first_not_of(_CharT __c, size_type __pos = 0) const;
- size_type
- find_last_not_of(const basic_string& __str, size_type __pos = npos) const
- { return this->find_last_not_of(__str.data(), __pos, __str.size()); }
- size_type
- find_last_not_of(const _CharT* __s, size_type __pos,
- size_type __n) const;
- size_type
- find_last_not_of(const _CharT* __s, size_type __pos = npos) const
- {
- ;
- return this->find_last_not_of(__s, __pos, traits_type::length(__s));
- }
- size_type
- find_last_not_of(_CharT __c, size_type __pos = npos) const;
- basic_string
- substr(size_type __pos = 0, size_type __n = npos) const
- { return basic_string(*this,
- _M_check(__pos, "basic_string::substr"), __n); }
- int
- compare(const basic_string& __str) const
- {
- const size_type __size = this->size();
- const size_type __osize = __str.size();
- const size_type __len = std::min(__size, __osize);
- int __r = traits_type::compare(_M_data(), __str.data(), __len);
- if (!__r)
- __r = _S_compare(__size, __osize);
- return __r;
- }
- int
- compare(size_type __pos, size_type __n, const basic_string& __str) const;
- int
- compare(size_type __pos1, size_type __n1, const basic_string& __str,
- size_type __pos2, size_type __n2) const;
- int
- compare(const _CharT* __s) const;
- int
- compare(size_type __pos, size_type __n1, const _CharT* __s) const;
- int
- compare(size_type __pos, size_type __n1, const _CharT* __s,
- size_type __n2) const;
- };
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT, _Traits, _Alloc>
- operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
- const basic_string<_CharT, _Traits, _Alloc>& __rhs)
- {
- basic_string<_CharT, _Traits, _Alloc> __str(__lhs);
- __str.append(__rhs);
- return __str;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT,_Traits,_Alloc>
- operator+(const _CharT* __lhs,
- const basic_string<_CharT,_Traits,_Alloc>& __rhs);
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT,_Traits,_Alloc>
- operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs);
- template<typename _CharT, typename _Traits, typename _Alloc>
- inline basic_string<_CharT, _Traits, _Alloc>
- operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
- const _CharT* __rhs)
- {
- basic_string<_CharT, _Traits, _Alloc> __str(__lhs);
- __str.append(__rhs);
- return __str;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- inline basic_string<_CharT, _Traits, _Alloc>
- operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs)
- {
- typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
- typedef typename __string_type::size_type __size_type;
- __string_type __str(__lhs);
- __str.append(__size_type(1), __rhs);
- return __str;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- inline bool
- operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
- const basic_string<_CharT, _Traits, _Alloc>& __rhs)
- { return __lhs.compare(__rhs) == 0; }
- template<typename _CharT>
- inline
- typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, bool>::__type
- operator==(const basic_string<_CharT>& __lhs,
- const basic_string<_CharT>& __rhs)
- { return (__lhs.size() == __rhs.size()
- && !std::char_traits<_CharT>::compare(__lhs.data(), __rhs.data(),
- __lhs.size())); }
- template<typename _CharT, typename _Traits, typename _Alloc>
- inline bool
- operator==(const _CharT* __lhs,
- const basic_string<_CharT, _Traits, _Alloc>& __rhs)
- { return __rhs.compare(__lhs) == 0; }
- template<typename _CharT, typename _Traits, typename _Alloc>
- inline bool
- operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
- const _CharT* __rhs)
- { return __lhs.compare(__rhs) == 0; }
- template<typename _CharT, typename _Traits, typename _Alloc>
- inline bool
- operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
- const basic_string<_CharT, _Traits, _Alloc>& __rhs)
- { return !(__lhs == __rhs); }
- template<typename _CharT, typename _Traits, typename _Alloc>
- inline bool
- operator!=(const _CharT* __lhs,
- const basic_string<_CharT, _Traits, _Alloc>& __rhs)
- { return !(__lhs == __rhs); }
- template<typename _CharT, typename _Traits, typename _Alloc>
- inline bool
- operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
- const _CharT* __rhs)
- { return !(__lhs == __rhs); }
- template<typename _CharT, typename _Traits, typename _Alloc>
- inline bool
- operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
- const basic_string<_CharT, _Traits, _Alloc>& __rhs)
- { return __lhs.compare(__rhs) < 0; }
- template<typename _CharT, typename _Traits, typename _Alloc>
- inline bool
- operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
- const _CharT* __rhs)
- { return __lhs.compare(__rhs) < 0; }
- template<typename _CharT, typename _Traits, typename _Alloc>
- inline bool
- operator<(const _CharT* __lhs,
- const basic_string<_CharT, _Traits, _Alloc>& __rhs)
- { return __rhs.compare(__lhs) > 0; }
- template<typename _CharT, typename _Traits, typename _Alloc>
- inline bool
- operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
- const basic_string<_CharT, _Traits, _Alloc>& __rhs)
- { return __lhs.compare(__rhs) > 0; }
- template<typename _CharT, typename _Traits, typename _Alloc>
- inline bool
- operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
- const _CharT* __rhs)
- { return __lhs.compare(__rhs) > 0; }
- template<typename _CharT, typename _Traits, typename _Alloc>
- inline bool
- operator>(const _CharT* __lhs,
- const basic_string<_CharT, _Traits, _Alloc>& __rhs)
- { return __rhs.compare(__lhs) < 0; }
- template<typename _CharT, typename _Traits, typename _Alloc>
- inline bool
- operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
- const basic_string<_CharT, _Traits, _Alloc>& __rhs)
- { return __lhs.compare(__rhs) <= 0; }
- template<typename _CharT, typename _Traits, typename _Alloc>
- inline bool
- operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
- const _CharT* __rhs)
- { return __lhs.compare(__rhs) <= 0; }
- template<typename _CharT, typename _Traits, typename _Alloc>
- inline bool
- operator<=(const _CharT* __lhs,
- const basic_string<_CharT, _Traits, _Alloc>& __rhs)
- { return __rhs.compare(__lhs) >= 0; }
- template<typename _CharT, typename _Traits, typename _Alloc>
- inline bool
- operator>=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
- const basic_string<_CharT, _Traits, _Alloc>& __rhs)
- { return __lhs.compare(__rhs) >= 0; }
- template<typename _CharT, typename _Traits, typename _Alloc>
- inline bool
- operator>=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
- const _CharT* __rhs)
- { return __lhs.compare(__rhs) >= 0; }
- template<typename _CharT, typename _Traits, typename _Alloc>
- inline bool
- operator>=(const _CharT* __lhs,
- const basic_string<_CharT, _Traits, _Alloc>& __rhs)
- { return __rhs.compare(__lhs) <= 0; }
- template<typename _CharT, typename _Traits, typename _Alloc>
- inline void
- swap(basic_string<_CharT, _Traits, _Alloc>& __lhs,
- basic_string<_CharT, _Traits, _Alloc>& __rhs)
- { __lhs.swap(__rhs); }
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_istream<_CharT, _Traits>&
- operator>>(basic_istream<_CharT, _Traits>& __is,
- basic_string<_CharT, _Traits, _Alloc>& __str);
- template<>
- basic_istream<char>&
- operator>>(basic_istream<char>& __is, basic_string<char>& __str);
- template<typename _CharT, typename _Traits, typename _Alloc>
- inline basic_ostream<_CharT, _Traits>&
- operator<<(basic_ostream<_CharT, _Traits>& __os,
- const basic_string<_CharT, _Traits, _Alloc>& __str)
- {
- return __ostream_insert(__os, __str.data(), __str.size());
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_istream<_CharT, _Traits>&
- getline(basic_istream<_CharT, _Traits>& __is,
- basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
- template<typename _CharT, typename _Traits, typename _Alloc>
- inline basic_istream<_CharT, _Traits>&
- getline(basic_istream<_CharT, _Traits>& __is,
- basic_string<_CharT, _Traits, _Alloc>& __str)
- { return getline(__is, __str, __is.widen('\n')); }
- template<>
- basic_istream<char>&
- getline(basic_istream<char>& __in, basic_string<char>& __str,
- char __delim);
- template<>
- basic_istream<wchar_t>&
- getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
- wchar_t __delim);
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _CharT, typename _Traits, typename _Alloc>
- const typename basic_string<_CharT, _Traits, _Alloc>::size_type
- basic_string<_CharT, _Traits, _Alloc>::
- _Rep::_S_max_size = (((npos - sizeof(_Rep_base))/sizeof(_CharT)) - 1) / 4;
- template<typename _CharT, typename _Traits, typename _Alloc>
- const _CharT
- basic_string<_CharT, _Traits, _Alloc>::
- _Rep::_S_terminal = _CharT();
- template<typename _CharT, typename _Traits, typename _Alloc>
- const typename basic_string<_CharT, _Traits, _Alloc>::size_type
- basic_string<_CharT, _Traits, _Alloc>::npos;
- template<typename _CharT, typename _Traits, typename _Alloc>
- typename basic_string<_CharT, _Traits, _Alloc>::size_type
- basic_string<_CharT, _Traits, _Alloc>::_Rep::_S_empty_rep_storage[
- (sizeof(_Rep_base) + sizeof(_CharT) + sizeof(size_type) - 1) /
- sizeof(size_type)];
- template<typename _CharT, typename _Traits, typename _Alloc>
- template<typename _InIterator>
- _CharT*
- basic_string<_CharT, _Traits, _Alloc>::
- _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
- input_iterator_tag)
- {
- if (__beg == __end && __a == _Alloc())
- return _S_empty_rep()._M_refdata();
- _CharT __buf[128];
- size_type __len = 0;
- while (__beg != __end && __len < sizeof(__buf) / sizeof(_CharT))
- {
- __buf[__len++] = *__beg;
- ++__beg;
- }
- _Rep* __r = _Rep::_S_create(__len, size_type(0), __a);
- _M_copy(__r->_M_refdata(), __buf, __len);
- try
- {
- while (__beg != __end)
- {
- if (__len == __r->_M_capacity)
- {
- _Rep* __another = _Rep::_S_create(__len + 1, __len, __a);
- _M_copy(__another->_M_refdata(), __r->_M_refdata(), __len);
- __r->_M_destroy(__a);
- __r = __another;
- }
- __r->_M_refdata()[__len++] = *__beg;
- ++__beg;
- }
- }
- catch(...)
- {
- __r->_M_destroy(__a);
- throw;
- }
- __r->_M_set_length_and_sharable(__len);
- return __r->_M_refdata();
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- template <typename _InIterator>
- _CharT*
- basic_string<_CharT, _Traits, _Alloc>::
- _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
- forward_iterator_tag)
- {
- if (__beg == __end && __a == _Alloc())
- return _S_empty_rep()._M_refdata();
- if (__gnu_cxx::__is_null_pointer(__beg) && __beg != __end)
- __throw_logic_error(("basic_string::_S_construct null not valid"));
- const size_type __dnew = static_cast<size_type>(std::distance(__beg,
- __end));
- _Rep* __r = _Rep::_S_create(__dnew, size_type(0), __a);
- try
- { _S_copy_chars(__r->_M_refdata(), __beg, __end); }
- catch(...)
- {
- __r->_M_destroy(__a);
- throw;
- }
- __r->_M_set_length_and_sharable(__dnew);
- return __r->_M_refdata();
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- _CharT*
- basic_string<_CharT, _Traits, _Alloc>::
- _S_construct(size_type __n, _CharT __c, const _Alloc& __a)
- {
- if (__n == 0 && __a == _Alloc())
- return _S_empty_rep()._M_refdata();
- _Rep* __r = _Rep::_S_create(__n, size_type(0), __a);
- if (__n)
- _M_assign(__r->_M_refdata(), __n, __c);
- __r->_M_set_length_and_sharable(__n);
- return __r->_M_refdata();
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT, _Traits, _Alloc>::
- basic_string(const basic_string& __str)
- : _M_dataplus(__str._M_rep()->_M_grab(_Alloc(__str.get_allocator()),
- __str.get_allocator()),
- __str.get_allocator())
- { }
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT, _Traits, _Alloc>::
- basic_string(const _Alloc& __a)
- : _M_dataplus(_S_construct(size_type(), _CharT(), __a), __a)
- { }
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT, _Traits, _Alloc>::
- basic_string(const basic_string& __str, size_type __pos, size_type __n)
- : _M_dataplus(_S_construct(__str._M_data()
- + __str._M_check(__pos,
- "basic_string::basic_string"),
- __str._M_data() + __str._M_limit(__pos, __n)
- + __pos, _Alloc()), _Alloc())
- { }
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT, _Traits, _Alloc>::
- basic_string(const basic_string& __str, size_type __pos,
- size_type __n, const _Alloc& __a)
- : _M_dataplus(_S_construct(__str._M_data()
- + __str._M_check(__pos,
- "basic_string::basic_string"),
- __str._M_data() + __str._M_limit(__pos, __n)
- + __pos, __a), __a)
- { }
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT, _Traits, _Alloc>::
- basic_string(const _CharT* __s, size_type __n, const _Alloc& __a)
- : _M_dataplus(_S_construct(__s, __s + __n, __a), __a)
- { }
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT, _Traits, _Alloc>::
- basic_string(const _CharT* __s, const _Alloc& __a)
- : _M_dataplus(_S_construct(__s, __s ? __s + traits_type::length(__s) :
- __s + npos, __a), __a)
- { }
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT, _Traits, _Alloc>::
- basic_string(size_type __n, _CharT __c, const _Alloc& __a)
- : _M_dataplus(_S_construct(__n, __c, __a), __a)
- { }
- template<typename _CharT, typename _Traits, typename _Alloc>
- template<typename _InputIterator>
- basic_string<_CharT, _Traits, _Alloc>::
- basic_string(_InputIterator __beg, _InputIterator __end, const _Alloc& __a)
- : _M_dataplus(_S_construct(__beg, __end, __a), __a)
- { }
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT, _Traits, _Alloc>&
- basic_string<_CharT, _Traits, _Alloc>::
- assign(const basic_string& __str)
- {
- if (_M_rep() != __str._M_rep())
- {
- const allocator_type __a = this->get_allocator();
- _CharT* __tmp = __str._M_rep()->_M_grab(__a, __str.get_allocator());
- _M_rep()->_M_dispose(__a);
- _M_data(__tmp);
- }
- return *this;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT, _Traits, _Alloc>&
- basic_string<_CharT, _Traits, _Alloc>::
- assign(const _CharT* __s, size_type __n)
- {
- ;
- _M_check_length(this->size(), __n, "basic_string::assign");
- if (_M_disjunct(__s) || _M_rep()->_M_is_shared())
- return _M_replace_safe(size_type(0), this->size(), __s, __n);
- else
- {
- const size_type __pos = __s - _M_data();
- if (__pos >= __n)
- _M_copy(_M_data(), __s, __n);
- else if (__pos)
- _M_move(_M_data(), __s, __n);
- _M_rep()->_M_set_length_and_sharable(__n);
- return *this;
- }
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT, _Traits, _Alloc>&
- basic_string<_CharT, _Traits, _Alloc>::
- append(size_type __n, _CharT __c)
- {
- if (__n)
- {
- _M_check_length(size_type(0), __n, "basic_string::append");
- const size_type __len = __n + this->size();
- if (__len > this->capacity() || _M_rep()->_M_is_shared())
- this->reserve(__len);
- _M_assign(_M_data() + this->size(), __n, __c);
- _M_rep()->_M_set_length_and_sharable(__len);
- }
- return *this;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT, _Traits, _Alloc>&
- basic_string<_CharT, _Traits, _Alloc>::
- append(const _CharT* __s, size_type __n)
- {
- ;
- if (__n)
- {
- _M_check_length(size_type(0), __n, "basic_string::append");
- const size_type __len = __n + this->size();
- if (__len > this->capacity() || _M_rep()->_M_is_shared())
- {
- if (_M_disjunct(__s))
- this->reserve(__len);
- else
- {
- const size_type __off = __s - _M_data();
- this->reserve(__len);
- __s = _M_data() + __off;
- }
- }
- _M_copy(_M_data() + this->size(), __s, __n);
- _M_rep()->_M_set_length_and_sharable(__len);
- }
- return *this;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT, _Traits, _Alloc>&
- basic_string<_CharT, _Traits, _Alloc>::
- append(const basic_string& __str)
- {
- const size_type __size = __str.size();
- if (__size)
- {
- const size_type __len = __size + this->size();
- if (__len > this->capacity() || _M_rep()->_M_is_shared())
- this->reserve(__len);
- _M_copy(_M_data() + this->size(), __str._M_data(), __size);
- _M_rep()->_M_set_length_and_sharable(__len);
- }
- return *this;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT, _Traits, _Alloc>&
- basic_string<_CharT, _Traits, _Alloc>::
- append(const basic_string& __str, size_type __pos, size_type __n)
- {
- __str._M_check(__pos, "basic_string::append");
- __n = __str._M_limit(__pos, __n);
- if (__n)
- {
- const size_type __len = __n + this->size();
- if (__len > this->capacity() || _M_rep()->_M_is_shared())
- this->reserve(__len);
- _M_copy(_M_data() + this->size(), __str._M_data() + __pos, __n);
- _M_rep()->_M_set_length_and_sharable(__len);
- }
- return *this;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT, _Traits, _Alloc>&
- basic_string<_CharT, _Traits, _Alloc>::
- insert(size_type __pos, const _CharT* __s, size_type __n)
- {
- ;
- _M_check(__pos, "basic_string::insert");
- _M_check_length(size_type(0), __n, "basic_string::insert");
- if (_M_disjunct(__s) || _M_rep()->_M_is_shared())
- return _M_replace_safe(__pos, size_type(0), __s, __n);
- else
- {
- const size_type __off = __s - _M_data();
- _M_mutate(__pos, 0, __n);
- __s = _M_data() + __off;
- _CharT* __p = _M_data() + __pos;
- if (__s + __n <= __p)
- _M_copy(__p, __s, __n);
- else if (__s >= __p)
- _M_copy(__p, __s + __n, __n);
- else
- {
- const size_type __nleft = __p - __s;
- _M_copy(__p, __s, __nleft);
- _M_copy(__p + __nleft, __p + __n, __n - __nleft);
- }
- return *this;
- }
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- typename basic_string<_CharT, _Traits, _Alloc>::iterator
- basic_string<_CharT, _Traits, _Alloc>::
- erase(iterator __first, iterator __last)
- {
- ;
- const size_type __size = __last - __first;
- if (__size)
- {
- const size_type __pos = __first - _M_ibegin();
- _M_mutate(__pos, __size, size_type(0));
- _M_rep()->_M_set_leaked();
- return iterator(_M_data() + __pos);
- }
- else
- return __first;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT, _Traits, _Alloc>&
- basic_string<_CharT, _Traits, _Alloc>::
- replace(size_type __pos, size_type __n1, const _CharT* __s,
- size_type __n2)
- {
- ;
- _M_check(__pos, "basic_string::replace");
- __n1 = _M_limit(__pos, __n1);
- _M_check_length(__n1, __n2, "basic_string::replace");
- bool __left;
- if (_M_disjunct(__s) || _M_rep()->_M_is_shared())
- return _M_replace_safe(__pos, __n1, __s, __n2);
- else if ((__left = __s + __n2 <= _M_data() + __pos)
- || _M_data() + __pos + __n1 <= __s)
- {
- size_type __off = __s - _M_data();
- __left ? __off : (__off += __n2 - __n1);
- _M_mutate(__pos, __n1, __n2);
- _M_copy(_M_data() + __pos, _M_data() + __off, __n2);
- return *this;
- }
- else
- {
- const basic_string __tmp(__s, __n2);
- return _M_replace_safe(__pos, __n1, __tmp._M_data(), __n2);
- }
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- void
- basic_string<_CharT, _Traits, _Alloc>::_Rep::
- _M_destroy(const _Alloc& __a) throw ()
- {
- const size_type __size = sizeof(_Rep_base) +
- (this->_M_capacity + 1) * sizeof(_CharT);
- _Raw_bytes_alloc(__a).deallocate(reinterpret_cast<char*>(this), __size);
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- void
- basic_string<_CharT, _Traits, _Alloc>::
- _M_leak_hard()
- {
- if (_M_rep() == &_S_empty_rep())
- return;
- if (_M_rep()->_M_is_shared())
- _M_mutate(0, 0, 0);
- _M_rep()->_M_set_leaked();
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- void
- basic_string<_CharT, _Traits, _Alloc>::
- _M_mutate(size_type __pos, size_type __len1, size_type __len2)
- {
- const size_type __old_size = this->size();
- const size_type __new_size = __old_size + __len2 - __len1;
- const size_type __how_much = __old_size - __pos - __len1;
- if (__new_size > this->capacity() || _M_rep()->_M_is_shared())
- {
- const allocator_type __a = get_allocator();
- _Rep* __r = _Rep::_S_create(__new_size, this->capacity(), __a);
- if (__pos)
- _M_copy(__r->_M_refdata(), _M_data(), __pos);
- if (__how_much)
- _M_copy(__r->_M_refdata() + __pos + __len2,
- _M_data() + __pos + __len1, __how_much);
- _M_rep()->_M_dispose(__a);
- _M_data(__r->_M_refdata());
- }
- else if (__how_much && __len1 != __len2)
- {
- _M_move(_M_data() + __pos + __len2,
- _M_data() + __pos + __len1, __how_much);
- }
- _M_rep()->_M_set_length_and_sharable(__new_size);
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- void
- basic_string<_CharT, _Traits, _Alloc>::
- reserve(size_type __res)
- {
- if (__res != this->capacity() || _M_rep()->_M_is_shared())
- {
- if (__res < this->size())
- __res = this->size();
- const allocator_type __a = get_allocator();
- _CharT* __tmp = _M_rep()->_M_clone(__a, __res - this->size());
- _M_rep()->_M_dispose(__a);
- _M_data(__tmp);
- }
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- void
- basic_string<_CharT, _Traits, _Alloc>::
- swap(basic_string& __s)
- {
- if (_M_rep()->_M_is_leaked())
- _M_rep()->_M_set_sharable();
- if (__s._M_rep()->_M_is_leaked())
- __s._M_rep()->_M_set_sharable();
- if (this->get_allocator() == __s.get_allocator())
- {
- _CharT* __tmp = _M_data();
- _M_data(__s._M_data());
- __s._M_data(__tmp);
- }
- else
- {
- const basic_string __tmp1(_M_ibegin(), _M_iend(),
- __s.get_allocator());
- const basic_string __tmp2(__s._M_ibegin(), __s._M_iend(),
- this->get_allocator());
- *this = __tmp2;
- __s = __tmp1;
- }
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- typename basic_string<_CharT, _Traits, _Alloc>::_Rep*
- basic_string<_CharT, _Traits, _Alloc>::_Rep::
- _S_create(size_type __capacity, size_type __old_capacity,
- const _Alloc& __alloc)
- {
- if (__capacity > _S_max_size)
- __throw_length_error(("basic_string::_S_create"));
- const size_type __pagesize = 4096;
- const size_type __malloc_header_size = 4 * sizeof(void*);
- if (__capacity > __old_capacity && __capacity < 2 * __old_capacity)
- __capacity = 2 * __old_capacity;
- size_type __size = (__capacity + 1) * sizeof(_CharT) + sizeof(_Rep);
- const size_type __adj_size = __size + __malloc_header_size;
- if (__adj_size > __pagesize && __capacity > __old_capacity)
- {
- const size_type __extra = __pagesize - __adj_size % __pagesize;
- __capacity += __extra / sizeof(_CharT);
- if (__capacity > _S_max_size)
- __capacity = _S_max_size;
- __size = (__capacity + 1) * sizeof(_CharT) + sizeof(_Rep);
- }
- void* __place = _Raw_bytes_alloc(__alloc).allocate(__size);
- _Rep *__p = new (__place) _Rep;
- __p->_M_capacity = __capacity;
- __p->_M_set_sharable();
- return __p;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- _CharT*
- basic_string<_CharT, _Traits, _Alloc>::_Rep::
- _M_clone(const _Alloc& __alloc, size_type __res)
- {
- const size_type __requested_cap = this->_M_length + __res;
- _Rep* __r = _Rep::_S_create(__requested_cap, this->_M_capacity,
- __alloc);
- if (this->_M_length)
- _M_copy(__r->_M_refdata(), _M_refdata(), this->_M_length);
- __r->_M_set_length_and_sharable(this->_M_length);
- return __r->_M_refdata();
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- void
- basic_string<_CharT, _Traits, _Alloc>::
- resize(size_type __n, _CharT __c)
- {
- const size_type __size = this->size();
- _M_check_length(__size, __n, "basic_string::resize");
- if (__size < __n)
- this->append(__n - __size, __c);
- else if (__n < __size)
- this->erase(__n);
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- template<typename _InputIterator>
- basic_string<_CharT, _Traits, _Alloc>&
- basic_string<_CharT, _Traits, _Alloc>::
- _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
- _InputIterator __k2, __false_type)
- {
- const basic_string __s(__k1, __k2);
- const size_type __n1 = __i2 - __i1;
- _M_check_length(__n1, __s.size(), "basic_string::_M_replace_dispatch");
- return _M_replace_safe(__i1 - _M_ibegin(), __n1, __s._M_data(),
- __s.size());
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT, _Traits, _Alloc>&
- basic_string<_CharT, _Traits, _Alloc>::
- _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
- _CharT __c)
- {
- _M_check_length(__n1, __n2, "basic_string::_M_replace_aux");
- _M_mutate(__pos1, __n1, __n2);
- if (__n2)
- _M_assign(_M_data() + __pos1, __n2, __c);
- return *this;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT, _Traits, _Alloc>&
- basic_string<_CharT, _Traits, _Alloc>::
- _M_replace_safe(size_type __pos1, size_type __n1, const _CharT* __s,
- size_type __n2)
- {
- _M_mutate(__pos1, __n1, __n2);
- if (__n2)
- _M_copy(_M_data() + __pos1, __s, __n2);
- return *this;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT, _Traits, _Alloc>
- operator+(const _CharT* __lhs,
- const basic_string<_CharT, _Traits, _Alloc>& __rhs)
- {
- ;
- typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
- typedef typename __string_type::size_type __size_type;
- const __size_type __len = _Traits::length(__lhs);
- __string_type __str;
- __str.reserve(__len + __rhs.size());
- __str.append(__lhs, __len);
- __str.append(__rhs);
- return __str;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT, _Traits, _Alloc>
- operator+(_CharT __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs)
- {
- typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
- typedef typename __string_type::size_type __size_type;
- __string_type __str;
- const __size_type __len = __rhs.size();
- __str.reserve(__len + 1);
- __str.append(__size_type(1), __lhs);
- __str.append(__rhs);
- return __str;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- typename basic_string<_CharT, _Traits, _Alloc>::size_type
- basic_string<_CharT, _Traits, _Alloc>::
- copy(_CharT* __s, size_type __n, size_type __pos) const
- {
- _M_check(__pos, "basic_string::copy");
- __n = _M_limit(__pos, __n);
- ;
- if (__n)
- _M_copy(__s, _M_data() + __pos, __n);
- return __n;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- typename basic_string<_CharT, _Traits, _Alloc>::size_type
- basic_string<_CharT, _Traits, _Alloc>::
- find(const _CharT* __s, size_type __pos, size_type __n) const
- {
- ;
- const size_type __size = this->size();
- const _CharT* __data = _M_data();
- if (__n == 0)
- return __pos <= __size ? __pos : npos;
- if (__n <= __size)
- {
- for (; __pos <= __size - __n; ++__pos)
- if (traits_type::eq(__data[__pos], __s[0])
- && traits_type::compare(__data + __pos + 1,
- __s + 1, __n - 1) == 0)
- return __pos;
- }
- return npos;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- typename basic_string<_CharT, _Traits, _Alloc>::size_type
- basic_string<_CharT, _Traits, _Alloc>::
- find(_CharT __c, size_type __pos) const
- {
- size_type __ret = npos;
- const size_type __size = this->size();
- if (__pos < __size)
- {
- const _CharT* __data = _M_data();
- const size_type __n = __size - __pos;
- const _CharT* __p = traits_type::find(__data + __pos, __n, __c);
- if (__p)
- __ret = __p - __data;
- }
- return __ret;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- typename basic_string<_CharT, _Traits, _Alloc>::size_type
- basic_string<_CharT, _Traits, _Alloc>::
- rfind(const _CharT* __s, size_type __pos, size_type __n) const
- {
- ;
- const size_type __size = this->size();
- if (__n <= __size)
- {
- __pos = std::min(size_type(__size - __n), __pos);
- const _CharT* __data = _M_data();
- do
- {
- if (traits_type::compare(__data + __pos, __s, __n) == 0)
- return __pos;
- }
- while (__pos-- > 0);
- }
- return npos;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- typename basic_string<_CharT, _Traits, _Alloc>::size_type
- basic_string<_CharT, _Traits, _Alloc>::
- rfind(_CharT __c, size_type __pos) const
- {
- size_type __size = this->size();
- if (__size)
- {
- if (--__size > __pos)
- __size = __pos;
- for (++__size; __size-- > 0; )
- if (traits_type::eq(_M_data()[__size], __c))
- return __size;
- }
- return npos;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- typename basic_string<_CharT, _Traits, _Alloc>::size_type
- basic_string<_CharT, _Traits, _Alloc>::
- find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
- {
- ;
- for (; __n && __pos < this->size(); ++__pos)
- {
- const _CharT* __p = traits_type::find(__s, __n, _M_data()[__pos]);
- if (__p)
- return __pos;
- }
- return npos;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- typename basic_string<_CharT, _Traits, _Alloc>::size_type
- basic_string<_CharT, _Traits, _Alloc>::
- find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
- {
- ;
- size_type __size = this->size();
- if (__size && __n)
- {
- if (--__size > __pos)
- __size = __pos;
- do
- {
- if (traits_type::find(__s, __n, _M_data()[__size]))
- return __size;
- }
- while (__size-- != 0);
- }
- return npos;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- typename basic_string<_CharT, _Traits, _Alloc>::size_type
- basic_string<_CharT, _Traits, _Alloc>::
- find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
- {
- ;
- for (; __pos < this->size(); ++__pos)
- if (!traits_type::find(__s, __n, _M_data()[__pos]))
- return __pos;
- return npos;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- typename basic_string<_CharT, _Traits, _Alloc>::size_type
- basic_string<_CharT, _Traits, _Alloc>::
- find_first_not_of(_CharT __c, size_type __pos) const
- {
- for (; __pos < this->size(); ++__pos)
- if (!traits_type::eq(_M_data()[__pos], __c))
- return __pos;
- return npos;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- typename basic_string<_CharT, _Traits, _Alloc>::size_type
- basic_string<_CharT, _Traits, _Alloc>::
- find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
- {
- ;
- size_type __size = this->size();
- if (__size)
- {
- if (--__size > __pos)
- __size = __pos;
- do
- {
- if (!traits_type::find(__s, __n, _M_data()[__size]))
- return __size;
- }
- while (__size--);
- }
- return npos;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- typename basic_string<_CharT, _Traits, _Alloc>::size_type
- basic_string<_CharT, _Traits, _Alloc>::
- find_last_not_of(_CharT __c, size_type __pos) const
- {
- size_type __size = this->size();
- if (__size)
- {
- if (--__size > __pos)
- __size = __pos;
- do
- {
- if (!traits_type::eq(_M_data()[__size], __c))
- return __size;
- }
- while (__size--);
- }
- return npos;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- int
- basic_string<_CharT, _Traits, _Alloc>::
- compare(size_type __pos, size_type __n, const basic_string& __str) const
- {
- _M_check(__pos, "basic_string::compare");
- __n = _M_limit(__pos, __n);
- const size_type __osize = __str.size();
- const size_type __len = std::min(__n, __osize);
- int __r = traits_type::compare(_M_data() + __pos, __str.data(), __len);
- if (!__r)
- __r = _S_compare(__n, __osize);
- return __r;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- int
- basic_string<_CharT, _Traits, _Alloc>::
- compare(size_type __pos1, size_type __n1, const basic_string& __str,
- size_type __pos2, size_type __n2) const
- {
- _M_check(__pos1, "basic_string::compare");
- __str._M_check(__pos2, "basic_string::compare");
- __n1 = _M_limit(__pos1, __n1);
- __n2 = __str._M_limit(__pos2, __n2);
- const size_type __len = std::min(__n1, __n2);
- int __r = traits_type::compare(_M_data() + __pos1,
- __str.data() + __pos2, __len);
- if (!__r)
- __r = _S_compare(__n1, __n2);
- return __r;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- int
- basic_string<_CharT, _Traits, _Alloc>::
- compare(const _CharT* __s) const
- {
- ;
- const size_type __size = this->size();
- const size_type __osize = traits_type::length(__s);
- const size_type __len = std::min(__size, __osize);
- int __r = traits_type::compare(_M_data(), __s, __len);
- if (!__r)
- __r = _S_compare(__size, __osize);
- return __r;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- int
- basic_string <_CharT, _Traits, _Alloc>::
- compare(size_type __pos, size_type __n1, const _CharT* __s) const
- {
- ;
- _M_check(__pos, "basic_string::compare");
- __n1 = _M_limit(__pos, __n1);
- const size_type __osize = traits_type::length(__s);
- const size_type __len = std::min(__n1, __osize);
- int __r = traits_type::compare(_M_data() + __pos, __s, __len);
- if (!__r)
- __r = _S_compare(__n1, __osize);
- return __r;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- int
- basic_string <_CharT, _Traits, _Alloc>::
- compare(size_type __pos, size_type __n1, const _CharT* __s,
- size_type __n2) const
- {
- ;
- _M_check(__pos, "basic_string::compare");
- __n1 = _M_limit(__pos, __n1);
- const size_type __len = std::min(__n1, __n2);
- int __r = traits_type::compare(_M_data() + __pos, __s, __len);
- if (!__r)
- __r = _S_compare(__n1, __n2);
- return __r;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_istream<_CharT, _Traits>&
- operator>>(basic_istream<_CharT, _Traits>& __in,
- basic_string<_CharT, _Traits, _Alloc>& __str)
- {
- typedef basic_istream<_CharT, _Traits> __istream_type;
- typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
- typedef typename __istream_type::ios_base __ios_base;
- typedef typename __istream_type::int_type __int_type;
- typedef typename __string_type::size_type __size_type;
- typedef ctype<_CharT> __ctype_type;
- typedef typename __ctype_type::ctype_base __ctype_base;
- __size_type __extracted = 0;
- typename __ios_base::iostate __err = __ios_base::goodbit;
- typename __istream_type::sentry __cerb(__in, false);
- if (__cerb)
- {
- try
- {
- __str.erase();
- _CharT __buf[128];
- __size_type __len = 0;
- const streamsize __w = __in.width();
- const __size_type __n = __w > 0 ? static_cast<__size_type>(__w)
- : __str.max_size();
- const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc());
- const __int_type __eof = _Traits::eof();
- __int_type __c = __in.rdbuf()->sgetc();
- while (__extracted < __n
- && !_Traits::eq_int_type(__c, __eof)
- && !__ct.is(__ctype_base::space,
- _Traits::to_char_type(__c)))
- {
- if (__len == sizeof(__buf) / sizeof(_CharT))
- {
- __str.append(__buf, sizeof(__buf) / sizeof(_CharT));
- __len = 0;
- }
- __buf[__len++] = _Traits::to_char_type(__c);
- ++__extracted;
- __c = __in.rdbuf()->snextc();
- }
- __str.append(__buf, __len);
- if (_Traits::eq_int_type(__c, __eof))
- __err |= __ios_base::eofbit;
- __in.width(0);
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- __in._M_setstate(__ios_base::badbit);
- throw;
- }
- catch(...)
- {
- __in._M_setstate(__ios_base::badbit);
- }
- }
- if (!__extracted)
- __err |= __ios_base::failbit;
- if (__err)
- __in.setstate(__err);
- return __in;
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_istream<_CharT, _Traits>&
- getline(basic_istream<_CharT, _Traits>& __in,
- basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim)
- {
- typedef basic_istream<_CharT, _Traits> __istream_type;
- typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
- typedef typename __istream_type::ios_base __ios_base;
- typedef typename __istream_type::int_type __int_type;
- typedef typename __string_type::size_type __size_type;
- __size_type __extracted = 0;
- const __size_type __n = __str.max_size();
- typename __ios_base::iostate __err = __ios_base::goodbit;
- typename __istream_type::sentry __cerb(__in, true);
- if (__cerb)
- {
- try
- {
- __str.erase();
- const __int_type __idelim = _Traits::to_int_type(__delim);
- const __int_type __eof = _Traits::eof();
- __int_type __c = __in.rdbuf()->sgetc();
- while (__extracted < __n
- && !_Traits::eq_int_type(__c, __eof)
- && !_Traits::eq_int_type(__c, __idelim))
- {
- __str += _Traits::to_char_type(__c);
- ++__extracted;
- __c = __in.rdbuf()->snextc();
- }
- if (_Traits::eq_int_type(__c, __eof))
- __err |= __ios_base::eofbit;
- else if (_Traits::eq_int_type(__c, __idelim))
- {
- ++__extracted;
- __in.rdbuf()->sbumpc();
- }
- else
- __err |= __ios_base::failbit;
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- __in._M_setstate(__ios_base::badbit);
- throw;
- }
- catch(...)
- {
- __in._M_setstate(__ios_base::badbit);
- }
- }
- if (!__extracted)
- __err |= __ios_base::failbit;
- if (__err)
- __in.setstate(__err);
- return __in;
- }
- extern template class basic_string<char>;
- extern template
- basic_istream<char>&
- operator>>(basic_istream<char>&, string&);
- extern template
- basic_ostream<char>&
- operator<<(basic_ostream<char>&, const string&);
- extern template
- basic_istream<char>&
- getline(basic_istream<char>&, string&, char);
- extern template
- basic_istream<char>&
- getline(basic_istream<char>&, string&);
- extern template class basic_string<wchar_t>;
- extern template
- basic_istream<wchar_t>&
- operator>>(basic_istream<wchar_t>&, wstring&);
- extern template
- basic_ostream<wchar_t>&
- operator<<(basic_ostream<wchar_t>&, const wstring&);
- extern template
- basic_istream<wchar_t>&
- getline(basic_istream<wchar_t>&, wstring&, wchar_t);
- extern template
- basic_istream<wchar_t>&
- getline(basic_istream<wchar_t>&, wstring&);
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- class locale
- {
- public:
- typedef int category;
- class facet;
- class id;
- class _Impl;
- friend class facet;
- friend class _Impl;
- template<typename _Facet>
- friend bool
- has_facet(const locale&) throw();
- template<typename _Facet>
- friend const _Facet&
- use_facet(const locale&);
- template<typename _Cache>
- friend struct __use_cache;
- static const category none = 0;
- static const category ctype = 1L << 0;
- static const category numeric = 1L << 1;
- static const category collate = 1L << 2;
- static const category time = 1L << 3;
- static const category monetary = 1L << 4;
- static const category messages = 1L << 5;
- static const category all = (ctype | numeric | collate |
- time | monetary | messages);
- locale() throw();
- locale(const locale& __other) throw();
- explicit
- locale(const char* __s);
- locale(const locale& __base, const char* __s, category __cat);
- locale(const locale& __base, const locale& __add, category __cat);
- template<typename _Facet>
- locale(const locale& __other, _Facet* __f);
- ~locale() throw();
- const locale&
- operator=(const locale& __other) throw();
- template<typename _Facet>
- locale
- combine(const locale& __other) const;
- string
- name() const;
- bool
- operator==(const locale& __other) const throw();
- bool
- operator!=(const locale& __other) const throw()
- { return !(this->operator==(__other)); }
- template<typename _Char, typename _Traits, typename _Alloc>
- bool
- operator()(const basic_string<_Char, _Traits, _Alloc>& __s1,
- const basic_string<_Char, _Traits, _Alloc>& __s2) const;
- static locale
- global(const locale&);
- static const locale&
- classic();
- private:
- _Impl* _M_impl;
- static _Impl* _S_classic;
- static _Impl* _S_global;
- static const char* const* const _S_categories;
- enum { _S_categories_size = 6 + 6 };
- static __gthread_once_t _S_once;
- explicit
- locale(_Impl*) throw();
- static void
- _S_initialize();
- static void
- _S_initialize_once() throw();
- static category
- _S_normalize_category(category);
- void
- _M_coalesce(const locale& __base, const locale& __add, category __cat);
- };
- class locale::facet
- {
- private:
- friend class locale;
- friend class locale::_Impl;
- mutable _Atomic_word _M_refcount;
- static __c_locale _S_c_locale;
- static const char _S_c_name[2];
- static __gthread_once_t _S_once;
- static void
- _S_initialize_once();
- protected:
- explicit
- facet(size_t __refs = 0) throw() : _M_refcount(__refs ? 1 : 0)
- { }
- virtual
- ~facet();
- static void
- _S_create_c_locale(__c_locale& __cloc, const char* __s,
- __c_locale __old = 0);
- static __c_locale
- _S_clone_c_locale(__c_locale& __cloc) throw();
- static void
- _S_destroy_c_locale(__c_locale& __cloc);
- static __c_locale
- _S_lc_ctype_c_locale(__c_locale __cloc, const char* __s);
- static __c_locale
- _S_get_c_locale();
- __attribute__ ((__const__)) static const char*
- _S_get_c_name() throw();
- private:
- void
- _M_add_reference() const throw()
- { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
- void
- _M_remove_reference() const throw()
- {
- ;
- if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1)
- {
- ;
- try
- { delete this; }
- catch(...)
- { }
- }
- }
- facet(const facet&);
- facet&
- operator=(const facet&);
- };
- class locale::id
- {
- private:
- friend class locale;
- friend class locale::_Impl;
- template<typename _Facet>
- friend const _Facet&
- use_facet(const locale&);
- template<typename _Facet>
- friend bool
- has_facet(const locale&) throw();
- mutable size_t _M_index;
- static _Atomic_word _S_refcount;
- void
- operator=(const id&);
- id(const id&);
- public:
- id() { }
- size_t
- _M_id() const throw();
- };
- class locale::_Impl
- {
- public:
- friend class locale;
- friend class locale::facet;
- template<typename _Facet>
- friend bool
- has_facet(const locale&) throw();
- template<typename _Facet>
- friend const _Facet&
- use_facet(const locale&);
- template<typename _Cache>
- friend struct __use_cache;
- private:
- _Atomic_word _M_refcount;
- const facet** _M_facets;
- size_t _M_facets_size;
- const facet** _M_caches;
- char** _M_names;
- static const locale::id* const _S_id_ctype[];
- static const locale::id* const _S_id_numeric[];
- static const locale::id* const _S_id_collate[];
- static const locale::id* const _S_id_time[];
- static const locale::id* const _S_id_monetary[];
- static const locale::id* const _S_id_messages[];
- static const locale::id* const* const _S_facet_categories[];
- void
- _M_add_reference() throw()
- { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
- void
- _M_remove_reference() throw()
- {
- ;
- if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1)
- {
- ;
- try
- { delete this; }
- catch(...)
- { }
- }
- }
- _Impl(const _Impl&, size_t);
- _Impl(const char*, size_t);
- _Impl(size_t) throw();
- ~_Impl() throw();
- _Impl(const _Impl&);
- void
- operator=(const _Impl&);
- bool
- _M_check_same_name()
- {
- bool __ret = true;
- if (_M_names[1])
- for (size_t __i = 0; __ret && __i < _S_categories_size - 1; ++__i)
- __ret = __builtin_strcmp(_M_names[__i], _M_names[__i + 1]) == 0;
- return __ret;
- }
- void
- _M_replace_categories(const _Impl*, category);
- void
- _M_replace_category(const _Impl*, const locale::id* const*);
- void
- _M_replace_facet(const _Impl*, const locale::id*);
- void
- _M_install_facet(const locale::id*, const facet*);
- template<typename _Facet>
- void
- _M_init_facet(_Facet* __facet)
- { _M_install_facet(&_Facet::id, __facet); }
- void
- _M_install_cache(const facet*, size_t);
- };
- template<typename _Facet>
- bool
- has_facet(const locale& __loc) throw();
- template<typename _Facet>
- const _Facet&
- use_facet(const locale& __loc);
- template<typename _CharT>
- class collate : public locale::facet
- {
- public:
- typedef _CharT char_type;
- typedef basic_string<_CharT> string_type;
- protected:
- __c_locale _M_c_locale_collate;
- public:
- static locale::id id;
- explicit
- collate(size_t __refs = 0)
- : facet(__refs), _M_c_locale_collate(_S_get_c_locale())
- { }
- explicit
- collate(__c_locale __cloc, size_t __refs = 0)
- : facet(__refs), _M_c_locale_collate(_S_clone_c_locale(__cloc))
- { }
- int
- compare(const _CharT* __lo1, const _CharT* __hi1,
- const _CharT* __lo2, const _CharT* __hi2) const
- { return this->do_compare(__lo1, __hi1, __lo2, __hi2); }
- string_type
- transform(const _CharT* __lo, const _CharT* __hi) const
- { return this->do_transform(__lo, __hi); }
- long
- hash(const _CharT* __lo, const _CharT* __hi) const
- { return this->do_hash(__lo, __hi); }
- int
- _M_compare(const _CharT*, const _CharT*) const throw();
- size_t
- _M_transform(_CharT*, const _CharT*, size_t) const throw();
- protected:
- virtual
- ~collate()
- { _S_destroy_c_locale(_M_c_locale_collate); }
- virtual int
- do_compare(const _CharT* __lo1, const _CharT* __hi1,
- const _CharT* __lo2, const _CharT* __hi2) const;
- virtual string_type
- do_transform(const _CharT* __lo, const _CharT* __hi) const;
- virtual long
- do_hash(const _CharT* __lo, const _CharT* __hi) const;
- };
- template<typename _CharT>
- locale::id collate<_CharT>::id;
- template<>
- int
- collate<char>::_M_compare(const char*, const char*) const throw();
- template<>
- size_t
- collate<char>::_M_transform(char*, const char*, size_t) const throw();
- template<>
- int
- collate<wchar_t>::_M_compare(const wchar_t*, const wchar_t*) const throw();
- template<>
- size_t
- collate<wchar_t>::_M_transform(wchar_t*, const wchar_t*, size_t) const throw();
- template<typename _CharT>
- class collate_byname : public collate<_CharT>
- {
- public:
- typedef _CharT char_type;
- typedef basic_string<_CharT> string_type;
- explicit
- collate_byname(const char* __s, size_t __refs = 0)
- : collate<_CharT>(__refs)
- {
- if (__builtin_strcmp(__s, "C") != 0
- && __builtin_strcmp(__s, "POSIX") != 0)
- {
- this->_S_destroy_c_locale(this->_M_c_locale_collate);
- this->_S_create_c_locale(this->_M_c_locale_collate, __s);
- }
- }
- protected:
- virtual
- ~collate_byname() { }
- };
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _Facet>
- locale::
- locale(const locale& __other, _Facet* __f)
- {
- _M_impl = new _Impl(*__other._M_impl, 1);
- try
- { _M_impl->_M_install_facet(&_Facet::id, __f); }
- catch(...)
- {
- _M_impl->_M_remove_reference();
- throw;
- }
- delete [] _M_impl->_M_names[0];
- _M_impl->_M_names[0] = 0;
- }
- template<typename _Facet>
- locale
- locale::
- combine(const locale& __other) const
- {
- _Impl* __tmp = new _Impl(*_M_impl, 1);
- try
- {
- __tmp->_M_replace_facet(__other._M_impl, &_Facet::id);
- }
- catch(...)
- {
- __tmp->_M_remove_reference();
- throw;
- }
- return locale(__tmp);
- }
- template<typename _CharT, typename _Traits, typename _Alloc>
- bool
- locale::
- operator()(const basic_string<_CharT, _Traits, _Alloc>& __s1,
- const basic_string<_CharT, _Traits, _Alloc>& __s2) const
- {
- typedef std::collate<_CharT> __collate_type;
- const __collate_type& __collate = use_facet<__collate_type>(*this);
- return (__collate.compare(__s1.data(), __s1.data() + __s1.length(),
- __s2.data(), __s2.data() + __s2.length()) < 0);
- }
- template<typename _Facet>
- bool
- has_facet(const locale& __loc) throw()
- {
- const size_t __i = _Facet::id._M_id();
- const locale::facet** __facets = __loc._M_impl->_M_facets;
- return (__i < __loc._M_impl->_M_facets_size
- && dynamic_cast<const _Facet*>(__facets[__i]));
- }
- template<typename _Facet>
- const _Facet&
- use_facet(const locale& __loc)
- {
- const size_t __i = _Facet::id._M_id();
- const locale::facet** __facets = __loc._M_impl->_M_facets;
- if (__i >= __loc._M_impl->_M_facets_size || !__facets[__i])
- __throw_bad_cast();
- return dynamic_cast<const _Facet&>(*__facets[__i]);
- }
- template<typename _CharT>
- int
- collate<_CharT>::_M_compare(const _CharT*, const _CharT*) const throw ()
- { return 0; }
- template<typename _CharT>
- size_t
- collate<_CharT>::_M_transform(_CharT*, const _CharT*, size_t) const throw ()
- { return 0; }
- template<typename _CharT>
- int
- collate<_CharT>::
- do_compare(const _CharT* __lo1, const _CharT* __hi1,
- const _CharT* __lo2, const _CharT* __hi2) const
- {
- const string_type __one(__lo1, __hi1);
- const string_type __two(__lo2, __hi2);
- const _CharT* __p = __one.c_str();
- const _CharT* __pend = __one.data() + __one.length();
- const _CharT* __q = __two.c_str();
- const _CharT* __qend = __two.data() + __two.length();
- for (;;)
- {
- const int __res = _M_compare(__p, __q);
- if (__res)
- return __res;
- __p += char_traits<_CharT>::length(__p);
- __q += char_traits<_CharT>::length(__q);
- if (__p == __pend && __q == __qend)
- return 0;
- else if (__p == __pend)
- return -1;
- else if (__q == __qend)
- return 1;
- __p++;
- __q++;
- }
- }
- template<typename _CharT>
- typename collate<_CharT>::string_type
- collate<_CharT>::
- do_transform(const _CharT* __lo, const _CharT* __hi) const
- {
- string_type __ret;
- const string_type __str(__lo, __hi);
- const _CharT* __p = __str.c_str();
- const _CharT* __pend = __str.data() + __str.length();
- size_t __len = (__hi - __lo) * 2;
- _CharT* __c = new _CharT[__len];
- try
- {
- for (;;)
- {
- size_t __res = _M_transform(__c, __p, __len);
- if (__res >= __len)
- {
- __len = __res + 1;
- delete [] __c, __c = 0;
- __c = new _CharT[__len];
- __res = _M_transform(__c, __p, __len);
- }
- __ret.append(__c, __res);
- __p += char_traits<_CharT>::length(__p);
- if (__p == __pend)
- break;
- __p++;
- __ret.push_back(_CharT());
- }
- }
- catch(...)
- {
- delete [] __c;
- throw;
- }
- delete [] __c;
- return __ret;
- }
- template<typename _CharT>
- long
- collate<_CharT>::
- do_hash(const _CharT* __lo, const _CharT* __hi) const
- {
- unsigned long __val = 0;
- for (; __lo < __hi; ++__lo)
- __val =
- *__lo + ((__val << 7)
- | (__val >> (__gnu_cxx::__numeric_traits<unsigned long>::
- __digits - 7)));
- return static_cast<long>(__val);
- }
- extern template class collate<char>;
- extern template class collate_byname<char>;
- extern template
- const collate<char>&
- use_facet<collate<char> >(const locale&);
- extern template
- bool
- has_facet<collate<char> >(const locale&);
- extern template class collate<wchar_t>;
- extern template class collate_byname<wchar_t>;
- extern template
- const collate<wchar_t>&
- use_facet<collate<wchar_t> >(const locale&);
- extern template
- bool
- has_facet<collate<wchar_t> >(const locale&);
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- enum _Ios_Fmtflags
- {
- _S_boolalpha = 1L << 0,
- _S_dec = 1L << 1,
- _S_fixed = 1L << 2,
- _S_hex = 1L << 3,
- _S_internal = 1L << 4,
- _S_left = 1L << 5,
- _S_oct = 1L << 6,
- _S_right = 1L << 7,
- _S_scientific = 1L << 8,
- _S_showbase = 1L << 9,
- _S_showpoint = 1L << 10,
- _S_showpos = 1L << 11,
- _S_skipws = 1L << 12,
- _S_unitbuf = 1L << 13,
- _S_uppercase = 1L << 14,
- _S_adjustfield = _S_left | _S_right | _S_internal,
- _S_basefield = _S_dec | _S_oct | _S_hex,
- _S_floatfield = _S_scientific | _S_fixed,
- _S_ios_fmtflags_end = 1L << 16
- };
- inline _Ios_Fmtflags
- operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
- { return _Ios_Fmtflags(static_cast<int>(__a) & static_cast<int>(__b)); }
- inline _Ios_Fmtflags
- operator|(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
- { return _Ios_Fmtflags(static_cast<int>(__a) | static_cast<int>(__b)); }
- inline _Ios_Fmtflags
- operator^(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
- { return _Ios_Fmtflags(static_cast<int>(__a) ^ static_cast<int>(__b)); }
- inline _Ios_Fmtflags
- operator~(_Ios_Fmtflags __a)
- { return _Ios_Fmtflags(~static_cast<int>(__a)); }
- inline const _Ios_Fmtflags&
- operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
- { return __a = __a | __b; }
- inline const _Ios_Fmtflags&
- operator&=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
- { return __a = __a & __b; }
- inline const _Ios_Fmtflags&
- operator^=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
- { return __a = __a ^ __b; }
- enum _Ios_Openmode
- {
- _S_app = 1L << 0,
- _S_ate = 1L << 1,
- _S_bin = 1L << 2,
- _S_in = 1L << 3,
- _S_out = 1L << 4,
- _S_trunc = 1L << 5,
- _S_ios_openmode_end = 1L << 16
- };
- inline _Ios_Openmode
- operator&(_Ios_Openmode __a, _Ios_Openmode __b)
- { return _Ios_Openmode(static_cast<int>(__a) & static_cast<int>(__b)); }
- inline _Ios_Openmode
- operator|(_Ios_Openmode __a, _Ios_Openmode __b)
- { return _Ios_Openmode(static_cast<int>(__a) | static_cast<int>(__b)); }
- inline _Ios_Openmode
- operator^(_Ios_Openmode __a, _Ios_Openmode __b)
- { return _Ios_Openmode(static_cast<int>(__a) ^ static_cast<int>(__b)); }
- inline _Ios_Openmode
- operator~(_Ios_Openmode __a)
- { return _Ios_Openmode(~static_cast<int>(__a)); }
- inline const _Ios_Openmode&
- operator|=(_Ios_Openmode& __a, _Ios_Openmode __b)
- { return __a = __a | __b; }
- inline const _Ios_Openmode&
- operator&=(_Ios_Openmode& __a, _Ios_Openmode __b)
- { return __a = __a & __b; }
- inline const _Ios_Openmode&
- operator^=(_Ios_Openmode& __a, _Ios_Openmode __b)
- { return __a = __a ^ __b; }
- enum _Ios_Iostate
- {
- _S_goodbit = 0,
- _S_badbit = 1L << 0,
- _S_eofbit = 1L << 1,
- _S_failbit = 1L << 2,
- _S_ios_iostate_end = 1L << 16
- };
- inline _Ios_Iostate
- operator&(_Ios_Iostate __a, _Ios_Iostate __b)
- { return _Ios_Iostate(static_cast<int>(__a) & static_cast<int>(__b)); }
- inline _Ios_Iostate
- operator|(_Ios_Iostate __a, _Ios_Iostate __b)
- { return _Ios_Iostate(static_cast<int>(__a) | static_cast<int>(__b)); }
- inline _Ios_Iostate
- operator^(_Ios_Iostate __a, _Ios_Iostate __b)
- { return _Ios_Iostate(static_cast<int>(__a) ^ static_cast<int>(__b)); }
- inline _Ios_Iostate
- operator~(_Ios_Iostate __a)
- { return _Ios_Iostate(~static_cast<int>(__a)); }
- inline const _Ios_Iostate&
- operator|=(_Ios_Iostate& __a, _Ios_Iostate __b)
- { return __a = __a | __b; }
- inline const _Ios_Iostate&
- operator&=(_Ios_Iostate& __a, _Ios_Iostate __b)
- { return __a = __a & __b; }
- inline const _Ios_Iostate&
- operator^=(_Ios_Iostate& __a, _Ios_Iostate __b)
- { return __a = __a ^ __b; }
- enum _Ios_Seekdir
- {
- _S_beg = 0,
- _S_cur = 1,
- _S_end = 2,
- _S_ios_seekdir_end = 1L << 16
- };
- class ios_base
- {
- public:
- class failure : public exception
- {
- public:
- explicit
- failure(const string& __str) throw();
- virtual
- ~failure() throw();
- virtual const char*
- what() const throw();
- private:
- string _M_msg;
- };
- typedef _Ios_Fmtflags fmtflags;
- static const fmtflags boolalpha = _S_boolalpha;
- static const fmtflags dec = _S_dec;
- static const fmtflags fixed = _S_fixed;
- static const fmtflags hex = _S_hex;
- static const fmtflags internal = _S_internal;
- static const fmtflags left = _S_left;
- static const fmtflags oct = _S_oct;
- static const fmtflags right = _S_right;
- static const fmtflags scientific = _S_scientific;
- static const fmtflags showbase = _S_showbase;
- static const fmtflags showpoint = _S_showpoint;
- static const fmtflags showpos = _S_showpos;
- static const fmtflags skipws = _S_skipws;
- static const fmtflags unitbuf = _S_unitbuf;
- static const fmtflags uppercase = _S_uppercase;
- static const fmtflags adjustfield = _S_adjustfield;
- static const fmtflags basefield = _S_basefield;
- static const fmtflags floatfield = _S_floatfield;
- typedef _Ios_Iostate iostate;
- static const iostate badbit = _S_badbit;
- static const iostate eofbit = _S_eofbit;
- static const iostate failbit = _S_failbit;
- static const iostate goodbit = _S_goodbit;
- typedef _Ios_Openmode openmode;
- static const openmode app = _S_app;
- static const openmode ate = _S_ate;
- static const openmode binary = _S_bin;
- static const openmode in = _S_in;
- static const openmode out = _S_out;
- static const openmode trunc = _S_trunc;
- typedef _Ios_Seekdir seekdir;
- static const seekdir beg = _S_beg;
- static const seekdir cur = _S_cur;
- static const seekdir end = _S_end;
- typedef int io_state;
- typedef int open_mode;
- typedef int seek_dir;
- typedef std::streampos streampos;
- typedef std::streamoff streamoff;
- enum event
- {
- erase_event,
- imbue_event,
- copyfmt_event
- };
- typedef void (*event_callback) (event, ios_base&, int);
- void
- register_callback(event_callback __fn, int __index);
- protected:
- streamsize _M_precision;
- streamsize _M_width;
- fmtflags _M_flags;
- iostate _M_exception;
- iostate _M_streambuf_state;
- struct _Callback_list
- {
- _Callback_list* _M_next;
- ios_base::event_callback _M_fn;
- int _M_index;
- _Atomic_word _M_refcount;
- _Callback_list(ios_base::event_callback __fn, int __index,
- _Callback_list* __cb)
- : _M_next(__cb), _M_fn(__fn), _M_index(__index), _M_refcount(0) { }
- void
- _M_add_reference() { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
- int
- _M_remove_reference()
- {
- ;
- int __res = __gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1);
- if (__res == 0)
- {
- ;
- }
- return __res;
- }
- };
- _Callback_list* _M_callbacks;
- void
- _M_call_callbacks(event __ev) throw();
- void
- _M_dispose_callbacks(void) throw();
- struct _Words
- {
- void* _M_pword;
- long _M_iword;
- _Words() : _M_pword(0), _M_iword(0) { }
- };
- _Words _M_word_zero;
- enum { _S_local_word_size = 8 };
- _Words _M_local_word[_S_local_word_size];
- int _M_word_size;
- _Words* _M_word;
- _Words&
- _M_grow_words(int __index, bool __iword);
- locale _M_ios_locale;
- void
- _M_init() throw();
- public:
- class Init
- {
- friend class ios_base;
- public:
- Init();
- ~Init();
- private:
- static _Atomic_word _S_refcount;
- static bool _S_synced_with_stdio;
- };
- fmtflags
- flags() const
- { return _M_flags; }
- fmtflags
- flags(fmtflags __fmtfl)
- {
- fmtflags __old = _M_flags;
- _M_flags = __fmtfl;
- return __old;
- }
- fmtflags
- setf(fmtflags __fmtfl)
- {
- fmtflags __old = _M_flags;
- _M_flags |= __fmtfl;
- return __old;
- }
- fmtflags
- setf(fmtflags __fmtfl, fmtflags __mask)
- {
- fmtflags __old = _M_flags;
- _M_flags &= ~__mask;
- _M_flags |= (__fmtfl & __mask);
- return __old;
- }
- void
- unsetf(fmtflags __mask)
- { _M_flags &= ~__mask; }
- streamsize
- precision() const
- { return _M_precision; }
- streamsize
- precision(streamsize __prec)
- {
- streamsize __old = _M_precision;
- _M_precision = __prec;
- return __old;
- }
- streamsize
- width() const
- { return _M_width; }
- streamsize
- width(streamsize __wide)
- {
- streamsize __old = _M_width;
- _M_width = __wide;
- return __old;
- }
- static bool
- sync_with_stdio(bool __sync = true);
- locale
- imbue(const locale& __loc) throw();
- locale
- getloc() const
- { return _M_ios_locale; }
- const locale&
- _M_getloc() const
- { return _M_ios_locale; }
- static int
- xalloc() throw();
- long&
- iword(int __ix)
- {
- _Words& __word = (__ix < _M_word_size)
- ? _M_word[__ix] : _M_grow_words(__ix, true);
- return __word._M_iword;
- }
- void*&
- pword(int __ix)
- {
- _Words& __word = (__ix < _M_word_size)
- ? _M_word[__ix] : _M_grow_words(__ix, false);
- return __word._M_pword;
- }
- virtual ~ios_base();
- protected:
- ios_base() throw ();
- private:
- ios_base(const ios_base&);
- ios_base&
- operator=(const ios_base&);
- };
- inline ios_base&
- boolalpha(ios_base& __base)
- {
- __base.setf(ios_base::boolalpha);
- return __base;
- }
- inline ios_base&
- noboolalpha(ios_base& __base)
- {
- __base.unsetf(ios_base::boolalpha);
- return __base;
- }
- inline ios_base&
- showbase(ios_base& __base)
- {
- __base.setf(ios_base::showbase);
- return __base;
- }
- inline ios_base&
- noshowbase(ios_base& __base)
- {
- __base.unsetf(ios_base::showbase);
- return __base;
- }
- inline ios_base&
- showpoint(ios_base& __base)
- {
- __base.setf(ios_base::showpoint);
- return __base;
- }
- inline ios_base&
- noshowpoint(ios_base& __base)
- {
- __base.unsetf(ios_base::showpoint);
- return __base;
- }
- inline ios_base&
- showpos(ios_base& __base)
- {
- __base.setf(ios_base::showpos);
- return __base;
- }
- inline ios_base&
- noshowpos(ios_base& __base)
- {
- __base.unsetf(ios_base::showpos);
- return __base;
- }
- inline ios_base&
- skipws(ios_base& __base)
- {
- __base.setf(ios_base::skipws);
- return __base;
- }
- inline ios_base&
- noskipws(ios_base& __base)
- {
- __base.unsetf(ios_base::skipws);
- return __base;
- }
- inline ios_base&
- uppercase(ios_base& __base)
- {
- __base.setf(ios_base::uppercase);
- return __base;
- }
- inline ios_base&
- nouppercase(ios_base& __base)
- {
- __base.unsetf(ios_base::uppercase);
- return __base;
- }
- inline ios_base&
- unitbuf(ios_base& __base)
- {
- __base.setf(ios_base::unitbuf);
- return __base;
- }
- inline ios_base&
- nounitbuf(ios_base& __base)
- {
- __base.unsetf(ios_base::unitbuf);
- return __base;
- }
- inline ios_base&
- internal(ios_base& __base)
- {
- __base.setf(ios_base::internal, ios_base::adjustfield);
- return __base;
- }
- inline ios_base&
- left(ios_base& __base)
- {
- __base.setf(ios_base::left, ios_base::adjustfield);
- return __base;
- }
- inline ios_base&
- right(ios_base& __base)
- {
- __base.setf(ios_base::right, ios_base::adjustfield);
- return __base;
- }
- inline ios_base&
- dec(ios_base& __base)
- {
- __base.setf(ios_base::dec, ios_base::basefield);
- return __base;
- }
- inline ios_base&
- hex(ios_base& __base)
- {
- __base.setf(ios_base::hex, ios_base::basefield);
- return __base;
- }
- inline ios_base&
- oct(ios_base& __base)
- {
- __base.setf(ios_base::oct, ios_base::basefield);
- return __base;
- }
- inline ios_base&
- fixed(ios_base& __base)
- {
- __base.setf(ios_base::fixed, ios_base::floatfield);
- return __base;
- }
- inline ios_base&
- scientific(ios_base& __base)
- {
- __base.setf(ios_base::scientific, ios_base::floatfield);
- return __base;
- }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _CharT, typename _Traits>
- streamsize
- __copy_streambufs_eof(basic_streambuf<_CharT, _Traits>*,
- basic_streambuf<_CharT, _Traits>*, bool&);
- template<typename _CharT, typename _Traits>
- class basic_streambuf
- {
- public:
- typedef _CharT char_type;
- typedef _Traits traits_type;
- typedef typename traits_type::int_type int_type;
- typedef typename traits_type::pos_type pos_type;
- typedef typename traits_type::off_type off_type;
- typedef basic_streambuf<char_type, traits_type> __streambuf_type;
- friend class basic_ios<char_type, traits_type>;
- friend class basic_istream<char_type, traits_type>;
- friend class basic_ostream<char_type, traits_type>;
- friend class istreambuf_iterator<char_type, traits_type>;
- friend class ostreambuf_iterator<char_type, traits_type>;
- friend streamsize
- __copy_streambufs_eof<>(__streambuf_type*, __streambuf_type*, bool&);
- template<bool _IsMove, typename _CharT2>
- friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value,
- _CharT2*>::__type
- __copy_move_a2(istreambuf_iterator<_CharT2>,
- istreambuf_iterator<_CharT2>, _CharT2*);
- template<typename _CharT2>
- friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value,
- istreambuf_iterator<_CharT2> >::__type
- find(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>,
- const _CharT2&);
- template<typename _CharT2, typename _Traits2>
- friend basic_istream<_CharT2, _Traits2>&
- operator>>(basic_istream<_CharT2, _Traits2>&, _CharT2*);
- template<typename _CharT2, typename _Traits2, typename _Alloc>
- friend basic_istream<_CharT2, _Traits2>&
- operator>>(basic_istream<_CharT2, _Traits2>&,
- basic_string<_CharT2, _Traits2, _Alloc>&);
- template<typename _CharT2, typename _Traits2, typename _Alloc>
- friend basic_istream<_CharT2, _Traits2>&
- getline(basic_istream<_CharT2, _Traits2>&,
- basic_string<_CharT2, _Traits2, _Alloc>&, _CharT2);
- protected:
- char_type* _M_in_beg;
- char_type* _M_in_cur;
- char_type* _M_in_end;
- char_type* _M_out_beg;
- char_type* _M_out_cur;
- char_type* _M_out_end;
- locale _M_buf_locale;
- public:
- virtual
- ~basic_streambuf()
- { }
- locale
- pubimbue(const locale &__loc)
- {
- locale __tmp(this->getloc());
- this->imbue(__loc);
- _M_buf_locale = __loc;
- return __tmp;
- }
- locale
- getloc() const
- { return _M_buf_locale; }
- __streambuf_type*
- pubsetbuf(char_type* __s, streamsize __n)
- { return this->setbuf(__s, __n); }
- pos_type
- pubseekoff(off_type __off, ios_base::seekdir __way,
- ios_base::openmode __mode = ios_base::in | ios_base::out)
- { return this->seekoff(__off, __way, __mode); }
- pos_type
- pubseekpos(pos_type __sp,
- ios_base::openmode __mode = ios_base::in | ios_base::out)
- { return this->seekpos(__sp, __mode); }
- int
- pubsync() { return this->sync(); }
- streamsize
- in_avail()
- {
- const streamsize __ret = this->egptr() - this->gptr();
- return __ret ? __ret : this->showmanyc();
- }
- int_type
- snextc()
- {
- int_type __ret = traits_type::eof();
- if (__builtin_expect(!traits_type::eq_int_type(this->sbumpc(),
- __ret), true))
- __ret = this->sgetc();
- return __ret;
- }
- int_type
- sbumpc()
- {
- int_type __ret;
- if (__builtin_expect(this->gptr() < this->egptr(), true))
- {
- __ret = traits_type::to_int_type(*this->gptr());
- this->gbump(1);
- }
- else
- __ret = this->uflow();
- return __ret;
- }
- int_type
- sgetc()
- {
- int_type __ret;
- if (__builtin_expect(this->gptr() < this->egptr(), true))
- __ret = traits_type::to_int_type(*this->gptr());
- else
- __ret = this->underflow();
- return __ret;
- }
- streamsize
- sgetn(char_type* __s, streamsize __n)
- { return this->xsgetn(__s, __n); }
- int_type
- sputbackc(char_type __c)
- {
- int_type __ret;
- const bool __testpos = this->eback() < this->gptr();
- if (__builtin_expect(!__testpos ||
- !traits_type::eq(__c, this->gptr()[-1]), false))
- __ret = this->pbackfail(traits_type::to_int_type(__c));
- else
- {
- this->gbump(-1);
- __ret = traits_type::to_int_type(*this->gptr());
- }
- return __ret;
- }
- int_type
- sungetc()
- {
- int_type __ret;
- if (__builtin_expect(this->eback() < this->gptr(), true))
- {
- this->gbump(-1);
- __ret = traits_type::to_int_type(*this->gptr());
- }
- else
- __ret = this->pbackfail();
- return __ret;
- }
- int_type
- sputc(char_type __c)
- {
- int_type __ret;
- if (__builtin_expect(this->pptr() < this->epptr(), true))
- {
- *this->pptr() = __c;
- this->pbump(1);
- __ret = traits_type::to_int_type(__c);
- }
- else
- __ret = this->overflow(traits_type::to_int_type(__c));
- return __ret;
- }
- streamsize
- sputn(const char_type* __s, streamsize __n)
- { return this->xsputn(__s, __n); }
- protected:
- basic_streambuf()
- : _M_in_beg(0), _M_in_cur(0), _M_in_end(0),
- _M_out_beg(0), _M_out_cur(0), _M_out_end(0),
- _M_buf_locale(locale())
- { }
- char_type*
- eback() const { return _M_in_beg; }
- char_type*
- gptr() const { return _M_in_cur; }
- char_type*
- egptr() const { return _M_in_end; }
- void
- gbump(int __n) { _M_in_cur += __n; }
- void
- setg(char_type* __gbeg, char_type* __gnext, char_type* __gend)
- {
- _M_in_beg = __gbeg;
- _M_in_cur = __gnext;
- _M_in_end = __gend;
- }
- char_type*
- pbase() const { return _M_out_beg; }
- char_type*
- pptr() const { return _M_out_cur; }
- char_type*
- epptr() const { return _M_out_end; }
- void
- pbump(int __n) { _M_out_cur += __n; }
- void
- setp(char_type* __pbeg, char_type* __pend)
- {
- _M_out_beg = _M_out_cur = __pbeg;
- _M_out_end = __pend;
- }
- virtual void
- imbue(const locale&)
- { }
- virtual basic_streambuf<char_type,_Traits>*
- setbuf(char_type*, streamsize)
- { return this; }
- virtual pos_type
- seekoff(off_type, ios_base::seekdir,
- ios_base::openmode = ios_base::in | ios_base::out)
- { return pos_type(off_type(-1)); }
- virtual pos_type
- seekpos(pos_type,
- ios_base::openmode = ios_base::in | ios_base::out)
- { return pos_type(off_type(-1)); }
- virtual int
- sync() { return 0; }
- virtual streamsize
- showmanyc() { return 0; }
- virtual streamsize
- xsgetn(char_type* __s, streamsize __n);
- virtual int_type
- underflow()
- { return traits_type::eof(); }
- virtual int_type
- uflow()
- {
- int_type __ret = traits_type::eof();
- const bool __testeof = traits_type::eq_int_type(this->underflow(),
- __ret);
- if (!__testeof)
- {
- __ret = traits_type::to_int_type(*this->gptr());
- this->gbump(1);
- }
- return __ret;
- }
- virtual int_type
- pbackfail(int_type = traits_type::eof())
- { return traits_type::eof(); }
- virtual streamsize
- xsputn(const char_type* __s, streamsize __n);
- virtual int_type
- overflow(int_type = traits_type::eof())
- { return traits_type::eof(); }
- public:
- void
- stossc()
- {
- if (this->gptr() < this->egptr())
- this->gbump(1);
- else
- this->uflow();
- }
- void
- __safe_gbump(streamsize __n) { _M_in_cur += __n; }
- void
- __safe_pbump(streamsize __n) { _M_out_cur += __n; }
- private:
- basic_streambuf(const __streambuf_type& __sb)
- : _M_in_beg(__sb._M_in_beg), _M_in_cur(__sb._M_in_cur),
- _M_in_end(__sb._M_in_end), _M_out_beg(__sb._M_out_beg),
- _M_out_cur(__sb._M_out_cur), _M_out_end(__sb._M_out_cur),
- _M_buf_locale(__sb._M_buf_locale)
- { }
- __streambuf_type&
- operator=(const __streambuf_type&) { return *this; };
- };
- template<>
- streamsize
- __copy_streambufs_eof(basic_streambuf<char>* __sbin,
- basic_streambuf<char>* __sbout, bool& __ineof);
- template<>
- streamsize
- __copy_streambufs_eof(basic_streambuf<wchar_t>* __sbin,
- basic_streambuf<wchar_t>* __sbout, bool& __ineof);
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _CharT, typename _Traits>
- streamsize
- basic_streambuf<_CharT, _Traits>::
- xsgetn(char_type* __s, streamsize __n)
- {
- streamsize __ret = 0;
- while (__ret < __n)
- {
- const streamsize __buf_len = this->egptr() - this->gptr();
- if (__buf_len)
- {
- const streamsize __remaining = __n - __ret;
- const streamsize __len = std::min(__buf_len, __remaining);
- traits_type::copy(__s, this->gptr(), __len);
- __ret += __len;
- __s += __len;
- this->__safe_gbump(__len);
- }
- if (__ret < __n)
- {
- const int_type __c = this->uflow();
- if (!traits_type::eq_int_type(__c, traits_type::eof()))
- {
- traits_type::assign(*__s++, traits_type::to_char_type(__c));
- ++__ret;
- }
- else
- break;
- }
- }
- return __ret;
- }
- template<typename _CharT, typename _Traits>
- streamsize
- basic_streambuf<_CharT, _Traits>::
- xsputn(const char_type* __s, streamsize __n)
- {
- streamsize __ret = 0;
- while (__ret < __n)
- {
- const streamsize __buf_len = this->epptr() - this->pptr();
- if (__buf_len)
- {
- const streamsize __remaining = __n - __ret;
- const streamsize __len = std::min(__buf_len, __remaining);
- traits_type::copy(this->pptr(), __s, __len);
- __ret += __len;
- __s += __len;
- this->__safe_pbump(__len);
- }
- if (__ret < __n)
- {
- int_type __c = this->overflow(traits_type::to_int_type(*__s));
- if (!traits_type::eq_int_type(__c, traits_type::eof()))
- {
- ++__ret;
- ++__s;
- }
- else
- break;
- }
- }
- return __ret;
- }
- template<typename _CharT, typename _Traits>
- streamsize
- __copy_streambufs_eof(basic_streambuf<_CharT, _Traits>* __sbin,
- basic_streambuf<_CharT, _Traits>* __sbout,
- bool& __ineof)
- {
- streamsize __ret = 0;
- __ineof = true;
- typename _Traits::int_type __c = __sbin->sgetc();
- while (!_Traits::eq_int_type(__c, _Traits::eof()))
- {
- __c = __sbout->sputc(_Traits::to_char_type(__c));
- if (_Traits::eq_int_type(__c, _Traits::eof()))
- {
- __ineof = false;
- break;
- }
- ++__ret;
- __c = __sbin->snextc();
- }
- return __ret;
- }
- template<typename _CharT, typename _Traits>
- inline streamsize
- __copy_streambufs(basic_streambuf<_CharT, _Traits>* __sbin,
- basic_streambuf<_CharT, _Traits>* __sbout)
- {
- bool __ineof;
- return __copy_streambufs_eof(__sbin, __sbout, __ineof);
- }
- extern template class basic_streambuf<char>;
- extern template
- streamsize
- __copy_streambufs(basic_streambuf<char>*,
- basic_streambuf<char>*);
- extern template
- streamsize
- __copy_streambufs_eof(basic_streambuf<char>*,
- basic_streambuf<char>*, bool&);
- extern template class basic_streambuf<wchar_t>;
- extern template
- streamsize
- __copy_streambufs(basic_streambuf<wchar_t>*,
- basic_streambuf<wchar_t>*);
- extern template
- streamsize
- __copy_streambufs_eof(basic_streambuf<wchar_t>*,
- basic_streambuf<wchar_t>*, bool&);
-}
-typedef unsigned long int wctype_t;
-enum
-{
- __ISwupper = 0,
- __ISwlower = 1,
- __ISwalpha = 2,
- __ISwdigit = 3,
- __ISwxdigit = 4,
- __ISwspace = 5,
- __ISwprint = 6,
- __ISwgraph = 7,
- __ISwblank = 8,
- __ISwcntrl = 9,
- __ISwpunct = 10,
- __ISwalnum = 11,
- _ISwupper = ((__ISwupper) < 8 ? (int) ((1UL << (__ISwupper)) << 24) : ((__ISwupper) < 16 ? (int) ((1UL << (__ISwupper)) << 8) : ((__ISwupper) < 24 ? (int) ((1UL << (__ISwupper)) >> 8) : (int) ((1UL << (__ISwupper)) >> 24)))),
- _ISwlower = ((__ISwlower) < 8 ? (int) ((1UL << (__ISwlower)) << 24) : ((__ISwlower) < 16 ? (int) ((1UL << (__ISwlower)) << 8) : ((__ISwlower) < 24 ? (int) ((1UL << (__ISwlower)) >> 8) : (int) ((1UL << (__ISwlower)) >> 24)))),
- _ISwalpha = ((__ISwalpha) < 8 ? (int) ((1UL << (__ISwalpha)) << 24) : ((__ISwalpha) < 16 ? (int) ((1UL << (__ISwalpha)) << 8) : ((__ISwalpha) < 24 ? (int) ((1UL << (__ISwalpha)) >> 8) : (int) ((1UL << (__ISwalpha)) >> 24)))),
- _ISwdigit = ((__ISwdigit) < 8 ? (int) ((1UL << (__ISwdigit)) << 24) : ((__ISwdigit) < 16 ? (int) ((1UL << (__ISwdigit)) << 8) : ((__ISwdigit) < 24 ? (int) ((1UL << (__ISwdigit)) >> 8) : (int) ((1UL << (__ISwdigit)) >> 24)))),
- _ISwxdigit = ((__ISwxdigit) < 8 ? (int) ((1UL << (__ISwxdigit)) << 24) : ((__ISwxdigit) < 16 ? (int) ((1UL << (__ISwxdigit)) << 8) : ((__ISwxdigit) < 24 ? (int) ((1UL << (__ISwxdigit)) >> 8) : (int) ((1UL << (__ISwxdigit)) >> 24)))),
- _ISwspace = ((__ISwspace) < 8 ? (int) ((1UL << (__ISwspace)) << 24) : ((__ISwspace) < 16 ? (int) ((1UL << (__ISwspace)) << 8) : ((__ISwspace) < 24 ? (int) ((1UL << (__ISwspace)) >> 8) : (int) ((1UL << (__ISwspace)) >> 24)))),
- _ISwprint = ((__ISwprint) < 8 ? (int) ((1UL << (__ISwprint)) << 24) : ((__ISwprint) < 16 ? (int) ((1UL << (__ISwprint)) << 8) : ((__ISwprint) < 24 ? (int) ((1UL << (__ISwprint)) >> 8) : (int) ((1UL << (__ISwprint)) >> 24)))),
- _ISwgraph = ((__ISwgraph) < 8 ? (int) ((1UL << (__ISwgraph)) << 24) : ((__ISwgraph) < 16 ? (int) ((1UL << (__ISwgraph)) << 8) : ((__ISwgraph) < 24 ? (int) ((1UL << (__ISwgraph)) >> 8) : (int) ((1UL << (__ISwgraph)) >> 24)))),
- _ISwblank = ((__ISwblank) < 8 ? (int) ((1UL << (__ISwblank)) << 24) : ((__ISwblank) < 16 ? (int) ((1UL << (__ISwblank)) << 8) : ((__ISwblank) < 24 ? (int) ((1UL << (__ISwblank)) >> 8) : (int) ((1UL << (__ISwblank)) >> 24)))),
- _ISwcntrl = ((__ISwcntrl) < 8 ? (int) ((1UL << (__ISwcntrl)) << 24) : ((__ISwcntrl) < 16 ? (int) ((1UL << (__ISwcntrl)) << 8) : ((__ISwcntrl) < 24 ? (int) ((1UL << (__ISwcntrl)) >> 8) : (int) ((1UL << (__ISwcntrl)) >> 24)))),
- _ISwpunct = ((__ISwpunct) < 8 ? (int) ((1UL << (__ISwpunct)) << 24) : ((__ISwpunct) < 16 ? (int) ((1UL << (__ISwpunct)) << 8) : ((__ISwpunct) < 24 ? (int) ((1UL << (__ISwpunct)) >> 8) : (int) ((1UL << (__ISwpunct)) >> 24)))),
- _ISwalnum = ((__ISwalnum) < 8 ? (int) ((1UL << (__ISwalnum)) << 24) : ((__ISwalnum) < 16 ? (int) ((1UL << (__ISwalnum)) << 8) : ((__ISwalnum) < 24 ? (int) ((1UL << (__ISwalnum)) >> 8) : (int) ((1UL << (__ISwalnum)) >> 24))))
-};
-extern "C" {
-extern int iswalnum (wint_t __wc) throw ();
-extern int iswalpha (wint_t __wc) throw ();
-extern int iswcntrl (wint_t __wc) throw ();
-extern int iswdigit (wint_t __wc) throw ();
-extern int iswgraph (wint_t __wc) throw ();
-extern int iswlower (wint_t __wc) throw ();
-extern int iswprint (wint_t __wc) throw ();
-extern int iswpunct (wint_t __wc) throw ();
-extern int iswspace (wint_t __wc) throw ();
-extern int iswupper (wint_t __wc) throw ();
-extern int iswxdigit (wint_t __wc) throw ();
-extern int iswblank (wint_t __wc) throw ();
-extern wctype_t wctype (__const char *__property) throw ();
-extern int iswctype (wint_t __wc, wctype_t __desc) throw ();
-typedef __const __int32_t *wctrans_t;
-extern wint_t towlower (wint_t __wc) throw ();
-extern wint_t towupper (wint_t __wc) throw ();
-}
-extern "C" {
-extern wctrans_t wctrans (__const char *__property) throw ();
-extern wint_t towctrans (wint_t __wc, wctrans_t __desc) throw ();
-extern int iswalnum_l (wint_t __wc, __locale_t __locale) throw ();
-extern int iswalpha_l (wint_t __wc, __locale_t __locale) throw ();
-extern int iswcntrl_l (wint_t __wc, __locale_t __locale) throw ();
-extern int iswdigit_l (wint_t __wc, __locale_t __locale) throw ();
-extern int iswgraph_l (wint_t __wc, __locale_t __locale) throw ();
-extern int iswlower_l (wint_t __wc, __locale_t __locale) throw ();
-extern int iswprint_l (wint_t __wc, __locale_t __locale) throw ();
-extern int iswpunct_l (wint_t __wc, __locale_t __locale) throw ();
-extern int iswspace_l (wint_t __wc, __locale_t __locale) throw ();
-extern int iswupper_l (wint_t __wc, __locale_t __locale) throw ();
-extern int iswxdigit_l (wint_t __wc, __locale_t __locale) throw ();
-extern int iswblank_l (wint_t __wc, __locale_t __locale) throw ();
-extern wctype_t wctype_l (__const char *__property, __locale_t __locale)
- throw ();
-extern int iswctype_l (wint_t __wc, wctype_t __desc, __locale_t __locale)
- throw ();
-extern wint_t towlower_l (wint_t __wc, __locale_t __locale) throw ();
-extern wint_t towupper_l (wint_t __wc, __locale_t __locale) throw ();
-extern wctrans_t wctrans_l (__const char *__property, __locale_t __locale)
- throw ();
-extern wint_t towctrans_l (wint_t __wc, wctrans_t __desc,
- __locale_t __locale) throw ();
-}
-namespace std
-{
- using ::wctrans_t;
- using ::wctype_t;
- using ::wint_t;
- using ::iswalnum;
- using ::iswalpha;
- using ::iswblank;
- using ::iswcntrl;
- using ::iswctype;
- using ::iswdigit;
- using ::iswgraph;
- using ::iswlower;
- using ::iswprint;
- using ::iswpunct;
- using ::iswspace;
- using ::iswupper;
- using ::iswxdigit;
- using ::towctrans;
- using ::towlower;
- using ::towupper;
- using ::wctrans;
- using ::wctype;
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- struct ctype_base
- {
- typedef const int* __to_type;
- typedef unsigned short mask;
- static const mask upper = _ISupper;
- static const mask lower = _ISlower;
- static const mask alpha = _ISalpha;
- static const mask digit = _ISdigit;
- static const mask xdigit = _ISxdigit;
- static const mask space = _ISspace;
- static const mask print = _ISprint;
- static const mask graph = _ISalpha | _ISdigit | _ISpunct;
- static const mask cntrl = _IScntrl;
- static const mask punct = _ISpunct;
- static const mask alnum = _ISalpha | _ISdigit;
- };
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _CharT, typename _Traits>
- class istreambuf_iterator
- : public iterator<input_iterator_tag, _CharT, typename _Traits::off_type,
- _CharT*, _CharT&>
- {
- public:
- typedef _CharT char_type;
- typedef _Traits traits_type;
- typedef typename _Traits::int_type int_type;
- typedef basic_streambuf<_CharT, _Traits> streambuf_type;
- typedef basic_istream<_CharT, _Traits> istream_type;
- template<typename _CharT2>
- friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value,
- ostreambuf_iterator<_CharT2> >::__type
- copy(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>,
- ostreambuf_iterator<_CharT2>);
- template<bool _IsMove, typename _CharT2>
- friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value,
- _CharT2*>::__type
- __copy_move_a2(istreambuf_iterator<_CharT2>,
- istreambuf_iterator<_CharT2>, _CharT2*);
- template<typename _CharT2>
- friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value,
- istreambuf_iterator<_CharT2> >::__type
- find(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>,
- const _CharT2&);
- private:
- mutable streambuf_type* _M_sbuf;
- mutable int_type _M_c;
- public:
- istreambuf_iterator() throw()
- : _M_sbuf(0), _M_c(traits_type::eof()) { }
- istreambuf_iterator(istream_type& __s) throw()
- : _M_sbuf(__s.rdbuf()), _M_c(traits_type::eof()) { }
- istreambuf_iterator(streambuf_type* __s) throw()
- : _M_sbuf(__s), _M_c(traits_type::eof()) { }
- char_type
- operator*() const
- {
- return traits_type::to_char_type(_M_get());
- }
- istreambuf_iterator&
- operator++()
- {
- ;
- if (_M_sbuf)
- {
- _M_sbuf->sbumpc();
- _M_c = traits_type::eof();
- }
- return *this;
- }
- istreambuf_iterator
- operator++(int)
- {
- ;
- istreambuf_iterator __old = *this;
- if (_M_sbuf)
- {
- __old._M_c = _M_sbuf->sbumpc();
- _M_c = traits_type::eof();
- }
- return __old;
- }
- bool
- equal(const istreambuf_iterator& __b) const
- { return _M_at_eof() == __b._M_at_eof(); }
- private:
- int_type
- _M_get() const
- {
- const int_type __eof = traits_type::eof();
- int_type __ret = __eof;
- if (_M_sbuf)
- {
- if (!traits_type::eq_int_type(_M_c, __eof))
- __ret = _M_c;
- else if (!traits_type::eq_int_type((__ret = _M_sbuf->sgetc()),
- __eof))
- _M_c = __ret;
- else
- _M_sbuf = 0;
- }
- return __ret;
- }
- bool
- _M_at_eof() const
- {
- const int_type __eof = traits_type::eof();
- return traits_type::eq_int_type(_M_get(), __eof);
- }
- };
- template<typename _CharT, typename _Traits>
- inline bool
- operator==(const istreambuf_iterator<_CharT, _Traits>& __a,
- const istreambuf_iterator<_CharT, _Traits>& __b)
- { return __a.equal(__b); }
- template<typename _CharT, typename _Traits>
- inline bool
- operator!=(const istreambuf_iterator<_CharT, _Traits>& __a,
- const istreambuf_iterator<_CharT, _Traits>& __b)
- { return !__a.equal(__b); }
- template<typename _CharT, typename _Traits>
- class ostreambuf_iterator
- : public iterator<output_iterator_tag, void, void, void, void>
- {
- public:
- typedef _CharT char_type;
- typedef _Traits traits_type;
- typedef basic_streambuf<_CharT, _Traits> streambuf_type;
- typedef basic_ostream<_CharT, _Traits> ostream_type;
- template<typename _CharT2>
- friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value,
- ostreambuf_iterator<_CharT2> >::__type
- copy(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>,
- ostreambuf_iterator<_CharT2>);
- private:
- streambuf_type* _M_sbuf;
- bool _M_failed;
- public:
- ostreambuf_iterator(ostream_type& __s) throw ()
- : _M_sbuf(__s.rdbuf()), _M_failed(!_M_sbuf) { }
- ostreambuf_iterator(streambuf_type* __s) throw ()
- : _M_sbuf(__s), _M_failed(!_M_sbuf) { }
- ostreambuf_iterator&
- operator=(_CharT __c)
- {
- if (!_M_failed &&
- _Traits::eq_int_type(_M_sbuf->sputc(__c), _Traits::eof()))
- _M_failed = true;
- return *this;
- }
- ostreambuf_iterator&
- operator*()
- { return *this; }
- ostreambuf_iterator&
- operator++(int)
- { return *this; }
- ostreambuf_iterator&
- operator++()
- { return *this; }
- bool
- failed() const throw()
- { return _M_failed; }
- ostreambuf_iterator&
- _M_put(const _CharT* __ws, streamsize __len)
- {
- if (__builtin_expect(!_M_failed, true)
- && __builtin_expect(this->_M_sbuf->sputn(__ws, __len) != __len,
- false))
- _M_failed = true;
- return *this;
- }
- };
- template<typename _CharT>
- typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
- ostreambuf_iterator<_CharT> >::__type
- copy(istreambuf_iterator<_CharT> __first,
- istreambuf_iterator<_CharT> __last,
- ostreambuf_iterator<_CharT> __result)
- {
- if (__first._M_sbuf && !__last._M_sbuf && !__result._M_failed)
- {
- bool __ineof;
- __copy_streambufs_eof(__first._M_sbuf, __result._M_sbuf, __ineof);
- if (!__ineof)
- __result._M_failed = true;
- }
- return __result;
- }
- template<bool _IsMove, typename _CharT>
- typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
- ostreambuf_iterator<_CharT> >::__type
- __copy_move_a2(_CharT* __first, _CharT* __last,
- ostreambuf_iterator<_CharT> __result)
- {
- const streamsize __num = __last - __first;
- if (__num > 0)
- __result._M_put(__first, __num);
- return __result;
- }
- template<bool _IsMove, typename _CharT>
- typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
- ostreambuf_iterator<_CharT> >::__type
- __copy_move_a2(const _CharT* __first, const _CharT* __last,
- ostreambuf_iterator<_CharT> __result)
- {
- const streamsize __num = __last - __first;
- if (__num > 0)
- __result._M_put(__first, __num);
- return __result;
- }
- template<bool _IsMove, typename _CharT>
- typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
- _CharT*>::__type
- __copy_move_a2(istreambuf_iterator<_CharT> __first,
- istreambuf_iterator<_CharT> __last, _CharT* __result)
- {
- typedef istreambuf_iterator<_CharT> __is_iterator_type;
- typedef typename __is_iterator_type::traits_type traits_type;
- typedef typename __is_iterator_type::streambuf_type streambuf_type;
- typedef typename traits_type::int_type int_type;
- if (__first._M_sbuf && !__last._M_sbuf)
- {
- streambuf_type* __sb = __first._M_sbuf;
- int_type __c = __sb->sgetc();
- while (!traits_type::eq_int_type(__c, traits_type::eof()))
- {
- const streamsize __n = __sb->egptr() - __sb->gptr();
- if (__n > 1)
- {
- traits_type::copy(__result, __sb->gptr(), __n);
- __sb->__safe_gbump(__n);
- __result += __n;
- __c = __sb->underflow();
- }
- else
- {
- *__result++ = traits_type::to_char_type(__c);
- __c = __sb->snextc();
- }
- }
- }
- return __result;
- }
- template<typename _CharT>
- typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
- istreambuf_iterator<_CharT> >::__type
- find(istreambuf_iterator<_CharT> __first,
- istreambuf_iterator<_CharT> __last, const _CharT& __val)
- {
- typedef istreambuf_iterator<_CharT> __is_iterator_type;
- typedef typename __is_iterator_type::traits_type traits_type;
- typedef typename __is_iterator_type::streambuf_type streambuf_type;
- typedef typename traits_type::int_type int_type;
- if (__first._M_sbuf && !__last._M_sbuf)
- {
- const int_type __ival = traits_type::to_int_type(__val);
- streambuf_type* __sb = __first._M_sbuf;
- int_type __c = __sb->sgetc();
- while (!traits_type::eq_int_type(__c, traits_type::eof())
- && !traits_type::eq_int_type(__c, __ival))
- {
- streamsize __n = __sb->egptr() - __sb->gptr();
- if (__n > 1)
- {
- const _CharT* __p = traits_type::find(__sb->gptr(),
- __n, __val);
- if (__p)
- __n = __p - __sb->gptr();
- __sb->__safe_gbump(__n);
- __c = __sb->sgetc();
- }
- else
- __c = __sb->snextc();
- }
- if (!traits_type::eq_int_type(__c, traits_type::eof()))
- __first._M_c = __c;
- else
- __first._M_sbuf = 0;
- }
- return __first;
- }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _Tp>
- void
- __convert_to_v(const char*, _Tp&, ios_base::iostate&,
- const __c_locale&) throw();
- template<>
- void
- __convert_to_v(const char*, float&, ios_base::iostate&,
- const __c_locale&) throw();
- template<>
- void
- __convert_to_v(const char*, double&, ios_base::iostate&,
- const __c_locale&) throw();
- template<>
- void
- __convert_to_v(const char*, long double&, ios_base::iostate&,
- const __c_locale&) throw();
- template<typename _CharT, typename _Traits>
- struct __pad
- {
- static void
- _S_pad(ios_base& __io, _CharT __fill, _CharT* __news,
- const _CharT* __olds, streamsize __newlen, streamsize __oldlen);
- };
- template<typename _CharT>
- _CharT*
- __add_grouping(_CharT* __s, _CharT __sep,
- const char* __gbeg, size_t __gsize,
- const _CharT* __first, const _CharT* __last);
- template<typename _CharT>
- inline
- ostreambuf_iterator<_CharT>
- __write(ostreambuf_iterator<_CharT> __s, const _CharT* __ws, int __len)
- {
- __s._M_put(__ws, __len);
- return __s;
- }
- template<typename _CharT, typename _OutIter>
- inline
- _OutIter
- __write(_OutIter __s, const _CharT* __ws, int __len)
- {
- for (int __j = 0; __j < __len; __j++, ++__s)
- *__s = __ws[__j];
- return __s;
- }
- template<typename _CharT>
- class __ctype_abstract_base : public locale::facet, public ctype_base
- {
- public:
- typedef _CharT char_type;
- bool
- is(mask __m, char_type __c) const
- { return this->do_is(__m, __c); }
- const char_type*
- is(const char_type *__lo, const char_type *__hi, mask *__vec) const
- { return this->do_is(__lo, __hi, __vec); }
- const char_type*
- scan_is(mask __m, const char_type* __lo, const char_type* __hi) const
- { return this->do_scan_is(__m, __lo, __hi); }
- const char_type*
- scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
- { return this->do_scan_not(__m, __lo, __hi); }
- char_type
- toupper(char_type __c) const
- { return this->do_toupper(__c); }
- const char_type*
- toupper(char_type *__lo, const char_type* __hi) const
- { return this->do_toupper(__lo, __hi); }
- char_type
- tolower(char_type __c) const
- { return this->do_tolower(__c); }
- const char_type*
- tolower(char_type* __lo, const char_type* __hi) const
- { return this->do_tolower(__lo, __hi); }
- char_type
- widen(char __c) const
- { return this->do_widen(__c); }
- const char*
- widen(const char* __lo, const char* __hi, char_type* __to) const
- { return this->do_widen(__lo, __hi, __to); }
- char
- narrow(char_type __c, char __dfault) const
- { return this->do_narrow(__c, __dfault); }
- const char_type*
- narrow(const char_type* __lo, const char_type* __hi,
- char __dfault, char *__to) const
- { return this->do_narrow(__lo, __hi, __dfault, __to); }
- protected:
- explicit
- __ctype_abstract_base(size_t __refs = 0): facet(__refs) { }
- virtual
- ~__ctype_abstract_base() { }
- virtual bool
- do_is(mask __m, char_type __c) const = 0;
- virtual const char_type*
- do_is(const char_type* __lo, const char_type* __hi,
- mask* __vec) const = 0;
- virtual const char_type*
- do_scan_is(mask __m, const char_type* __lo,
- const char_type* __hi) const = 0;
- virtual const char_type*
- do_scan_not(mask __m, const char_type* __lo,
- const char_type* __hi) const = 0;
- virtual char_type
- do_toupper(char_type) const = 0;
- virtual const char_type*
- do_toupper(char_type* __lo, const char_type* __hi) const = 0;
- virtual char_type
- do_tolower(char_type) const = 0;
- virtual const char_type*
- do_tolower(char_type* __lo, const char_type* __hi) const = 0;
- virtual char_type
- do_widen(char) const = 0;
- virtual const char*
- do_widen(const char* __lo, const char* __hi,
- char_type* __dest) const = 0;
- virtual char
- do_narrow(char_type, char __dfault) const = 0;
- virtual const char_type*
- do_narrow(const char_type* __lo, const char_type* __hi,
- char __dfault, char* __dest) const = 0;
- };
- template<typename _CharT>
- class ctype : public __ctype_abstract_base<_CharT>
- {
- public:
- typedef _CharT char_type;
- typedef typename __ctype_abstract_base<_CharT>::mask mask;
- static locale::id id;
- explicit
- ctype(size_t __refs = 0) : __ctype_abstract_base<_CharT>(__refs) { }
- protected:
- virtual
- ~ctype();
- virtual bool
- do_is(mask __m, char_type __c) const;
- virtual const char_type*
- do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
- virtual const char_type*
- do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
- virtual const char_type*
- do_scan_not(mask __m, const char_type* __lo,
- const char_type* __hi) const;
- virtual char_type
- do_toupper(char_type __c) const;
- virtual const char_type*
- do_toupper(char_type* __lo, const char_type* __hi) const;
- virtual char_type
- do_tolower(char_type __c) const;
- virtual const char_type*
- do_tolower(char_type* __lo, const char_type* __hi) const;
- virtual char_type
- do_widen(char __c) const;
- virtual const char*
- do_widen(const char* __lo, const char* __hi, char_type* __dest) const;
- virtual char
- do_narrow(char_type, char __dfault) const;
- virtual const char_type*
- do_narrow(const char_type* __lo, const char_type* __hi,
- char __dfault, char* __dest) const;
- };
- template<typename _CharT>
- locale::id ctype<_CharT>::id;
- template<>
- class ctype<char> : public locale::facet, public ctype_base
- {
- public:
- typedef char char_type;
- protected:
- __c_locale _M_c_locale_ctype;
- bool _M_del;
- __to_type _M_toupper;
- __to_type _M_tolower;
- const mask* _M_table;
- mutable char _M_widen_ok;
- mutable char _M_widen[1 + static_cast<unsigned char>(-1)];
- mutable char _M_narrow[1 + static_cast<unsigned char>(-1)];
- mutable char _M_narrow_ok;
- public:
- static locale::id id;
- static const size_t table_size = 1 + static_cast<unsigned char>(-1);
- explicit
- ctype(const mask* __table = 0, bool __del = false, size_t __refs = 0);
- explicit
- ctype(__c_locale __cloc, const mask* __table = 0, bool __del = false,
- size_t __refs = 0);
- inline bool
- is(mask __m, char __c) const;
- inline const char*
- is(const char* __lo, const char* __hi, mask* __vec) const;
- inline const char*
- scan_is(mask __m, const char* __lo, const char* __hi) const;
- inline const char*
- scan_not(mask __m, const char* __lo, const char* __hi) const;
- char_type
- toupper(char_type __c) const
- { return this->do_toupper(__c); }
- const char_type*
- toupper(char_type *__lo, const char_type* __hi) const
- { return this->do_toupper(__lo, __hi); }
- char_type
- tolower(char_type __c) const
- { return this->do_tolower(__c); }
- const char_type*
- tolower(char_type* __lo, const char_type* __hi) const
- { return this->do_tolower(__lo, __hi); }
- char_type
- widen(char __c) const
- {
- if (_M_widen_ok)
- return _M_widen[static_cast<unsigned char>(__c)];
- this->_M_widen_init();
- return this->do_widen(__c);
- }
- const char*
- widen(const char* __lo, const char* __hi, char_type* __to) const
- {
- if (_M_widen_ok == 1)
- {
- __builtin_memcpy(__to, __lo, __hi - __lo);
- return __hi;
- }
- if (!_M_widen_ok)
- _M_widen_init();
- return this->do_widen(__lo, __hi, __to);
- }
- char
- narrow(char_type __c, char __dfault) const
- {
- if (_M_narrow[static_cast<unsigned char>(__c)])
- return _M_narrow[static_cast<unsigned char>(__c)];
- const char __t = do_narrow(__c, __dfault);
- if (__t != __dfault)
- _M_narrow[static_cast<unsigned char>(__c)] = __t;
- return __t;
- }
- const char_type*
- narrow(const char_type* __lo, const char_type* __hi,
- char __dfault, char *__to) const
- {
- if (__builtin_expect(_M_narrow_ok == 1, true))
- {
- __builtin_memcpy(__to, __lo, __hi - __lo);
- return __hi;
- }
- if (!_M_narrow_ok)
- _M_narrow_init();
- return this->do_narrow(__lo, __hi, __dfault, __to);
- }
- const mask*
- table() const throw()
- { return _M_table; }
- static const mask*
- classic_table() throw();
- protected:
- virtual
- ~ctype();
- virtual char_type
- do_toupper(char_type) const;
- virtual const char_type*
- do_toupper(char_type* __lo, const char_type* __hi) const;
- virtual char_type
- do_tolower(char_type) const;
- virtual const char_type*
- do_tolower(char_type* __lo, const char_type* __hi) const;
- virtual char_type
- do_widen(char __c) const
- { return __c; }
- virtual const char*
- do_widen(const char* __lo, const char* __hi, char_type* __dest) const
- {
- __builtin_memcpy(__dest, __lo, __hi - __lo);
- return __hi;
- }
- virtual char
- do_narrow(char_type __c, char) const
- { return __c; }
- virtual const char_type*
- do_narrow(const char_type* __lo, const char_type* __hi,
- char, char* __dest) const
- {
- __builtin_memcpy(__dest, __lo, __hi - __lo);
- return __hi;
- }
- private:
- void _M_narrow_init() const;
- void _M_widen_init() const;
- };
- template<>
- class ctype<wchar_t> : public __ctype_abstract_base<wchar_t>
- {
- public:
- typedef wchar_t char_type;
- typedef wctype_t __wmask_type;
- protected:
- __c_locale _M_c_locale_ctype;
- bool _M_narrow_ok;
- char _M_narrow[128];
- wint_t _M_widen[1 + static_cast<unsigned char>(-1)];
- mask _M_bit[16];
- __wmask_type _M_wmask[16];
- public:
- static locale::id id;
- explicit
- ctype(size_t __refs = 0);
- explicit
- ctype(__c_locale __cloc, size_t __refs = 0);
- protected:
- __wmask_type
- _M_convert_to_wmask(const mask __m) const throw();
- virtual
- ~ctype();
- virtual bool
- do_is(mask __m, char_type __c) const;
- virtual const char_type*
- do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
- virtual const char_type*
- do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
- virtual const char_type*
- do_scan_not(mask __m, const char_type* __lo,
- const char_type* __hi) const;
- virtual char_type
- do_toupper(char_type) const;
- virtual const char_type*
- do_toupper(char_type* __lo, const char_type* __hi) const;
- virtual char_type
- do_tolower(char_type) const;
- virtual const char_type*
- do_tolower(char_type* __lo, const char_type* __hi) const;
- virtual char_type
- do_widen(char) const;
- virtual const char*
- do_widen(const char* __lo, const char* __hi, char_type* __dest) const;
- virtual char
- do_narrow(char_type, char __dfault) const;
- virtual const char_type*
- do_narrow(const char_type* __lo, const char_type* __hi,
- char __dfault, char* __dest) const;
- void
- _M_initialize_ctype() throw();
- };
- template<typename _CharT>
- class ctype_byname : public ctype<_CharT>
- {
- public:
- typedef typename ctype<_CharT>::mask mask;
- explicit
- ctype_byname(const char* __s, size_t __refs = 0);
- protected:
- virtual
- ~ctype_byname() { };
- };
- template<>
- class ctype_byname<char> : public ctype<char>
- {
- public:
- explicit
- ctype_byname(const char* __s, size_t __refs = 0);
- protected:
- virtual
- ~ctype_byname();
- };
- template<>
- class ctype_byname<wchar_t> : public ctype<wchar_t>
- {
- public:
- explicit
- ctype_byname(const char* __s, size_t __refs = 0);
- protected:
- virtual
- ~ctype_byname();
- };
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- bool
- ctype<char>::
- is(mask __m, char __c) const
- { return _M_table[static_cast<unsigned char>(__c)] & __m; }
- const char*
- ctype<char>::
- is(const char* __low, const char* __high, mask* __vec) const
- {
- while (__low < __high)
- *__vec++ = _M_table[static_cast<unsigned char>(*__low++)];
- return __high;
- }
- const char*
- ctype<char>::
- scan_is(mask __m, const char* __low, const char* __high) const
- {
- while (__low < __high
- && !(_M_table[static_cast<unsigned char>(*__low)] & __m))
- ++__low;
- return __low;
- }
- const char*
- ctype<char>::
- scan_not(mask __m, const char* __low, const char* __high) const
- {
- while (__low < __high
- && (_M_table[static_cast<unsigned char>(*__low)] & __m) != 0)
- ++__low;
- return __low;
- }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- class __num_base
- {
- public:
- enum
- {
- _S_ominus,
- _S_oplus,
- _S_ox,
- _S_oX,
- _S_odigits,
- _S_odigits_end = _S_odigits + 16,
- _S_oudigits = _S_odigits_end,
- _S_oudigits_end = _S_oudigits + 16,
- _S_oe = _S_odigits + 14,
- _S_oE = _S_oudigits + 14,
- _S_oend = _S_oudigits_end
- };
- static const char* _S_atoms_out;
- static const char* _S_atoms_in;
- enum
- {
- _S_iminus,
- _S_iplus,
- _S_ix,
- _S_iX,
- _S_izero,
- _S_ie = _S_izero + 14,
- _S_iE = _S_izero + 20,
- _S_iend = 26
- };
- static void
- _S_format_float(const ios_base& __io, char* __fptr, char __mod) throw();
- };
- template<typename _CharT>
- struct __numpunct_cache : public locale::facet
- {
- const char* _M_grouping;
- size_t _M_grouping_size;
- bool _M_use_grouping;
- const _CharT* _M_truename;
- size_t _M_truename_size;
- const _CharT* _M_falsename;
- size_t _M_falsename_size;
- _CharT _M_decimal_point;
- _CharT _M_thousands_sep;
- _CharT _M_atoms_out[__num_base::_S_oend];
- _CharT _M_atoms_in[__num_base::_S_iend];
- bool _M_allocated;
- __numpunct_cache(size_t __refs = 0)
- : facet(__refs), _M_grouping(0), _M_grouping_size(0),
- _M_use_grouping(false),
- _M_truename(0), _M_truename_size(0), _M_falsename(0),
- _M_falsename_size(0), _M_decimal_point(_CharT()),
- _M_thousands_sep(_CharT()), _M_allocated(false)
- { }
- ~__numpunct_cache();
- void
- _M_cache(const locale& __loc);
- private:
- __numpunct_cache&
- operator=(const __numpunct_cache&);
- explicit
- __numpunct_cache(const __numpunct_cache&);
- };
- template<typename _CharT>
- __numpunct_cache<_CharT>::~__numpunct_cache()
- {
- if (_M_allocated)
- {
- delete [] _M_grouping;
- delete [] _M_truename;
- delete [] _M_falsename;
- }
- }
- template<typename _CharT>
- class numpunct : public locale::facet
- {
- public:
- typedef _CharT char_type;
- typedef basic_string<_CharT> string_type;
- typedef __numpunct_cache<_CharT> __cache_type;
- protected:
- __cache_type* _M_data;
- public:
- static locale::id id;
- explicit
- numpunct(size_t __refs = 0)
- : facet(__refs), _M_data(0)
- { _M_initialize_numpunct(); }
- explicit
- numpunct(__cache_type* __cache, size_t __refs = 0)
- : facet(__refs), _M_data(__cache)
- { _M_initialize_numpunct(); }
- explicit
- numpunct(__c_locale __cloc, size_t __refs = 0)
- : facet(__refs), _M_data(0)
- { _M_initialize_numpunct(__cloc); }
- char_type
- decimal_point() const
- { return this->do_decimal_point(); }
- char_type
- thousands_sep() const
- { return this->do_thousands_sep(); }
- string
- grouping() const
- { return this->do_grouping(); }
- string_type
- truename() const
- { return this->do_truename(); }
- string_type
- falsename() const
- { return this->do_falsename(); }
- protected:
- virtual
- ~numpunct();
- virtual char_type
- do_decimal_point() const
- { return _M_data->_M_decimal_point; }
- virtual char_type
- do_thousands_sep() const
- { return _M_data->_M_thousands_sep; }
- virtual string
- do_grouping() const
- { return _M_data->_M_grouping; }
- virtual string_type
- do_truename() const
- { return _M_data->_M_truename; }
- virtual string_type
- do_falsename() const
- { return _M_data->_M_falsename; }
- void
- _M_initialize_numpunct(__c_locale __cloc = 0);
- };
- template<typename _CharT>
- locale::id numpunct<_CharT>::id;
- template<>
- numpunct<char>::~numpunct();
- template<>
- void
- numpunct<char>::_M_initialize_numpunct(__c_locale __cloc);
- template<>
- numpunct<wchar_t>::~numpunct();
- template<>
- void
- numpunct<wchar_t>::_M_initialize_numpunct(__c_locale __cloc);
- template<typename _CharT>
- class numpunct_byname : public numpunct<_CharT>
- {
- public:
- typedef _CharT char_type;
- typedef basic_string<_CharT> string_type;
- explicit
- numpunct_byname(const char* __s, size_t __refs = 0)
- : numpunct<_CharT>(__refs)
- {
- if (__builtin_strcmp(__s, "C") != 0
- && __builtin_strcmp(__s, "POSIX") != 0)
- {
- __c_locale __tmp;
- this->_S_create_c_locale(__tmp, __s);
- this->_M_initialize_numpunct(__tmp);
- this->_S_destroy_c_locale(__tmp);
- }
- }
- protected:
- virtual
- ~numpunct_byname() { }
- };
- template<typename _CharT, typename _InIter>
- class num_get : public locale::facet
- {
- public:
- typedef _CharT char_type;
- typedef _InIter iter_type;
- static locale::id id;
- explicit
- num_get(size_t __refs = 0) : facet(__refs) { }
- iter_type
- get(iter_type __in, iter_type __end, ios_base& __io,
- ios_base::iostate& __err, bool& __v) const
- { return this->do_get(__in, __end, __io, __err, __v); }
- iter_type
- get(iter_type __in, iter_type __end, ios_base& __io,
- ios_base::iostate& __err, long& __v) const
- { return this->do_get(__in, __end, __io, __err, __v); }
- iter_type
- get(iter_type __in, iter_type __end, ios_base& __io,
- ios_base::iostate& __err, unsigned short& __v) const
- { return this->do_get(__in, __end, __io, __err, __v); }
- iter_type
- get(iter_type __in, iter_type __end, ios_base& __io,
- ios_base::iostate& __err, unsigned int& __v) const
- { return this->do_get(__in, __end, __io, __err, __v); }
- iter_type
- get(iter_type __in, iter_type __end, ios_base& __io,
- ios_base::iostate& __err, unsigned long& __v) const
- { return this->do_get(__in, __end, __io, __err, __v); }
- iter_type
- get(iter_type __in, iter_type __end, ios_base& __io,
- ios_base::iostate& __err, long long& __v) const
- { return this->do_get(__in, __end, __io, __err, __v); }
- iter_type
- get(iter_type __in, iter_type __end, ios_base& __io,
- ios_base::iostate& __err, unsigned long long& __v) const
- { return this->do_get(__in, __end, __io, __err, __v); }
- iter_type
- get(iter_type __in, iter_type __end, ios_base& __io,
- ios_base::iostate& __err, float& __v) const
- { return this->do_get(__in, __end, __io, __err, __v); }
- iter_type
- get(iter_type __in, iter_type __end, ios_base& __io,
- ios_base::iostate& __err, double& __v) const
- { return this->do_get(__in, __end, __io, __err, __v); }
- iter_type
- get(iter_type __in, iter_type __end, ios_base& __io,
- ios_base::iostate& __err, long double& __v) const
- { return this->do_get(__in, __end, __io, __err, __v); }
- iter_type
- get(iter_type __in, iter_type __end, ios_base& __io,
- ios_base::iostate& __err, void*& __v) const
- { return this->do_get(__in, __end, __io, __err, __v); }
- protected:
- virtual ~num_get() { }
- iter_type
- _M_extract_float(iter_type, iter_type, ios_base&, ios_base::iostate&,
- string&) const;
- template<typename _ValueT>
- iter_type
- _M_extract_int(iter_type, iter_type, ios_base&, ios_base::iostate&,
- _ValueT&) const;
- template<typename _CharT2>
- typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, int>::__type
- _M_find(const _CharT2*, size_t __len, _CharT2 __c) const
- {
- int __ret = -1;
- if (__len <= 10)
- {
- if (__c >= _CharT2('0') && __c < _CharT2(_CharT2('0') + __len))
- __ret = __c - _CharT2('0');
- }
- else
- {
- if (__c >= _CharT2('0') && __c <= _CharT2('9'))
- __ret = __c - _CharT2('0');
- else if (__c >= _CharT2('a') && __c <= _CharT2('f'))
- __ret = 10 + (__c - _CharT2('a'));
- else if (__c >= _CharT2('A') && __c <= _CharT2('F'))
- __ret = 10 + (__c - _CharT2('A'));
- }
- return __ret;
- }
- template<typename _CharT2>
- typename __gnu_cxx::__enable_if<!__is_char<_CharT2>::__value,
- int>::__type
- _M_find(const _CharT2* __zero, size_t __len, _CharT2 __c) const
- {
- int __ret = -1;
- const char_type* __q = char_traits<_CharT2>::find(__zero, __len, __c);
- if (__q)
- {
- __ret = __q - __zero;
- if (__ret > 15)
- __ret -= 6;
- }
- return __ret;
- }
- virtual iter_type
- do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const;
- virtual iter_type
- do_get(iter_type __beg, iter_type __end, ios_base& __io,
- ios_base::iostate& __err, long& __v) const
- { return _M_extract_int(__beg, __end, __io, __err, __v); }
- virtual iter_type
- do_get(iter_type __beg, iter_type __end, ios_base& __io,
- ios_base::iostate& __err, unsigned short& __v) const
- { return _M_extract_int(__beg, __end, __io, __err, __v); }
- virtual iter_type
- do_get(iter_type __beg, iter_type __end, ios_base& __io,
- ios_base::iostate& __err, unsigned int& __v) const
- { return _M_extract_int(__beg, __end, __io, __err, __v); }
- virtual iter_type
- do_get(iter_type __beg, iter_type __end, ios_base& __io,
- ios_base::iostate& __err, unsigned long& __v) const
- { return _M_extract_int(__beg, __end, __io, __err, __v); }
- virtual iter_type
- do_get(iter_type __beg, iter_type __end, ios_base& __io,
- ios_base::iostate& __err, long long& __v) const
- { return _M_extract_int(__beg, __end, __io, __err, __v); }
- virtual iter_type
- do_get(iter_type __beg, iter_type __end, ios_base& __io,
- ios_base::iostate& __err, unsigned long long& __v) const
- { return _M_extract_int(__beg, __end, __io, __err, __v); }
- virtual iter_type
- do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
- float&) const;
- virtual iter_type
- do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
- double&) const;
- virtual iter_type
- do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
- long double&) const;
- virtual iter_type
- do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
- void*&) const;
- };
- template<typename _CharT, typename _InIter>
- locale::id num_get<_CharT, _InIter>::id;
- template<typename _CharT, typename _OutIter>
- class num_put : public locale::facet
- {
- public:
- typedef _CharT char_type;
- typedef _OutIter iter_type;
- static locale::id id;
- explicit
- num_put(size_t __refs = 0) : facet(__refs) { }
- iter_type
- put(iter_type __s, ios_base& __f, char_type __fill, bool __v) const
- { return this->do_put(__s, __f, __fill, __v); }
- iter_type
- put(iter_type __s, ios_base& __f, char_type __fill, long __v) const
- { return this->do_put(__s, __f, __fill, __v); }
- iter_type
- put(iter_type __s, ios_base& __f, char_type __fill,
- unsigned long __v) const
- { return this->do_put(__s, __f, __fill, __v); }
- iter_type
- put(iter_type __s, ios_base& __f, char_type __fill, long long __v) const
- { return this->do_put(__s, __f, __fill, __v); }
- iter_type
- put(iter_type __s, ios_base& __f, char_type __fill,
- unsigned long long __v) const
- { return this->do_put(__s, __f, __fill, __v); }
- iter_type
- put(iter_type __s, ios_base& __f, char_type __fill, double __v) const
- { return this->do_put(__s, __f, __fill, __v); }
- iter_type
- put(iter_type __s, ios_base& __f, char_type __fill,
- long double __v) const
- { return this->do_put(__s, __f, __fill, __v); }
- iter_type
- put(iter_type __s, ios_base& __f, char_type __fill,
- const void* __v) const
- { return this->do_put(__s, __f, __fill, __v); }
- protected:
- template<typename _ValueT>
- iter_type
- _M_insert_float(iter_type, ios_base& __io, char_type __fill,
- char __mod, _ValueT __v) const;
- void
- _M_group_float(const char* __grouping, size_t __grouping_size,
- char_type __sep, const char_type* __p, char_type* __new,
- char_type* __cs, int& __len) const;
- template<typename _ValueT>
- iter_type
- _M_insert_int(iter_type, ios_base& __io, char_type __fill,
- _ValueT __v) const;
- void
- _M_group_int(const char* __grouping, size_t __grouping_size,
- char_type __sep, ios_base& __io, char_type* __new,
- char_type* __cs, int& __len) const;
- void
- _M_pad(char_type __fill, streamsize __w, ios_base& __io,
- char_type* __new, const char_type* __cs, int& __len) const;
- virtual
- ~num_put() { };
- virtual iter_type
- do_put(iter_type, ios_base&, char_type __fill, bool __v) const;
- virtual iter_type
- do_put(iter_type __s, ios_base& __io, char_type __fill, long __v) const
- { return _M_insert_int(__s, __io, __fill, __v); }
- virtual iter_type
- do_put(iter_type __s, ios_base& __io, char_type __fill,
- unsigned long __v) const
- { return _M_insert_int(__s, __io, __fill, __v); }
- virtual iter_type
- do_put(iter_type __s, ios_base& __io, char_type __fill,
- long long __v) const
- { return _M_insert_int(__s, __io, __fill, __v); }
- virtual iter_type
- do_put(iter_type __s, ios_base& __io, char_type __fill,
- unsigned long long __v) const
- { return _M_insert_int(__s, __io, __fill, __v); }
- virtual iter_type
- do_put(iter_type, ios_base&, char_type __fill, double __v) const;
- virtual iter_type
- do_put(iter_type, ios_base&, char_type __fill, long double __v) const;
- virtual iter_type
- do_put(iter_type, ios_base&, char_type __fill, const void* __v) const;
- };
- template <typename _CharT, typename _OutIter>
- locale::id num_put<_CharT, _OutIter>::id;
- template<typename _CharT>
- inline bool
- isspace(_CharT __c, const locale& __loc)
- { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c); }
- template<typename _CharT>
- inline bool
- isprint(_CharT __c, const locale& __loc)
- { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c); }
- template<typename _CharT>
- inline bool
- iscntrl(_CharT __c, const locale& __loc)
- { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c); }
- template<typename _CharT>
- inline bool
- isupper(_CharT __c, const locale& __loc)
- { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c); }
- template<typename _CharT>
- inline bool
- islower(_CharT __c, const locale& __loc)
- { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c); }
- template<typename _CharT>
- inline bool
- isalpha(_CharT __c, const locale& __loc)
- { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c); }
- template<typename _CharT>
- inline bool
- isdigit(_CharT __c, const locale& __loc)
- { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c); }
- template<typename _CharT>
- inline bool
- ispunct(_CharT __c, const locale& __loc)
- { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c); }
- template<typename _CharT>
- inline bool
- isxdigit(_CharT __c, const locale& __loc)
- { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c); }
- template<typename _CharT>
- inline bool
- isalnum(_CharT __c, const locale& __loc)
- { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c); }
- template<typename _CharT>
- inline bool
- isgraph(_CharT __c, const locale& __loc)
- { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c); }
- template<typename _CharT>
- inline _CharT
- toupper(_CharT __c, const locale& __loc)
- { return use_facet<ctype<_CharT> >(__loc).toupper(__c); }
- template<typename _CharT>
- inline _CharT
- tolower(_CharT __c, const locale& __loc)
- { return use_facet<ctype<_CharT> >(__loc).tolower(__c); }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _Facet>
- struct __use_cache
- {
- const _Facet*
- operator() (const locale& __loc) const;
- };
- template<typename _CharT>
- struct __use_cache<__numpunct_cache<_CharT> >
- {
- const __numpunct_cache<_CharT>*
- operator() (const locale& __loc) const
- {
- const size_t __i = numpunct<_CharT>::id._M_id();
- const locale::facet** __caches = __loc._M_impl->_M_caches;
- if (!__caches[__i])
- {
- __numpunct_cache<_CharT>* __tmp = 0;
- try
- {
- __tmp = new __numpunct_cache<_CharT>;
- __tmp->_M_cache(__loc);
- }
- catch(...)
- {
- delete __tmp;
- throw;
- }
- __loc._M_impl->_M_install_cache(__tmp, __i);
- }
- return static_cast<const __numpunct_cache<_CharT>*>(__caches[__i]);
- }
- };
- template<typename _CharT>
- void
- __numpunct_cache<_CharT>::_M_cache(const locale& __loc)
- {
- _M_allocated = true;
- const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
- char* __grouping = 0;
- _CharT* __truename = 0;
- _CharT* __falsename = 0;
- try
- {
- _M_grouping_size = __np.grouping().size();
- __grouping = new char[_M_grouping_size];
- __np.grouping().copy(__grouping, _M_grouping_size);
- _M_grouping = __grouping;
- _M_use_grouping = (_M_grouping_size
- && static_cast<signed char>(_M_grouping[0]) > 0
- && (_M_grouping[0]
- != __gnu_cxx::__numeric_traits<char>::__max));
- _M_truename_size = __np.truename().size();
- __truename = new _CharT[_M_truename_size];
- __np.truename().copy(__truename, _M_truename_size);
- _M_truename = __truename;
- _M_falsename_size = __np.falsename().size();
- __falsename = new _CharT[_M_falsename_size];
- __np.falsename().copy(__falsename, _M_falsename_size);
- _M_falsename = __falsename;
- _M_decimal_point = __np.decimal_point();
- _M_thousands_sep = __np.thousands_sep();
- const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc);
- __ct.widen(__num_base::_S_atoms_out,
- __num_base::_S_atoms_out
- + __num_base::_S_oend, _M_atoms_out);
- __ct.widen(__num_base::_S_atoms_in,
- __num_base::_S_atoms_in
- + __num_base::_S_iend, _M_atoms_in);
- }
- catch(...)
- {
- delete [] __grouping;
- delete [] __truename;
- delete [] __falsename;
- throw;
- }
- }
- __attribute__ ((__pure__)) bool
- __verify_grouping(const char* __grouping, size_t __grouping_size,
- const string& __grouping_tmp) throw ();
- template<typename _CharT, typename _InIter>
- _InIter
- num_get<_CharT, _InIter>::
- _M_extract_float(_InIter __beg, _InIter __end, ios_base& __io,
- ios_base::iostate& __err, string& __xtrc) const
- {
- typedef char_traits<_CharT> __traits_type;
- typedef __numpunct_cache<_CharT> __cache_type;
- __use_cache<__cache_type> __uc;
- const locale& __loc = __io._M_getloc();
- const __cache_type* __lc = __uc(__loc);
- const _CharT* __lit = __lc->_M_atoms_in;
- char_type __c = char_type();
- bool __testeof = __beg == __end;
- if (!__testeof)
- {
- __c = *__beg;
- const bool __plus = __c == __lit[__num_base::_S_iplus];
- if ((__plus || __c == __lit[__num_base::_S_iminus])
- && !(__lc->_M_use_grouping && __c == __lc->_M_thousands_sep)
- && !(__c == __lc->_M_decimal_point))
- {
- __xtrc += __plus ? '+' : '-';
- if (++__beg != __end)
- __c = *__beg;
- else
- __testeof = true;
- }
- }
- bool __found_mantissa = false;
- int __sep_pos = 0;
- while (!__testeof)
- {
- if ((__lc->_M_use_grouping && __c == __lc->_M_thousands_sep)
- || __c == __lc->_M_decimal_point)
- break;
- else if (__c == __lit[__num_base::_S_izero])
- {
- if (!__found_mantissa)
- {
- __xtrc += '0';
- __found_mantissa = true;
- }
- ++__sep_pos;
- if (++__beg != __end)
- __c = *__beg;
- else
- __testeof = true;
- }
- else
- break;
- }
- bool __found_dec = false;
- bool __found_sci = false;
- string __found_grouping;
- if (__lc->_M_use_grouping)
- __found_grouping.reserve(32);
- const char_type* __lit_zero = __lit + __num_base::_S_izero;
- if (!__lc->_M_allocated)
- while (!__testeof)
- {
- const int __digit = _M_find(__lit_zero, 10, __c);
- if (__digit != -1)
- {
- __xtrc += '0' + __digit;
- __found_mantissa = true;
- }
- else if (__c == __lc->_M_decimal_point
- && !__found_dec && !__found_sci)
- {
- __xtrc += '.';
- __found_dec = true;
- }
- else if ((__c == __lit[__num_base::_S_ie]
- || __c == __lit[__num_base::_S_iE])
- && !__found_sci && __found_mantissa)
- {
- __xtrc += 'e';
- __found_sci = true;
- if (++__beg != __end)
- {
- __c = *__beg;
- const bool __plus = __c == __lit[__num_base::_S_iplus];
- if (__plus || __c == __lit[__num_base::_S_iminus])
- __xtrc += __plus ? '+' : '-';
- else
- continue;
- }
- else
- {
- __testeof = true;
- break;
- }
- }
- else
- break;
- if (++__beg != __end)
- __c = *__beg;
- else
- __testeof = true;
- }
- else
- while (!__testeof)
- {
- if (__lc->_M_use_grouping && __c == __lc->_M_thousands_sep)
- {
- if (!__found_dec && !__found_sci)
- {
- if (__sep_pos)
- {
- __found_grouping += static_cast<char>(__sep_pos);
- __sep_pos = 0;
- }
- else
- {
- __xtrc.clear();
- break;
- }
- }
- else
- break;
- }
- else if (__c == __lc->_M_decimal_point)
- {
- if (!__found_dec && !__found_sci)
- {
- if (__found_grouping.size())
- __found_grouping += static_cast<char>(__sep_pos);
- __xtrc += '.';
- __found_dec = true;
- }
- else
- break;
- }
- else
- {
- const char_type* __q =
- __traits_type::find(__lit_zero, 10, __c);
- if (__q)
- {
- __xtrc += '0' + (__q - __lit_zero);
- __found_mantissa = true;
- ++__sep_pos;
- }
- else if ((__c == __lit[__num_base::_S_ie]
- || __c == __lit[__num_base::_S_iE])
- && !__found_sci && __found_mantissa)
- {
- if (__found_grouping.size() && !__found_dec)
- __found_grouping += static_cast<char>(__sep_pos);
- __xtrc += 'e';
- __found_sci = true;
- if (++__beg != __end)
- {
- __c = *__beg;
- const bool __plus = __c == __lit[__num_base::_S_iplus];
- if ((__plus || __c == __lit[__num_base::_S_iminus])
- && !(__lc->_M_use_grouping
- && __c == __lc->_M_thousands_sep)
- && !(__c == __lc->_M_decimal_point))
- __xtrc += __plus ? '+' : '-';
- else
- continue;
- }
- else
- {
- __testeof = true;
- break;
- }
- }
- else
- break;
- }
- if (++__beg != __end)
- __c = *__beg;
- else
- __testeof = true;
- }
- if (__found_grouping.size())
- {
- if (!__found_dec && !__found_sci)
- __found_grouping += static_cast<char>(__sep_pos);
- if (!std::__verify_grouping(__lc->_M_grouping,
- __lc->_M_grouping_size,
- __found_grouping))
- __err = ios_base::failbit;
- }
- return __beg;
- }
- template<typename _CharT, typename _InIter>
- template<typename _ValueT>
- _InIter
- num_get<_CharT, _InIter>::
- _M_extract_int(_InIter __beg, _InIter __end, ios_base& __io,
- ios_base::iostate& __err, _ValueT& __v) const
- {
- typedef char_traits<_CharT> __traits_type;
- using __gnu_cxx::__add_unsigned;
- typedef typename __add_unsigned<_ValueT>::__type __unsigned_type;
- typedef __numpunct_cache<_CharT> __cache_type;
- __use_cache<__cache_type> __uc;
- const locale& __loc = __io._M_getloc();
- const __cache_type* __lc = __uc(__loc);
- const _CharT* __lit = __lc->_M_atoms_in;
- char_type __c = char_type();
- const ios_base::fmtflags __basefield = __io.flags()
- & ios_base::basefield;
- const bool __oct = __basefield == ios_base::oct;
- int __base = __oct ? 8 : (__basefield == ios_base::hex ? 16 : 10);
- bool __testeof = __beg == __end;
- bool __negative = false;
- if (!__testeof)
- {
- __c = *__beg;
- __negative = __c == __lit[__num_base::_S_iminus];
- if ((__negative || __c == __lit[__num_base::_S_iplus])
- && !(__lc->_M_use_grouping && __c == __lc->_M_thousands_sep)
- && !(__c == __lc->_M_decimal_point))
- {
- if (++__beg != __end)
- __c = *__beg;
- else
- __testeof = true;
- }
- }
- bool __found_zero = false;
- int __sep_pos = 0;
- while (!__testeof)
- {
- if ((__lc->_M_use_grouping && __c == __lc->_M_thousands_sep)
- || __c == __lc->_M_decimal_point)
- break;
- else if (__c == __lit[__num_base::_S_izero]
- && (!__found_zero || __base == 10))
- {
- __found_zero = true;
- ++__sep_pos;
- if (__basefield == 0)
- __base = 8;
- if (__base == 8)
- __sep_pos = 0;
- }
- else if (__found_zero
- && (__c == __lit[__num_base::_S_ix]
- || __c == __lit[__num_base::_S_iX]))
- {
- if (__basefield == 0)
- __base = 16;
- if (__base == 16)
- {
- __found_zero = false;
- __sep_pos = 0;
- }
- else
- break;
- }
- else
- break;
- if (++__beg != __end)
- {
- __c = *__beg;
- if (!__found_zero)
- break;
- }
- else
- __testeof = true;
- }
- const size_t __len = (__base == 16 ? __num_base::_S_iend
- - __num_base::_S_izero : __base);
- string __found_grouping;
- if (__lc->_M_use_grouping)
- __found_grouping.reserve(32);
- bool __testfail = false;
- bool __testoverflow = false;
- const __unsigned_type __max =
- (__negative && __gnu_cxx::__numeric_traits<_ValueT>::__is_signed)
- ? -__gnu_cxx::__numeric_traits<_ValueT>::__min
- : __gnu_cxx::__numeric_traits<_ValueT>::__max;
- const __unsigned_type __smax = __max / __base;
- __unsigned_type __result = 0;
- int __digit = 0;
- const char_type* __lit_zero = __lit + __num_base::_S_izero;
- if (!__lc->_M_allocated)
- while (!__testeof)
- {
- __digit = _M_find(__lit_zero, __len, __c);
- if (__digit == -1)
- break;
- if (__result > __smax)
- __testoverflow = true;
- else
- {
- __result *= __base;
- __testoverflow |= __result > __max - __digit;
- __result += __digit;
- ++__sep_pos;
- }
- if (++__beg != __end)
- __c = *__beg;
- else
- __testeof = true;
- }
- else
- while (!__testeof)
- {
- if (__lc->_M_use_grouping && __c == __lc->_M_thousands_sep)
- {
- if (__sep_pos)
- {
- __found_grouping += static_cast<char>(__sep_pos);
- __sep_pos = 0;
- }
- else
- {
- __testfail = true;
- break;
- }
- }
- else if (__c == __lc->_M_decimal_point)
- break;
- else
- {
- const char_type* __q =
- __traits_type::find(__lit_zero, __len, __c);
- if (!__q)
- break;
- __digit = __q - __lit_zero;
- if (__digit > 15)
- __digit -= 6;
- if (__result > __smax)
- __testoverflow = true;
- else
- {
- __result *= __base;
- __testoverflow |= __result > __max - __digit;
- __result += __digit;
- ++__sep_pos;
- }
- }
- if (++__beg != __end)
- __c = *__beg;
- else
- __testeof = true;
- }
- if (__found_grouping.size())
- {
- __found_grouping += static_cast<char>(__sep_pos);
- if (!std::__verify_grouping(__lc->_M_grouping,
- __lc->_M_grouping_size,
- __found_grouping))
- __err = ios_base::failbit;
- }
- if ((!__sep_pos && !__found_zero && !__found_grouping.size())
- || __testfail)
- {
- __v = 0;
- __err = ios_base::failbit;
- }
- else if (__testoverflow)
- {
- if (__negative
- && __gnu_cxx::__numeric_traits<_ValueT>::__is_signed)
- __v = __gnu_cxx::__numeric_traits<_ValueT>::__min;
- else
- __v = __gnu_cxx::__numeric_traits<_ValueT>::__max;
- __err = ios_base::failbit;
- }
- else
- __v = __negative ? -__result : __result;
- if (__testeof)
- __err |= ios_base::eofbit;
- return __beg;
- }
- template<typename _CharT, typename _InIter>
- _InIter
- num_get<_CharT, _InIter>::
- do_get(iter_type __beg, iter_type __end, ios_base& __io,
- ios_base::iostate& __err, bool& __v) const
- {
- if (!(__io.flags() & ios_base::boolalpha))
- {
- long __l = -1;
- __beg = _M_extract_int(__beg, __end, __io, __err, __l);
- if (__l == 0 || __l == 1)
- __v = bool(__l);
- else
- {
- __v = true;
- __err = ios_base::failbit;
- if (__beg == __end)
- __err |= ios_base::eofbit;
- }
- }
- else
- {
- typedef __numpunct_cache<_CharT> __cache_type;
- __use_cache<__cache_type> __uc;
- const locale& __loc = __io._M_getloc();
- const __cache_type* __lc = __uc(__loc);
- bool __testf = true;
- bool __testt = true;
- bool __donef = __lc->_M_falsename_size == 0;
- bool __donet = __lc->_M_truename_size == 0;
- bool __testeof = false;
- size_t __n = 0;
- while (!__donef || !__donet)
- {
- if (__beg == __end)
- {
- __testeof = true;
- break;
- }
- const char_type __c = *__beg;
- if (!__donef)
- __testf = __c == __lc->_M_falsename[__n];
- if (!__testf && __donet)
- break;
- if (!__donet)
- __testt = __c == __lc->_M_truename[__n];
- if (!__testt && __donef)
- break;
- if (!__testt && !__testf)
- break;
- ++__n;
- ++__beg;
- __donef = !__testf || __n >= __lc->_M_falsename_size;
- __donet = !__testt || __n >= __lc->_M_truename_size;
- }
- if (__testf && __n == __lc->_M_falsename_size && __n)
- {
- __v = false;
- if (__testt && __n == __lc->_M_truename_size)
- __err = ios_base::failbit;
- else
- __err = __testeof ? ios_base::eofbit : ios_base::goodbit;
- }
- else if (__testt && __n == __lc->_M_truename_size && __n)
- {
- __v = true;
- __err = __testeof ? ios_base::eofbit : ios_base::goodbit;
- }
- else
- {
- __v = false;
- __err = ios_base::failbit;
- if (__testeof)
- __err |= ios_base::eofbit;
- }
- }
- return __beg;
- }
- template<typename _CharT, typename _InIter>
- _InIter
- num_get<_CharT, _InIter>::
- do_get(iter_type __beg, iter_type __end, ios_base& __io,
- ios_base::iostate& __err, float& __v) const
- {
- string __xtrc;
- __xtrc.reserve(32);
- __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
- std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
- if (__beg == __end)
- __err |= ios_base::eofbit;
- return __beg;
- }
- template<typename _CharT, typename _InIter>
- _InIter
- num_get<_CharT, _InIter>::
- do_get(iter_type __beg, iter_type __end, ios_base& __io,
- ios_base::iostate& __err, double& __v) const
- {
- string __xtrc;
- __xtrc.reserve(32);
- __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
- std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
- if (__beg == __end)
- __err |= ios_base::eofbit;
- return __beg;
- }
- template<typename _CharT, typename _InIter>
- _InIter
- num_get<_CharT, _InIter>::
- do_get(iter_type __beg, iter_type __end, ios_base& __io,
- ios_base::iostate& __err, long double& __v) const
- {
- string __xtrc;
- __xtrc.reserve(32);
- __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
- std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
- if (__beg == __end)
- __err |= ios_base::eofbit;
- return __beg;
- }
- template<typename _CharT, typename _InIter>
- _InIter
- num_get<_CharT, _InIter>::
- do_get(iter_type __beg, iter_type __end, ios_base& __io,
- ios_base::iostate& __err, void*& __v) const
- {
- typedef ios_base::fmtflags fmtflags;
- const fmtflags __fmt = __io.flags();
- __io.flags((__fmt & ~ios_base::basefield) | ios_base::hex);
- typedef __gnu_cxx::__conditional_type<(sizeof(void*)
- <= sizeof(unsigned long)),
- unsigned long, unsigned long long>::__type _UIntPtrType;
- _UIntPtrType __ul;
- __beg = _M_extract_int(__beg, __end, __io, __err, __ul);
- __io.flags(__fmt);
- __v = reinterpret_cast<void*>(__ul);
- return __beg;
- }
- template<typename _CharT, typename _OutIter>
- void
- num_put<_CharT, _OutIter>::
- _M_pad(_CharT __fill, streamsize __w, ios_base& __io,
- _CharT* __new, const _CharT* __cs, int& __len) const
- {
- __pad<_CharT, char_traits<_CharT> >::_S_pad(__io, __fill, __new,
- __cs, __w, __len);
- __len = static_cast<int>(__w);
- }
- template<typename _CharT, typename _ValueT>
- int
- __int_to_char(_CharT* __bufend, _ValueT __v, const _CharT* __lit,
- ios_base::fmtflags __flags, bool __dec)
- {
- _CharT* __buf = __bufend;
- if (__builtin_expect(__dec, true))
- {
- do
- {
- *--__buf = __lit[(__v % 10) + __num_base::_S_odigits];
- __v /= 10;
- }
- while (__v != 0);
- }
- else if ((__flags & ios_base::basefield) == ios_base::oct)
- {
- do
- {
- *--__buf = __lit[(__v & 0x7) + __num_base::_S_odigits];
- __v >>= 3;
- }
- while (__v != 0);
- }
- else
- {
- const bool __uppercase = __flags & ios_base::uppercase;
- const int __case_offset = __uppercase ? __num_base::_S_oudigits
- : __num_base::_S_odigits;
- do
- {
- *--__buf = __lit[(__v & 0xf) + __case_offset];
- __v >>= 4;
- }
- while (__v != 0);
- }
- return __bufend - __buf;
- }
- template<typename _CharT, typename _OutIter>
- void
- num_put<_CharT, _OutIter>::
- _M_group_int(const char* __grouping, size_t __grouping_size, _CharT __sep,
- ios_base&, _CharT* __new, _CharT* __cs, int& __len) const
- {
- _CharT* __p = std::__add_grouping(__new, __sep, __grouping,
- __grouping_size, __cs, __cs + __len);
- __len = __p - __new;
- }
- template<typename _CharT, typename _OutIter>
- template<typename _ValueT>
- _OutIter
- num_put<_CharT, _OutIter>::
- _M_insert_int(_OutIter __s, ios_base& __io, _CharT __fill,
- _ValueT __v) const
- {
- using __gnu_cxx::__add_unsigned;
- typedef typename __add_unsigned<_ValueT>::__type __unsigned_type;
- typedef __numpunct_cache<_CharT> __cache_type;
- __use_cache<__cache_type> __uc;
- const locale& __loc = __io._M_getloc();
- const __cache_type* __lc = __uc(__loc);
- const _CharT* __lit = __lc->_M_atoms_out;
- const ios_base::fmtflags __flags = __io.flags();
- const int __ilen = 5 * sizeof(_ValueT);
- _CharT* __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
- * __ilen));
- const ios_base::fmtflags __basefield = __flags & ios_base::basefield;
- const bool __dec = (__basefield != ios_base::oct
- && __basefield != ios_base::hex);
- const __unsigned_type __u = ((__v > 0 || !__dec)
- ? __unsigned_type(__v)
- : -__unsigned_type(__v));
- int __len = __int_to_char(__cs + __ilen, __u, __lit, __flags, __dec);
- __cs += __ilen - __len;
- if (__lc->_M_use_grouping)
- {
- _CharT* __cs2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
- * (__len + 1)
- * 2));
- _M_group_int(__lc->_M_grouping, __lc->_M_grouping_size,
- __lc->_M_thousands_sep, __io, __cs2 + 2, __cs, __len);
- __cs = __cs2 + 2;
- }
- if (__builtin_expect(__dec, true))
- {
- if (__v >= 0)
- {
- if (bool(__flags & ios_base::showpos)
- && __gnu_cxx::__numeric_traits<_ValueT>::__is_signed)
- *--__cs = __lit[__num_base::_S_oplus], ++__len;
- }
- else
- *--__cs = __lit[__num_base::_S_ominus], ++__len;
- }
- else if (bool(__flags & ios_base::showbase) && __v)
- {
- if (__basefield == ios_base::oct)
- *--__cs = __lit[__num_base::_S_odigits], ++__len;
- else
- {
- const bool __uppercase = __flags & ios_base::uppercase;
- *--__cs = __lit[__num_base::_S_ox + __uppercase];
- *--__cs = __lit[__num_base::_S_odigits];
- __len += 2;
- }
- }
- const streamsize __w = __io.width();
- if (__w > static_cast<streamsize>(__len))
- {
- _CharT* __cs3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
- * __w));
- _M_pad(__fill, __w, __io, __cs3, __cs, __len);
- __cs = __cs3;
- }
- __io.width(0);
- return std::__write(__s, __cs, __len);
- }
- template<typename _CharT, typename _OutIter>
- void
- num_put<_CharT, _OutIter>::
- _M_group_float(const char* __grouping, size_t __grouping_size,
- _CharT __sep, const _CharT* __p, _CharT* __new,
- _CharT* __cs, int& __len) const
- {
- const int __declen = __p ? __p - __cs : __len;
- _CharT* __p2 = std::__add_grouping(__new, __sep, __grouping,
- __grouping_size,
- __cs, __cs + __declen);
- int __newlen = __p2 - __new;
- if (__p)
- {
- char_traits<_CharT>::copy(__p2, __p, __len - __declen);
- __newlen += __len - __declen;
- }
- __len = __newlen;
- }
- template<typename _CharT, typename _OutIter>
- template<typename _ValueT>
- _OutIter
- num_put<_CharT, _OutIter>::
- _M_insert_float(_OutIter __s, ios_base& __io, _CharT __fill, char __mod,
- _ValueT __v) const
- {
- typedef __numpunct_cache<_CharT> __cache_type;
- __use_cache<__cache_type> __uc;
- const locale& __loc = __io._M_getloc();
- const __cache_type* __lc = __uc(__loc);
- const streamsize __prec = __io.precision() < 0 ? 6 : __io.precision();
- const int __max_digits =
- __gnu_cxx::__numeric_traits<_ValueT>::__digits10;
- int __len;
- char __fbuf[16];
- __num_base::_S_format_float(__io, __fbuf, __mod);
- int __cs_size = __max_digits * 3;
- char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
- __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size,
- __fbuf, __prec, __v);
- if (__len >= __cs_size)
- {
- __cs_size = __len + 1;
- __cs = static_cast<char*>(__builtin_alloca(__cs_size));
- __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size,
- __fbuf, __prec, __v);
- }
- const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
- _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
- * __len));
- __ctype.widen(__cs, __cs + __len, __ws);
- _CharT* __wp = 0;
- const char* __p = char_traits<char>::find(__cs, __len, '.');
- if (__p)
- {
- __wp = __ws + (__p - __cs);
- *__wp = __lc->_M_decimal_point;
- }
- if (__lc->_M_use_grouping
- && (__wp || __len < 3 || (__cs[1] <= '9' && __cs[2] <= '9'
- && __cs[1] >= '0' && __cs[2] >= '0')))
- {
- _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
- * __len * 2));
- streamsize __off = 0;
- if (__cs[0] == '-' || __cs[0] == '+')
- {
- __off = 1;
- __ws2[0] = __ws[0];
- __len -= 1;
- }
- _M_group_float(__lc->_M_grouping, __lc->_M_grouping_size,
- __lc->_M_thousands_sep, __wp, __ws2 + __off,
- __ws + __off, __len);
- __len += __off;
- __ws = __ws2;
- }
- const streamsize __w = __io.width();
- if (__w > static_cast<streamsize>(__len))
- {
- _CharT* __ws3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
- * __w));
- _M_pad(__fill, __w, __io, __ws3, __ws, __len);
- __ws = __ws3;
- }
- __io.width(0);
- return std::__write(__s, __ws, __len);
- }
- template<typename _CharT, typename _OutIter>
- _OutIter
- num_put<_CharT, _OutIter>::
- do_put(iter_type __s, ios_base& __io, char_type __fill, bool __v) const
- {
- const ios_base::fmtflags __flags = __io.flags();
- if ((__flags & ios_base::boolalpha) == 0)
- {
- const long __l = __v;
- __s = _M_insert_int(__s, __io, __fill, __l);
- }
- else
- {
- typedef __numpunct_cache<_CharT> __cache_type;
- __use_cache<__cache_type> __uc;
- const locale& __loc = __io._M_getloc();
- const __cache_type* __lc = __uc(__loc);
- const _CharT* __name = __v ? __lc->_M_truename
- : __lc->_M_falsename;
- int __len = __v ? __lc->_M_truename_size
- : __lc->_M_falsename_size;
- const streamsize __w = __io.width();
- if (__w > static_cast<streamsize>(__len))
- {
- const streamsize __plen = __w - __len;
- _CharT* __ps
- = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
- * __plen));
- char_traits<_CharT>::assign(__ps, __plen, __fill);
- __io.width(0);
- if ((__flags & ios_base::adjustfield) == ios_base::left)
- {
- __s = std::__write(__s, __name, __len);
- __s = std::__write(__s, __ps, __plen);
- }
- else
- {
- __s = std::__write(__s, __ps, __plen);
- __s = std::__write(__s, __name, __len);
- }
- return __s;
- }
- __io.width(0);
- __s = std::__write(__s, __name, __len);
- }
- return __s;
- }
- template<typename _CharT, typename _OutIter>
- _OutIter
- num_put<_CharT, _OutIter>::
- do_put(iter_type __s, ios_base& __io, char_type __fill, double __v) const
- { return _M_insert_float(__s, __io, __fill, char(), __v); }
- template<typename _CharT, typename _OutIter>
- _OutIter
- num_put<_CharT, _OutIter>::
- do_put(iter_type __s, ios_base& __io, char_type __fill,
- long double __v) const
- { return _M_insert_float(__s, __io, __fill, 'L', __v); }
- template<typename _CharT, typename _OutIter>
- _OutIter
- num_put<_CharT, _OutIter>::
- do_put(iter_type __s, ios_base& __io, char_type __fill,
- const void* __v) const
- {
- const ios_base::fmtflags __flags = __io.flags();
- const ios_base::fmtflags __fmt = ~(ios_base::basefield
- | ios_base::uppercase);
- __io.flags((__flags & __fmt) | (ios_base::hex | ios_base::showbase));
- typedef __gnu_cxx::__conditional_type<(sizeof(const void*)
- <= sizeof(unsigned long)),
- unsigned long, unsigned long long>::__type _UIntPtrType;
- __s = _M_insert_int(__s, __io, __fill,
- reinterpret_cast<_UIntPtrType>(__v));
- __io.flags(__flags);
- return __s;
- }
- template<typename _CharT, typename _Traits>
- void
- __pad<_CharT, _Traits>::_S_pad(ios_base& __io, _CharT __fill,
- _CharT* __news, const _CharT* __olds,
- streamsize __newlen, streamsize __oldlen)
- {
- const size_t __plen = static_cast<size_t>(__newlen - __oldlen);
- const ios_base::fmtflags __adjust = __io.flags() & ios_base::adjustfield;
- if (__adjust == ios_base::left)
- {
- _Traits::copy(__news, __olds, __oldlen);
- _Traits::assign(__news + __oldlen, __plen, __fill);
- return;
- }
- size_t __mod = 0;
- if (__adjust == ios_base::internal)
- {
- const locale& __loc = __io._M_getloc();
- const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
- if (__ctype.widen('-') == __olds[0]
- || __ctype.widen('+') == __olds[0])
- {
- __news[0] = __olds[0];
- __mod = 1;
- ++__news;
- }
- else if (__ctype.widen('0') == __olds[0]
- && __oldlen > 1
- && (__ctype.widen('x') == __olds[1]
- || __ctype.widen('X') == __olds[1]))
- {
- __news[0] = __olds[0];
- __news[1] = __olds[1];
- __mod = 2;
- __news += 2;
- }
- }
- _Traits::assign(__news, __plen, __fill);
- _Traits::copy(__news + __plen, __olds + __mod, __oldlen - __mod);
- }
- template<typename _CharT>
- _CharT*
- __add_grouping(_CharT* __s, _CharT __sep,
- const char* __gbeg, size_t __gsize,
- const _CharT* __first, const _CharT* __last)
- {
- size_t __idx = 0;
- size_t __ctr = 0;
- while (__last - __first > __gbeg[__idx]
- && static_cast<signed char>(__gbeg[__idx]) > 0
- && __gbeg[__idx] != __gnu_cxx::__numeric_traits<char>::__max)
- {
- __last -= __gbeg[__idx];
- __idx < __gsize - 1 ? ++__idx : ++__ctr;
- }
- while (__first != __last)
- *__s++ = *__first++;
- while (__ctr--)
- {
- *__s++ = __sep;
- for (char __i = __gbeg[__idx]; __i > 0; --__i)
- *__s++ = *__first++;
- }
- while (__idx--)
- {
- *__s++ = __sep;
- for (char __i = __gbeg[__idx]; __i > 0; --__i)
- *__s++ = *__first++;
- }
- return __s;
- }
- extern template class numpunct<char>;
- extern template class numpunct_byname<char>;
- extern template class num_get<char>;
- extern template class num_put<char>;
- extern template class ctype_byname<char>;
- extern template
- const ctype<char>&
- use_facet<ctype<char> >(const locale&);
- extern template
- const numpunct<char>&
- use_facet<numpunct<char> >(const locale&);
- extern template
- const num_put<char>&
- use_facet<num_put<char> >(const locale&);
- extern template
- const num_get<char>&
- use_facet<num_get<char> >(const locale&);
- extern template
- bool
- has_facet<ctype<char> >(const locale&);
- extern template
- bool
- has_facet<numpunct<char> >(const locale&);
- extern template
- bool
- has_facet<num_put<char> >(const locale&);
- extern template
- bool
- has_facet<num_get<char> >(const locale&);
- extern template class numpunct<wchar_t>;
- extern template class numpunct_byname<wchar_t>;
- extern template class num_get<wchar_t>;
- extern template class num_put<wchar_t>;
- extern template class ctype_byname<wchar_t>;
- extern template
- const ctype<wchar_t>&
- use_facet<ctype<wchar_t> >(const locale&);
- extern template
- const numpunct<wchar_t>&
- use_facet<numpunct<wchar_t> >(const locale&);
- extern template
- const num_put<wchar_t>&
- use_facet<num_put<wchar_t> >(const locale&);
- extern template
- const num_get<wchar_t>&
- use_facet<num_get<wchar_t> >(const locale&);
- extern template
- bool
- has_facet<ctype<wchar_t> >(const locale&);
- extern template
- bool
- has_facet<numpunct<wchar_t> >(const locale&);
- extern template
- bool
- has_facet<num_put<wchar_t> >(const locale&);
- extern template
- bool
- has_facet<num_get<wchar_t> >(const locale&);
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _Facet>
- inline const _Facet&
- __check_facet(const _Facet* __f)
- {
- if (!__f)
- __throw_bad_cast();
- return *__f;
- }
- template<typename _CharT, typename _Traits>
- class basic_ios : public ios_base
- {
- public:
- typedef _CharT char_type;
- typedef typename _Traits::int_type int_type;
- typedef typename _Traits::pos_type pos_type;
- typedef typename _Traits::off_type off_type;
- typedef _Traits traits_type;
- typedef ctype<_CharT> __ctype_type;
- typedef num_put<_CharT, ostreambuf_iterator<_CharT, _Traits> >
- __num_put_type;
- typedef num_get<_CharT, istreambuf_iterator<_CharT, _Traits> >
- __num_get_type;
- protected:
- basic_ostream<_CharT, _Traits>* _M_tie;
- mutable char_type _M_fill;
- mutable bool _M_fill_init;
- basic_streambuf<_CharT, _Traits>* _M_streambuf;
- const __ctype_type* _M_ctype;
- const __num_put_type* _M_num_put;
- const __num_get_type* _M_num_get;
- public:
- operator void*() const
- { return this->fail() ? 0 : const_cast<basic_ios*>(this); }
- bool
- operator!() const
- { return this->fail(); }
- iostate
- rdstate() const
- { return _M_streambuf_state; }
- void
- clear(iostate __state = goodbit);
- void
- setstate(iostate __state)
- { this->clear(this->rdstate() | __state); }
- void
- _M_setstate(iostate __state)
- {
- _M_streambuf_state |= __state;
- if (this->exceptions() & __state)
- throw;
- }
- bool
- good() const
- { return this->rdstate() == 0; }
- bool
- eof() const
- { return (this->rdstate() & eofbit) != 0; }
- bool
- fail() const
- { return (this->rdstate() & (badbit | failbit)) != 0; }
- bool
- bad() const
- { return (this->rdstate() & badbit) != 0; }
- iostate
- exceptions() const
- { return _M_exception; }
- void
- exceptions(iostate __except)
- {
- _M_exception = __except;
- this->clear(_M_streambuf_state);
- }
- explicit
- basic_ios(basic_streambuf<_CharT, _Traits>* __sb)
- : ios_base(), _M_tie(0), _M_fill(), _M_fill_init(false), _M_streambuf(0),
- _M_ctype(0), _M_num_put(0), _M_num_get(0)
- { this->init(__sb); }
- virtual
- ~basic_ios() { }
- basic_ostream<_CharT, _Traits>*
- tie() const
- { return _M_tie; }
- basic_ostream<_CharT, _Traits>*
- tie(basic_ostream<_CharT, _Traits>* __tiestr)
- {
- basic_ostream<_CharT, _Traits>* __old = _M_tie;
- _M_tie = __tiestr;
- return __old;
- }
- basic_streambuf<_CharT, _Traits>*
- rdbuf() const
- { return _M_streambuf; }
- basic_streambuf<_CharT, _Traits>*
- rdbuf(basic_streambuf<_CharT, _Traits>* __sb);
- basic_ios&
- copyfmt(const basic_ios& __rhs);
- char_type
- fill() const
- {
- if (!_M_fill_init)
- {
- _M_fill = this->widen(' ');
- _M_fill_init = true;
- }
- return _M_fill;
- }
- char_type
- fill(char_type __ch)
- {
- char_type __old = this->fill();
- _M_fill = __ch;
- return __old;
- }
- locale
- imbue(const locale& __loc);
- char
- narrow(char_type __c, char __dfault) const
- { return __check_facet(_M_ctype).narrow(__c, __dfault); }
- char_type
- widen(char __c) const
- { return __check_facet(_M_ctype).widen(__c); }
- protected:
- basic_ios()
- : ios_base(), _M_tie(0), _M_fill(char_type()), _M_fill_init(false),
- _M_streambuf(0), _M_ctype(0), _M_num_put(0), _M_num_get(0)
- { }
- void
- init(basic_streambuf<_CharT, _Traits>* __sb);
- void
- _M_cache_locale(const locale& __loc);
- };
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _CharT, typename _Traits>
- void
- basic_ios<_CharT, _Traits>::clear(iostate __state)
- {
- if (this->rdbuf())
- _M_streambuf_state = __state;
- else
- _M_streambuf_state = __state | badbit;
- if (this->exceptions() & this->rdstate())
- __throw_ios_failure(("basic_ios::clear"));
- }
- template<typename _CharT, typename _Traits>
- basic_streambuf<_CharT, _Traits>*
- basic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<_CharT, _Traits>* __sb)
- {
- basic_streambuf<_CharT, _Traits>* __old = _M_streambuf;
- _M_streambuf = __sb;
- this->clear();
- return __old;
- }
- template<typename _CharT, typename _Traits>
- basic_ios<_CharT, _Traits>&
- basic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs)
- {
- if (this != &__rhs)
- {
- _Words* __words = (__rhs._M_word_size <= _S_local_word_size) ?
- _M_local_word : new _Words[__rhs._M_word_size];
- _Callback_list* __cb = __rhs._M_callbacks;
- if (__cb)
- __cb->_M_add_reference();
- _M_call_callbacks(erase_event);
- if (_M_word != _M_local_word)
- {
- delete [] _M_word;
- _M_word = 0;
- }
- _M_dispose_callbacks();
- _M_callbacks = __cb;
- for (int __i = 0; __i < __rhs._M_word_size; ++__i)
- __words[__i] = __rhs._M_word[__i];
- _M_word = __words;
- _M_word_size = __rhs._M_word_size;
- this->flags(__rhs.flags());
- this->width(__rhs.width());
- this->precision(__rhs.precision());
- this->tie(__rhs.tie());
- this->fill(__rhs.fill());
- _M_ios_locale = __rhs.getloc();
- _M_cache_locale(_M_ios_locale);
- _M_call_callbacks(copyfmt_event);
- this->exceptions(__rhs.exceptions());
- }
- return *this;
- }
- template<typename _CharT, typename _Traits>
- locale
- basic_ios<_CharT, _Traits>::imbue(const locale& __loc)
- {
- locale __old(this->getloc());
- ios_base::imbue(__loc);
- _M_cache_locale(__loc);
- if (this->rdbuf() != 0)
- this->rdbuf()->pubimbue(__loc);
- return __old;
- }
- template<typename _CharT, typename _Traits>
- void
- basic_ios<_CharT, _Traits>::init(basic_streambuf<_CharT, _Traits>* __sb)
- {
- ios_base::_M_init();
- _M_cache_locale(_M_ios_locale);
- _M_fill = _CharT();
- _M_fill_init = false;
- _M_tie = 0;
- _M_exception = goodbit;
- _M_streambuf = __sb;
- _M_streambuf_state = __sb ? goodbit : badbit;
- }
- template<typename _CharT, typename _Traits>
- void
- basic_ios<_CharT, _Traits>::_M_cache_locale(const locale& __loc)
- {
- if (__builtin_expect(has_facet<__ctype_type>(__loc), true))
- _M_ctype = &use_facet<__ctype_type>(__loc);
- else
- _M_ctype = 0;
- if (__builtin_expect(has_facet<__num_put_type>(__loc), true))
- _M_num_put = &use_facet<__num_put_type>(__loc);
- else
- _M_num_put = 0;
- if (__builtin_expect(has_facet<__num_get_type>(__loc), true))
- _M_num_get = &use_facet<__num_get_type>(__loc);
- else
- _M_num_get = 0;
- }
- extern template class basic_ios<char>;
- extern template class basic_ios<wchar_t>;
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _CharT, typename _Traits>
- class basic_ostream : virtual public basic_ios<_CharT, _Traits>
- {
- public:
- typedef _CharT char_type;
- typedef typename _Traits::int_type int_type;
- typedef typename _Traits::pos_type pos_type;
- typedef typename _Traits::off_type off_type;
- typedef _Traits traits_type;
- typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
- typedef basic_ios<_CharT, _Traits> __ios_type;
- typedef basic_ostream<_CharT, _Traits> __ostream_type;
- typedef num_put<_CharT, ostreambuf_iterator<_CharT, _Traits> >
- __num_put_type;
- typedef ctype<_CharT> __ctype_type;
- explicit
- basic_ostream(__streambuf_type* __sb)
- { this->init(__sb); }
- virtual
- ~basic_ostream() { }
- class sentry;
- friend class sentry;
- __ostream_type&
- operator<<(__ostream_type& (*__pf)(__ostream_type&))
- {
- return __pf(*this);
- }
- __ostream_type&
- operator<<(__ios_type& (*__pf)(__ios_type&))
- {
- __pf(*this);
- return *this;
- }
- __ostream_type&
- operator<<(ios_base& (*__pf) (ios_base&))
- {
- __pf(*this);
- return *this;
- }
- __ostream_type&
- operator<<(long __n)
- { return _M_insert(__n); }
- __ostream_type&
- operator<<(unsigned long __n)
- { return _M_insert(__n); }
- __ostream_type&
- operator<<(bool __n)
- { return _M_insert(__n); }
- __ostream_type&
- operator<<(short __n);
- __ostream_type&
- operator<<(unsigned short __n)
- {
- return _M_insert(static_cast<unsigned long>(__n));
- }
- __ostream_type&
- operator<<(int __n);
- __ostream_type&
- operator<<(unsigned int __n)
- {
- return _M_insert(static_cast<unsigned long>(__n));
- }
- __ostream_type&
- operator<<(long long __n)
- { return _M_insert(__n); }
- __ostream_type&
- operator<<(unsigned long long __n)
- { return _M_insert(__n); }
- __ostream_type&
- operator<<(double __f)
- { return _M_insert(__f); }
- __ostream_type&
- operator<<(float __f)
- {
- return _M_insert(static_cast<double>(__f));
- }
- __ostream_type&
- operator<<(long double __f)
- { return _M_insert(__f); }
- __ostream_type&
- operator<<(const void* __p)
- { return _M_insert(__p); }
- __ostream_type&
- operator<<(__streambuf_type* __sb);
- __ostream_type&
- put(char_type __c);
- void
- _M_write(const char_type* __s, streamsize __n)
- {
- const streamsize __put = this->rdbuf()->sputn(__s, __n);
- if (__put != __n)
- this->setstate(ios_base::badbit);
- }
- __ostream_type&
- write(const char_type* __s, streamsize __n);
- __ostream_type&
- flush();
- pos_type
- tellp();
- __ostream_type&
- seekp(pos_type);
- __ostream_type&
- seekp(off_type, ios_base::seekdir);
- protected:
- basic_ostream()
- { this->init(0); }
- template<typename _ValueT>
- __ostream_type&
- _M_insert(_ValueT __v);
- };
- template <typename _CharT, typename _Traits>
- class basic_ostream<_CharT, _Traits>::sentry
- {
- bool _M_ok;
- basic_ostream<_CharT, _Traits>& _M_os;
- public:
- explicit
- sentry(basic_ostream<_CharT, _Traits>& __os);
- ~sentry()
- {
- if (bool(_M_os.flags() & ios_base::unitbuf) && !uncaught_exception())
- {
- if (_M_os.rdbuf() && _M_os.rdbuf()->pubsync() == -1)
- _M_os.setstate(ios_base::badbit);
- }
- }
- operator bool() const
- { return _M_ok; }
- };
- template<typename _CharT, typename _Traits>
- inline basic_ostream<_CharT, _Traits>&
- operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)
- { return __ostream_insert(__out, &__c, 1); }
- template<typename _CharT, typename _Traits>
- inline basic_ostream<_CharT, _Traits>&
- operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)
- { return (__out << __out.widen(__c)); }
- template <class _Traits>
- inline basic_ostream<char, _Traits>&
- operator<<(basic_ostream<char, _Traits>& __out, char __c)
- { return __ostream_insert(__out, &__c, 1); }
- template<class _Traits>
- inline basic_ostream<char, _Traits>&
- operator<<(basic_ostream<char, _Traits>& __out, signed char __c)
- { return (__out << static_cast<char>(__c)); }
- template<class _Traits>
- inline basic_ostream<char, _Traits>&
- operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)
- { return (__out << static_cast<char>(__c)); }
- template<typename _CharT, typename _Traits>
- inline basic_ostream<_CharT, _Traits>&
- operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)
- {
- if (!__s)
- __out.setstate(ios_base::badbit);
- else
- __ostream_insert(__out, __s,
- static_cast<streamsize>(_Traits::length(__s)));
- return __out;
- }
- template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits> &
- operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s);
- template<class _Traits>
- inline basic_ostream<char, _Traits>&
- operator<<(basic_ostream<char, _Traits>& __out, const char* __s)
- {
- if (!__s)
- __out.setstate(ios_base::badbit);
- else
- __ostream_insert(__out, __s,
- static_cast<streamsize>(_Traits::length(__s)));
- return __out;
- }
- template<class _Traits>
- inline basic_ostream<char, _Traits>&
- operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)
- { return (__out << reinterpret_cast<const char*>(__s)); }
- template<class _Traits>
- inline basic_ostream<char, _Traits> &
- operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)
- { return (__out << reinterpret_cast<const char*>(__s)); }
- template<typename _CharT, typename _Traits>
- inline basic_ostream<_CharT, _Traits>&
- endl(basic_ostream<_CharT, _Traits>& __os)
- { return flush(__os.put(__os.widen('\n'))); }
- template<typename _CharT, typename _Traits>
- inline basic_ostream<_CharT, _Traits>&
- ends(basic_ostream<_CharT, _Traits>& __os)
- { return __os.put(_CharT()); }
- template<typename _CharT, typename _Traits>
- inline basic_ostream<_CharT, _Traits>&
- flush(basic_ostream<_CharT, _Traits>& __os)
- { return __os.flush(); }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>::sentry::
- sentry(basic_ostream<_CharT, _Traits>& __os)
- : _M_ok(false), _M_os(__os)
- {
- if (__os.tie() && __os.good())
- __os.tie()->flush();
- if (__os.good())
- _M_ok = true;
- else
- __os.setstate(ios_base::failbit);
- }
- template<typename _CharT, typename _Traits>
- template<typename _ValueT>
- basic_ostream<_CharT, _Traits>&
- basic_ostream<_CharT, _Traits>::
- _M_insert(_ValueT __v)
- {
- sentry __cerb(*this);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::goodbit;
- try
- {
- const __num_put_type& __np = __check_facet(this->_M_num_put);
- if (__np.put(*this, *this, this->fill(), __v).failed())
- __err |= ios_base::badbit;
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
- template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>&
- basic_ostream<_CharT, _Traits>::
- operator<<(short __n)
- {
- const ios_base::fmtflags __fmt = this->flags() & ios_base::basefield;
- if (__fmt == ios_base::oct || __fmt == ios_base::hex)
- return _M_insert(static_cast<long>(static_cast<unsigned short>(__n)));
- else
- return _M_insert(static_cast<long>(__n));
- }
- template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>&
- basic_ostream<_CharT, _Traits>::
- operator<<(int __n)
- {
- const ios_base::fmtflags __fmt = this->flags() & ios_base::basefield;
- if (__fmt == ios_base::oct || __fmt == ios_base::hex)
- return _M_insert(static_cast<long>(static_cast<unsigned int>(__n)));
- else
- return _M_insert(static_cast<long>(__n));
- }
- template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>&
- basic_ostream<_CharT, _Traits>::
- operator<<(__streambuf_type* __sbin)
- {
- ios_base::iostate __err = ios_base::goodbit;
- sentry __cerb(*this);
- if (__cerb && __sbin)
- {
- try
- {
- if (!__copy_streambufs(__sbin, this->rdbuf()))
- __err |= ios_base::failbit;
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::failbit); }
- }
- else if (!__sbin)
- __err |= ios_base::badbit;
- if (__err)
- this->setstate(__err);
- return *this;
- }
- template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>&
- basic_ostream<_CharT, _Traits>::
- put(char_type __c)
- {
- sentry __cerb(*this);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::goodbit;
- try
- {
- const int_type __put = this->rdbuf()->sputc(__c);
- if (traits_type::eq_int_type(__put, traits_type::eof()))
- __err |= ios_base::badbit;
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
- template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>&
- basic_ostream<_CharT, _Traits>::
- write(const _CharT* __s, streamsize __n)
- {
- sentry __cerb(*this);
- if (__cerb)
- {
- try
- { _M_write(__s, __n); }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- }
- return *this;
- }
- template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>&
- basic_ostream<_CharT, _Traits>::
- flush()
- {
- ios_base::iostate __err = ios_base::goodbit;
- try
- {
- if (this->rdbuf() && this->rdbuf()->pubsync() == -1)
- __err |= ios_base::badbit;
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- return *this;
- }
- template<typename _CharT, typename _Traits>
- typename basic_ostream<_CharT, _Traits>::pos_type
- basic_ostream<_CharT, _Traits>::
- tellp()
- {
- pos_type __ret = pos_type(-1);
- try
- {
- if (!this->fail())
- __ret = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out);
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- return __ret;
- }
- template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>&
- basic_ostream<_CharT, _Traits>::
- seekp(pos_type __pos)
- {
- ios_base::iostate __err = ios_base::goodbit;
- try
- {
- if (!this->fail())
- {
- const pos_type __p = this->rdbuf()->pubseekpos(__pos,
- ios_base::out);
- if (__p == pos_type(off_type(-1)))
- __err |= ios_base::failbit;
- }
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- return *this;
- }
- template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>&
- basic_ostream<_CharT, _Traits>::
- seekp(off_type __off, ios_base::seekdir __dir)
- {
- ios_base::iostate __err = ios_base::goodbit;
- try
- {
- if (!this->fail())
- {
- const pos_type __p = this->rdbuf()->pubseekoff(__off, __dir,
- ios_base::out);
- if (__p == pos_type(off_type(-1)))
- __err |= ios_base::failbit;
- }
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- return *this;
- }
- template<typename _CharT, typename _Traits>
- basic_ostream<_CharT, _Traits>&
- operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)
- {
- if (!__s)
- __out.setstate(ios_base::badbit);
- else
- {
- const size_t __clen = char_traits<char>::length(__s);
- try
- {
- struct __ptr_guard
- {
- _CharT *__p;
- __ptr_guard (_CharT *__ip): __p(__ip) { }
- ~__ptr_guard() { delete[] __p; }
- _CharT* __get() { return __p; }
- } __pg (new _CharT[__clen]);
- _CharT *__ws = __pg.__get();
- for (size_t __i = 0; __i < __clen; ++__i)
- __ws[__i] = __out.widen(__s[__i]);
- __ostream_insert(__out, __ws, __clen);
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- __out._M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { __out._M_setstate(ios_base::badbit); }
- }
- return __out;
- }
- extern template class basic_ostream<char>;
- extern template ostream& endl(ostream&);
- extern template ostream& ends(ostream&);
- extern template ostream& flush(ostream&);
- extern template ostream& operator<<(ostream&, char);
- extern template ostream& operator<<(ostream&, unsigned char);
- extern template ostream& operator<<(ostream&, signed char);
- extern template ostream& operator<<(ostream&, const char*);
- extern template ostream& operator<<(ostream&, const unsigned char*);
- extern template ostream& operator<<(ostream&, const signed char*);
- extern template ostream& ostream::_M_insert(long);
- extern template ostream& ostream::_M_insert(unsigned long);
- extern template ostream& ostream::_M_insert(bool);
- extern template ostream& ostream::_M_insert(long long);
- extern template ostream& ostream::_M_insert(unsigned long long);
- extern template ostream& ostream::_M_insert(double);
- extern template ostream& ostream::_M_insert(long double);
- extern template ostream& ostream::_M_insert(const void*);
- extern template class basic_ostream<wchar_t>;
- extern template wostream& endl(wostream&);
- extern template wostream& ends(wostream&);
- extern template wostream& flush(wostream&);
- extern template wostream& operator<<(wostream&, wchar_t);
- extern template wostream& operator<<(wostream&, char);
- extern template wostream& operator<<(wostream&, const wchar_t*);
- extern template wostream& operator<<(wostream&, const char*);
- extern template wostream& wostream::_M_insert(long);
- extern template wostream& wostream::_M_insert(unsigned long);
- extern template wostream& wostream::_M_insert(bool);
- extern template wostream& wostream::_M_insert(long long);
- extern template wostream& wostream::_M_insert(unsigned long long);
- extern template wostream& wostream::_M_insert(double);
- extern template wostream& wostream::_M_insert(long double);
- extern template wostream& wostream::_M_insert(const void*);
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _CharT, typename _Traits>
- class basic_istream : virtual public basic_ios<_CharT, _Traits>
- {
- public:
- typedef _CharT char_type;
- typedef typename _Traits::int_type int_type;
- typedef typename _Traits::pos_type pos_type;
- typedef typename _Traits::off_type off_type;
- typedef _Traits traits_type;
- typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
- typedef basic_ios<_CharT, _Traits> __ios_type;
- typedef basic_istream<_CharT, _Traits> __istream_type;
- typedef num_get<_CharT, istreambuf_iterator<_CharT, _Traits> >
- __num_get_type;
- typedef ctype<_CharT> __ctype_type;
- protected:
- streamsize _M_gcount;
- public:
- explicit
- basic_istream(__streambuf_type* __sb)
- : _M_gcount(streamsize(0))
- { this->init(__sb); }
- virtual
- ~basic_istream()
- { _M_gcount = streamsize(0); }
- class sentry;
- friend class sentry;
- __istream_type&
- operator>>(__istream_type& (*__pf)(__istream_type&))
- { return __pf(*this); }
- __istream_type&
- operator>>(__ios_type& (*__pf)(__ios_type&))
- {
- __pf(*this);
- return *this;
- }
- __istream_type&
- operator>>(ios_base& (*__pf)(ios_base&))
- {
- __pf(*this);
- return *this;
- }
- __istream_type&
- operator>>(bool& __n)
- { return _M_extract(__n); }
- __istream_type&
- operator>>(short& __n);
- __istream_type&
- operator>>(unsigned short& __n)
- { return _M_extract(__n); }
- __istream_type&
- operator>>(int& __n);
- __istream_type&
- operator>>(unsigned int& __n)
- { return _M_extract(__n); }
- __istream_type&
- operator>>(long& __n)
- { return _M_extract(__n); }
- __istream_type&
- operator>>(unsigned long& __n)
- { return _M_extract(__n); }
- __istream_type&
- operator>>(long long& __n)
- { return _M_extract(__n); }
- __istream_type&
- operator>>(unsigned long long& __n)
- { return _M_extract(__n); }
- __istream_type&
- operator>>(float& __f)
- { return _M_extract(__f); }
- __istream_type&
- operator>>(double& __f)
- { return _M_extract(__f); }
- __istream_type&
- operator>>(long double& __f)
- { return _M_extract(__f); }
- __istream_type&
- operator>>(void*& __p)
- { return _M_extract(__p); }
- __istream_type&
- operator>>(__streambuf_type* __sb);
- streamsize
- gcount() const
- { return _M_gcount; }
- int_type
- get();
- __istream_type&
- get(char_type& __c);
- __istream_type&
- get(char_type* __s, streamsize __n, char_type __delim);
- __istream_type&
- get(char_type* __s, streamsize __n)
- { return this->get(__s, __n, this->widen('\n')); }
- __istream_type&
- get(__streambuf_type& __sb, char_type __delim);
- __istream_type&
- get(__streambuf_type& __sb)
- { return this->get(__sb, this->widen('\n')); }
- __istream_type&
- getline(char_type* __s, streamsize __n, char_type __delim);
- __istream_type&
- getline(char_type* __s, streamsize __n)
- { return this->getline(__s, __n, this->widen('\n')); }
- __istream_type&
- ignore();
- __istream_type&
- ignore(streamsize __n);
- __istream_type&
- ignore(streamsize __n, int_type __delim);
- int_type
- peek();
- __istream_type&
- read(char_type* __s, streamsize __n);
- streamsize
- readsome(char_type* __s, streamsize __n);
- __istream_type&
- putback(char_type __c);
- __istream_type&
- unget();
- int
- sync();
- pos_type
- tellg();
- __istream_type&
- seekg(pos_type);
- __istream_type&
- seekg(off_type, ios_base::seekdir);
- protected:
- basic_istream()
- : _M_gcount(streamsize(0))
- { this->init(0); }
- template<typename _ValueT>
- __istream_type&
- _M_extract(_ValueT& __v);
- };
- template<>
- basic_istream<char>&
- basic_istream<char>::
- getline(char_type* __s, streamsize __n, char_type __delim);
- template<>
- basic_istream<char>&
- basic_istream<char>::
- ignore(streamsize __n);
- template<>
- basic_istream<char>&
- basic_istream<char>::
- ignore(streamsize __n, int_type __delim);
- template<>
- basic_istream<wchar_t>&
- basic_istream<wchar_t>::
- getline(char_type* __s, streamsize __n, char_type __delim);
- template<>
- basic_istream<wchar_t>&
- basic_istream<wchar_t>::
- ignore(streamsize __n);
- template<>
- basic_istream<wchar_t>&
- basic_istream<wchar_t>::
- ignore(streamsize __n, int_type __delim);
- template<typename _CharT, typename _Traits>
- class basic_istream<_CharT, _Traits>::sentry
- {
- bool _M_ok;
- public:
- typedef _Traits traits_type;
- typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
- typedef basic_istream<_CharT, _Traits> __istream_type;
- typedef typename __istream_type::__ctype_type __ctype_type;
- typedef typename _Traits::int_type __int_type;
- explicit
- sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false);
- operator bool() const
- { return _M_ok; }
- };
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c);
- template<class _Traits>
- inline basic_istream<char, _Traits>&
- operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
- { return (__in >> reinterpret_cast<char&>(__c)); }
- template<class _Traits>
- inline basic_istream<char, _Traits>&
- operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
- { return (__in >> reinterpret_cast<char&>(__c)); }
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s);
- template<>
- basic_istream<char>&
- operator>>(basic_istream<char>& __in, char* __s);
- template<class _Traits>
- inline basic_istream<char, _Traits>&
- operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s)
- { return (__in >> reinterpret_cast<char*>(__s)); }
- template<class _Traits>
- inline basic_istream<char, _Traits>&
- operator>>(basic_istream<char, _Traits>& __in, signed char* __s)
- { return (__in >> reinterpret_cast<char*>(__s)); }
- template<typename _CharT, typename _Traits>
- class basic_iostream
- : public basic_istream<_CharT, _Traits>,
- public basic_ostream<_CharT, _Traits>
- {
- public:
- typedef _CharT char_type;
- typedef typename _Traits::int_type int_type;
- typedef typename _Traits::pos_type pos_type;
- typedef typename _Traits::off_type off_type;
- typedef _Traits traits_type;
- typedef basic_istream<_CharT, _Traits> __istream_type;
- typedef basic_ostream<_CharT, _Traits> __ostream_type;
- explicit
- basic_iostream(basic_streambuf<_CharT, _Traits>* __sb)
- : __istream_type(__sb), __ostream_type(__sb) { }
- virtual
- ~basic_iostream() { }
- protected:
- basic_iostream()
- : __istream_type(), __ostream_type() { }
- };
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- ws(basic_istream<_CharT, _Traits>& __is);
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>::sentry::
- sentry(basic_istream<_CharT, _Traits>& __in, bool __noskip) : _M_ok(false)
- {
- ios_base::iostate __err = ios_base::goodbit;
- if (__in.good())
- {
- if (__in.tie())
- __in.tie()->flush();
- if (!__noskip && bool(__in.flags() & ios_base::skipws))
- {
- const __int_type __eof = traits_type::eof();
- __streambuf_type* __sb = __in.rdbuf();
- __int_type __c = __sb->sgetc();
- const __ctype_type& __ct = __check_facet(__in._M_ctype);
- while (!traits_type::eq_int_type(__c, __eof)
- && __ct.is(ctype_base::space,
- traits_type::to_char_type(__c)))
- __c = __sb->snextc();
- if (traits_type::eq_int_type(__c, __eof))
- __err |= ios_base::eofbit;
- }
- }
- if (__in.good() && __err == ios_base::goodbit)
- _M_ok = true;
- else
- {
- __err |= ios_base::failbit;
- __in.setstate(__err);
- }
- }
- template<typename _CharT, typename _Traits>
- template<typename _ValueT>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- _M_extract(_ValueT& __v)
- {
- sentry __cerb(*this, false);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::goodbit;
- try
- {
- const __num_get_type& __ng = __check_facet(this->_M_num_get);
- __ng.get(*this, 0, *this, __err, __v);
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- operator>>(short& __n)
- {
- sentry __cerb(*this, false);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::goodbit;
- try
- {
- long __l;
- const __num_get_type& __ng = __check_facet(this->_M_num_get);
- __ng.get(*this, 0, *this, __err, __l);
- if (__l < __gnu_cxx::__numeric_traits<short>::__min)
- {
- __err |= ios_base::failbit;
- __n = __gnu_cxx::__numeric_traits<short>::__min;
- }
- else if (__l > __gnu_cxx::__numeric_traits<short>::__max)
- {
- __err |= ios_base::failbit;
- __n = __gnu_cxx::__numeric_traits<short>::__max;
- }
- else
- __n = short(__l);
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- operator>>(int& __n)
- {
- sentry __cerb(*this, false);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::goodbit;
- try
- {
- long __l;
- const __num_get_type& __ng = __check_facet(this->_M_num_get);
- __ng.get(*this, 0, *this, __err, __l);
- if (__l < __gnu_cxx::__numeric_traits<int>::__min)
- {
- __err |= ios_base::failbit;
- __n = __gnu_cxx::__numeric_traits<int>::__min;
- }
- else if (__l > __gnu_cxx::__numeric_traits<int>::__max)
- {
- __err |= ios_base::failbit;
- __n = __gnu_cxx::__numeric_traits<int>::__max;
- }
- else
- __n = int(__l);
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- operator>>(__streambuf_type* __sbout)
- {
- ios_base::iostate __err = ios_base::goodbit;
- sentry __cerb(*this, false);
- if (__cerb && __sbout)
- {
- try
- {
- bool __ineof;
- if (!__copy_streambufs_eof(this->rdbuf(), __sbout, __ineof))
- __err |= ios_base::failbit;
- if (__ineof)
- __err |= ios_base::eofbit;
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::failbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::failbit); }
- }
- else if (!__sbout)
- __err |= ios_base::failbit;
- if (__err)
- this->setstate(__err);
- return *this;
- }
- template<typename _CharT, typename _Traits>
- typename basic_istream<_CharT, _Traits>::int_type
- basic_istream<_CharT, _Traits>::
- get(void)
- {
- const int_type __eof = traits_type::eof();
- int_type __c = __eof;
- _M_gcount = 0;
- ios_base::iostate __err = ios_base::goodbit;
- sentry __cerb(*this, true);
- if (__cerb)
- {
- try
- {
- __c = this->rdbuf()->sbumpc();
- if (!traits_type::eq_int_type(__c, __eof))
- _M_gcount = 1;
- else
- __err |= ios_base::eofbit;
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- }
- if (!_M_gcount)
- __err |= ios_base::failbit;
- if (__err)
- this->setstate(__err);
- return __c;
- }
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- get(char_type& __c)
- {
- _M_gcount = 0;
- ios_base::iostate __err = ios_base::goodbit;
- sentry __cerb(*this, true);
- if (__cerb)
- {
- try
- {
- const int_type __cb = this->rdbuf()->sbumpc();
- if (!traits_type::eq_int_type(__cb, traits_type::eof()))
- {
- _M_gcount = 1;
- __c = traits_type::to_char_type(__cb);
- }
- else
- __err |= ios_base::eofbit;
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- }
- if (!_M_gcount)
- __err |= ios_base::failbit;
- if (__err)
- this->setstate(__err);
- return *this;
- }
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- get(char_type* __s, streamsize __n, char_type __delim)
- {
- _M_gcount = 0;
- ios_base::iostate __err = ios_base::goodbit;
- sentry __cerb(*this, true);
- if (__cerb)
- {
- try
- {
- const int_type __idelim = traits_type::to_int_type(__delim);
- const int_type __eof = traits_type::eof();
- __streambuf_type* __sb = this->rdbuf();
- int_type __c = __sb->sgetc();
- while (_M_gcount + 1 < __n
- && !traits_type::eq_int_type(__c, __eof)
- && !traits_type::eq_int_type(__c, __idelim))
- {
- *__s++ = traits_type::to_char_type(__c);
- ++_M_gcount;
- __c = __sb->snextc();
- }
- if (traits_type::eq_int_type(__c, __eof))
- __err |= ios_base::eofbit;
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- }
- if (__n > 0)
- *__s = char_type();
- if (!_M_gcount)
- __err |= ios_base::failbit;
- if (__err)
- this->setstate(__err);
- return *this;
- }
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- get(__streambuf_type& __sb, char_type __delim)
- {
- _M_gcount = 0;
- ios_base::iostate __err = ios_base::goodbit;
- sentry __cerb(*this, true);
- if (__cerb)
- {
- try
- {
- const int_type __idelim = traits_type::to_int_type(__delim);
- const int_type __eof = traits_type::eof();
- __streambuf_type* __this_sb = this->rdbuf();
- int_type __c = __this_sb->sgetc();
- char_type __c2 = traits_type::to_char_type(__c);
- while (!traits_type::eq_int_type(__c, __eof)
- && !traits_type::eq_int_type(__c, __idelim)
- && !traits_type::eq_int_type(__sb.sputc(__c2), __eof))
- {
- ++_M_gcount;
- __c = __this_sb->snextc();
- __c2 = traits_type::to_char_type(__c);
- }
- if (traits_type::eq_int_type(__c, __eof))
- __err |= ios_base::eofbit;
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- }
- if (!_M_gcount)
- __err |= ios_base::failbit;
- if (__err)
- this->setstate(__err);
- return *this;
- }
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- getline(char_type* __s, streamsize __n, char_type __delim)
- {
- _M_gcount = 0;
- ios_base::iostate __err = ios_base::goodbit;
- sentry __cerb(*this, true);
- if (__cerb)
- {
- try
- {
- const int_type __idelim = traits_type::to_int_type(__delim);
- const int_type __eof = traits_type::eof();
- __streambuf_type* __sb = this->rdbuf();
- int_type __c = __sb->sgetc();
- while (_M_gcount + 1 < __n
- && !traits_type::eq_int_type(__c, __eof)
- && !traits_type::eq_int_type(__c, __idelim))
- {
- *__s++ = traits_type::to_char_type(__c);
- __c = __sb->snextc();
- ++_M_gcount;
- }
- if (traits_type::eq_int_type(__c, __eof))
- __err |= ios_base::eofbit;
- else
- {
- if (traits_type::eq_int_type(__c, __idelim))
- {
- __sb->sbumpc();
- ++_M_gcount;
- }
- else
- __err |= ios_base::failbit;
- }
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- }
- if (__n > 0)
- *__s = char_type();
- if (!_M_gcount)
- __err |= ios_base::failbit;
- if (__err)
- this->setstate(__err);
- return *this;
- }
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- ignore(void)
- {
- _M_gcount = 0;
- sentry __cerb(*this, true);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::goodbit;
- try
- {
- const int_type __eof = traits_type::eof();
- __streambuf_type* __sb = this->rdbuf();
- if (traits_type::eq_int_type(__sb->sbumpc(), __eof))
- __err |= ios_base::eofbit;
- else
- _M_gcount = 1;
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- ignore(streamsize __n)
- {
- _M_gcount = 0;
- sentry __cerb(*this, true);
- if (__cerb && __n > 0)
- {
- ios_base::iostate __err = ios_base::goodbit;
- try
- {
- const int_type __eof = traits_type::eof();
- __streambuf_type* __sb = this->rdbuf();
- int_type __c = __sb->sgetc();
- bool __large_ignore = false;
- while (true)
- {
- while (_M_gcount < __n
- && !traits_type::eq_int_type(__c, __eof))
- {
- ++_M_gcount;
- __c = __sb->snextc();
- }
- if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
- && !traits_type::eq_int_type(__c, __eof))
- {
- _M_gcount =
- __gnu_cxx::__numeric_traits<streamsize>::__min;
- __large_ignore = true;
- }
- else
- break;
- }
- if (__large_ignore)
- _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
- if (traits_type::eq_int_type(__c, __eof))
- __err |= ios_base::eofbit;
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- ignore(streamsize __n, int_type __delim)
- {
- _M_gcount = 0;
- sentry __cerb(*this, true);
- if (__cerb && __n > 0)
- {
- ios_base::iostate __err = ios_base::goodbit;
- try
- {
- const int_type __eof = traits_type::eof();
- __streambuf_type* __sb = this->rdbuf();
- int_type __c = __sb->sgetc();
- bool __large_ignore = false;
- while (true)
- {
- while (_M_gcount < __n
- && !traits_type::eq_int_type(__c, __eof)
- && !traits_type::eq_int_type(__c, __delim))
- {
- ++_M_gcount;
- __c = __sb->snextc();
- }
- if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
- && !traits_type::eq_int_type(__c, __eof)
- && !traits_type::eq_int_type(__c, __delim))
- {
- _M_gcount =
- __gnu_cxx::__numeric_traits<streamsize>::__min;
- __large_ignore = true;
- }
- else
- break;
- }
- if (__large_ignore)
- _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
- if (traits_type::eq_int_type(__c, __eof))
- __err |= ios_base::eofbit;
- else if (traits_type::eq_int_type(__c, __delim))
- {
- if (_M_gcount
- < __gnu_cxx::__numeric_traits<streamsize>::__max)
- ++_M_gcount;
- __sb->sbumpc();
- }
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
- template<typename _CharT, typename _Traits>
- typename basic_istream<_CharT, _Traits>::int_type
- basic_istream<_CharT, _Traits>::
- peek(void)
- {
- int_type __c = traits_type::eof();
- _M_gcount = 0;
- sentry __cerb(*this, true);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::goodbit;
- try
- {
- __c = this->rdbuf()->sgetc();
- if (traits_type::eq_int_type(__c, traits_type::eof()))
- __err |= ios_base::eofbit;
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return __c;
- }
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- read(char_type* __s, streamsize __n)
- {
- _M_gcount = 0;
- sentry __cerb(*this, true);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::goodbit;
- try
- {
- _M_gcount = this->rdbuf()->sgetn(__s, __n);
- if (_M_gcount != __n)
- __err |= (ios_base::eofbit | ios_base::failbit);
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
- template<typename _CharT, typename _Traits>
- streamsize
- basic_istream<_CharT, _Traits>::
- readsome(char_type* __s, streamsize __n)
- {
- _M_gcount = 0;
- sentry __cerb(*this, true);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::goodbit;
- try
- {
- const streamsize __num = this->rdbuf()->in_avail();
- if (__num > 0)
- _M_gcount = this->rdbuf()->sgetn(__s, std::min(__num, __n));
- else if (__num == -1)
- __err |= ios_base::eofbit;
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return _M_gcount;
- }
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- putback(char_type __c)
- {
- _M_gcount = 0;
- this->clear(this->rdstate() & ~ios_base::eofbit);
- sentry __cerb(*this, true);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::goodbit;
- try
- {
- const int_type __eof = traits_type::eof();
- __streambuf_type* __sb = this->rdbuf();
- if (!__sb
- || traits_type::eq_int_type(__sb->sputbackc(__c), __eof))
- __err |= ios_base::badbit;
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- unget(void)
- {
- _M_gcount = 0;
- this->clear(this->rdstate() & ~ios_base::eofbit);
- sentry __cerb(*this, true);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::goodbit;
- try
- {
- const int_type __eof = traits_type::eof();
- __streambuf_type* __sb = this->rdbuf();
- if (!__sb
- || traits_type::eq_int_type(__sb->sungetc(), __eof))
- __err |= ios_base::badbit;
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
- template<typename _CharT, typename _Traits>
- int
- basic_istream<_CharT, _Traits>::
- sync(void)
- {
- int __ret = -1;
- sentry __cerb(*this, true);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::goodbit;
- try
- {
- __streambuf_type* __sb = this->rdbuf();
- if (__sb)
- {
- if (__sb->pubsync() == -1)
- __err |= ios_base::badbit;
- else
- __ret = 0;
- }
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return __ret;
- }
- template<typename _CharT, typename _Traits>
- typename basic_istream<_CharT, _Traits>::pos_type
- basic_istream<_CharT, _Traits>::
- tellg(void)
- {
- pos_type __ret = pos_type(-1);
- sentry __cerb(*this, true);
- if (__cerb)
- {
- try
- {
- if (!this->fail())
- __ret = this->rdbuf()->pubseekoff(0, ios_base::cur,
- ios_base::in);
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- }
- return __ret;
- }
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- seekg(pos_type __pos)
- {
- this->clear(this->rdstate() & ~ios_base::eofbit);
- sentry __cerb(*this, true);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::goodbit;
- try
- {
- if (!this->fail())
- {
- const pos_type __p = this->rdbuf()->pubseekpos(__pos,
- ios_base::in);
- if (__p == pos_type(off_type(-1)))
- __err |= ios_base::failbit;
- }
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- basic_istream<_CharT, _Traits>::
- seekg(off_type __off, ios_base::seekdir __dir)
- {
- this->clear(this->rdstate() & ~ios_base::eofbit);
- sentry __cerb(*this, true);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::goodbit;
- try
- {
- if (!this->fail())
- {
- const pos_type __p = this->rdbuf()->pubseekoff(__off, __dir,
- ios_base::in);
- if (__p == pos_type(off_type(-1)))
- __err |= ios_base::failbit;
- }
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- this->_M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { this->_M_setstate(ios_base::badbit); }
- if (__err)
- this->setstate(__err);
- }
- return *this;
- }
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c)
- {
- typedef basic_istream<_CharT, _Traits> __istream_type;
- typedef typename __istream_type::int_type __int_type;
- typename __istream_type::sentry __cerb(__in, false);
- if (__cerb)
- {
- ios_base::iostate __err = ios_base::goodbit;
- try
- {
- const __int_type __cb = __in.rdbuf()->sbumpc();
- if (!_Traits::eq_int_type(__cb, _Traits::eof()))
- __c = _Traits::to_char_type(__cb);
- else
- __err |= (ios_base::eofbit | ios_base::failbit);
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- __in._M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { __in._M_setstate(ios_base::badbit); }
- if (__err)
- __in.setstate(__err);
- }
- return __in;
- }
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s)
- {
- typedef basic_istream<_CharT, _Traits> __istream_type;
- typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
- typedef typename _Traits::int_type int_type;
- typedef _CharT char_type;
- typedef ctype<_CharT> __ctype_type;
- streamsize __extracted = 0;
- ios_base::iostate __err = ios_base::goodbit;
- typename __istream_type::sentry __cerb(__in, false);
- if (__cerb)
- {
- try
- {
- streamsize __num = __in.width();
- if (__num <= 0)
- __num = __gnu_cxx::__numeric_traits<streamsize>::__max;
- const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc());
- const int_type __eof = _Traits::eof();
- __streambuf_type* __sb = __in.rdbuf();
- int_type __c = __sb->sgetc();
- while (__extracted < __num - 1
- && !_Traits::eq_int_type(__c, __eof)
- && !__ct.is(ctype_base::space,
- _Traits::to_char_type(__c)))
- {
- *__s++ = _Traits::to_char_type(__c);
- ++__extracted;
- __c = __sb->snextc();
- }
- if (_Traits::eq_int_type(__c, __eof))
- __err |= ios_base::eofbit;
- *__s = char_type();
- __in.width(0);
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- __in._M_setstate(ios_base::badbit);
- throw;
- }
- catch(...)
- { __in._M_setstate(ios_base::badbit); }
- }
- if (!__extracted)
- __err |= ios_base::failbit;
- if (__err)
- __in.setstate(__err);
- return __in;
- }
- template<typename _CharT, typename _Traits>
- basic_istream<_CharT, _Traits>&
- ws(basic_istream<_CharT, _Traits>& __in)
- {
- typedef basic_istream<_CharT, _Traits> __istream_type;
- typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
- typedef typename __istream_type::int_type __int_type;
- typedef ctype<_CharT> __ctype_type;
- const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc());
- const __int_type __eof = _Traits::eof();
- __streambuf_type* __sb = __in.rdbuf();
- __int_type __c = __sb->sgetc();
- while (!_Traits::eq_int_type(__c, __eof)
- && __ct.is(ctype_base::space, _Traits::to_char_type(__c)))
- __c = __sb->snextc();
- if (_Traits::eq_int_type(__c, __eof))
- __in.setstate(ios_base::eofbit);
- return __in;
- }
- extern template class basic_istream<char>;
- extern template istream& ws(istream&);
- extern template istream& operator>>(istream&, char&);
- extern template istream& operator>>(istream&, char*);
- extern template istream& operator>>(istream&, unsigned char&);
- extern template istream& operator>>(istream&, signed char&);
- extern template istream& operator>>(istream&, unsigned char*);
- extern template istream& operator>>(istream&, signed char*);
- extern template istream& istream::_M_extract(unsigned short&);
- extern template istream& istream::_M_extract(unsigned int&);
- extern template istream& istream::_M_extract(long&);
- extern template istream& istream::_M_extract(unsigned long&);
- extern template istream& istream::_M_extract(bool&);
- extern template istream& istream::_M_extract(long long&);
- extern template istream& istream::_M_extract(unsigned long long&);
- extern template istream& istream::_M_extract(float&);
- extern template istream& istream::_M_extract(double&);
- extern template istream& istream::_M_extract(long double&);
- extern template istream& istream::_M_extract(void*&);
- extern template class basic_iostream<char>;
- extern template class basic_istream<wchar_t>;
- extern template wistream& ws(wistream&);
- extern template wistream& operator>>(wistream&, wchar_t&);
- extern template wistream& operator>>(wistream&, wchar_t*);
- extern template wistream& wistream::_M_extract(unsigned short&);
- extern template wistream& wistream::_M_extract(unsigned int&);
- extern template wistream& wistream::_M_extract(long&);
- extern template wistream& wistream::_M_extract(unsigned long&);
- extern template wistream& wistream::_M_extract(bool&);
- extern template wistream& wistream::_M_extract(long long&);
- extern template wistream& wistream::_M_extract(unsigned long long&);
- extern template wistream& wistream::_M_extract(float&);
- extern template wistream& wistream::_M_extract(double&);
- extern template wistream& wistream::_M_extract(long double&);
- extern template wistream& wistream::_M_extract(void*&);
- extern template class basic_iostream<wchar_t>;
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _CharT, typename _Traits, typename _Alloc>
- class basic_stringbuf : public basic_streambuf<_CharT, _Traits>
- {
- public:
- typedef _CharT char_type;
- typedef _Traits traits_type;
- typedef _Alloc allocator_type;
- typedef typename traits_type::int_type int_type;
- typedef typename traits_type::pos_type pos_type;
- typedef typename traits_type::off_type off_type;
- typedef basic_streambuf<char_type, traits_type> __streambuf_type;
- typedef basic_string<char_type, _Traits, _Alloc> __string_type;
- typedef typename __string_type::size_type __size_type;
- protected:
- ios_base::openmode _M_mode;
- __string_type _M_string;
- public:
- explicit
- basic_stringbuf(ios_base::openmode __mode = ios_base::in | ios_base::out)
- : __streambuf_type(), _M_mode(__mode), _M_string()
- { }
- explicit
- basic_stringbuf(const __string_type& __str,
- ios_base::openmode __mode = ios_base::in | ios_base::out)
- : __streambuf_type(), _M_mode(), _M_string(__str.data(), __str.size())
- { _M_stringbuf_init(__mode); }
- __string_type
- str() const
- {
- __string_type __ret;
- if (this->pptr())
- {
- if (this->pptr() > this->egptr())
- __ret = __string_type(this->pbase(), this->pptr());
- else
- __ret = __string_type(this->pbase(), this->egptr());
- }
- else
- __ret = _M_string;
- return __ret;
- }
- void
- str(const __string_type& __s)
- {
- _M_string.assign(__s.data(), __s.size());
- _M_stringbuf_init(_M_mode);
- }
- protected:
- void
- _M_stringbuf_init(ios_base::openmode __mode)
- {
- _M_mode = __mode;
- __size_type __len = 0;
- if (_M_mode & (ios_base::ate | ios_base::app))
- __len = _M_string.size();
- _M_sync(const_cast<char_type*>(_M_string.data()), 0, __len);
- }
- virtual streamsize
- showmanyc()
- {
- streamsize __ret = -1;
- if (_M_mode & ios_base::in)
- {
- _M_update_egptr();
- __ret = this->egptr() - this->gptr();
- }
- return __ret;
- }
- virtual int_type
- underflow();
- virtual int_type
- pbackfail(int_type __c = traits_type::eof());
- virtual int_type
- overflow(int_type __c = traits_type::eof());
- virtual __streambuf_type*
- setbuf(char_type* __s, streamsize __n)
- {
- if (__s && __n >= 0)
- {
- _M_string.clear();
- _M_sync(__s, __n, 0);
- }
- return this;
- }
- virtual pos_type
- seekoff(off_type __off, ios_base::seekdir __way,
- ios_base::openmode __mode = ios_base::in | ios_base::out);
- virtual pos_type
- seekpos(pos_type __sp,
- ios_base::openmode __mode = ios_base::in | ios_base::out);
- void
- _M_sync(char_type* __base, __size_type __i, __size_type __o);
- void
- _M_update_egptr()
- {
- const bool __testin = _M_mode & ios_base::in;
- if (this->pptr() && this->pptr() > this->egptr())
- {
- if (__testin)
- this->setg(this->eback(), this->gptr(), this->pptr());
- else
- this->setg(this->pptr(), this->pptr(), this->pptr());
- }
- }
- void
- _M_pbump(char_type* __pbeg, char_type* __pend, off_type __off);
- };
- template<typename _CharT, typename _Traits, typename _Alloc>
- class basic_istringstream : public basic_istream<_CharT, _Traits>
- {
- public:
- typedef _CharT char_type;
- typedef _Traits traits_type;
- typedef _Alloc allocator_type;
- typedef typename traits_type::int_type int_type;
- typedef typename traits_type::pos_type pos_type;
- typedef typename traits_type::off_type off_type;
- typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
- typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type;
- typedef basic_istream<char_type, traits_type> __istream_type;
- private:
- __stringbuf_type _M_stringbuf;
- public:
- explicit
- basic_istringstream(ios_base::openmode __mode = ios_base::in)
- : __istream_type(), _M_stringbuf(__mode | ios_base::in)
- { this->init(&_M_stringbuf); }
- explicit
- basic_istringstream(const __string_type& __str,
- ios_base::openmode __mode = ios_base::in)
- : __istream_type(), _M_stringbuf(__str, __mode | ios_base::in)
- { this->init(&_M_stringbuf); }
- ~basic_istringstream()
- { }
- __stringbuf_type*
- rdbuf() const
- { return const_cast<__stringbuf_type*>(&_M_stringbuf); }
- __string_type
- str() const
- { return _M_stringbuf.str(); }
- void
- str(const __string_type& __s)
- { _M_stringbuf.str(__s); }
- };
- template <typename _CharT, typename _Traits, typename _Alloc>
- class basic_ostringstream : public basic_ostream<_CharT, _Traits>
- {
- public:
- typedef _CharT char_type;
- typedef _Traits traits_type;
- typedef _Alloc allocator_type;
- typedef typename traits_type::int_type int_type;
- typedef typename traits_type::pos_type pos_type;
- typedef typename traits_type::off_type off_type;
- typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
- typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type;
- typedef basic_ostream<char_type, traits_type> __ostream_type;
- private:
- __stringbuf_type _M_stringbuf;
- public:
- explicit
- basic_ostringstream(ios_base::openmode __mode = ios_base::out)
- : __ostream_type(), _M_stringbuf(__mode | ios_base::out)
- { this->init(&_M_stringbuf); }
- explicit
- basic_ostringstream(const __string_type& __str,
- ios_base::openmode __mode = ios_base::out)
- : __ostream_type(), _M_stringbuf(__str, __mode | ios_base::out)
- { this->init(&_M_stringbuf); }
- ~basic_ostringstream()
- { }
- __stringbuf_type*
- rdbuf() const
- { return const_cast<__stringbuf_type*>(&_M_stringbuf); }
- __string_type
- str() const
- { return _M_stringbuf.str(); }
- void
- str(const __string_type& __s)
- { _M_stringbuf.str(__s); }
- };
- template <typename _CharT, typename _Traits, typename _Alloc>
- class basic_stringstream : public basic_iostream<_CharT, _Traits>
- {
- public:
- typedef _CharT char_type;
- typedef _Traits traits_type;
- typedef _Alloc allocator_type;
- typedef typename traits_type::int_type int_type;
- typedef typename traits_type::pos_type pos_type;
- typedef typename traits_type::off_type off_type;
- typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
- typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type;
- typedef basic_iostream<char_type, traits_type> __iostream_type;
- private:
- __stringbuf_type _M_stringbuf;
- public:
- explicit
- basic_stringstream(ios_base::openmode __m = ios_base::out | ios_base::in)
- : __iostream_type(), _M_stringbuf(__m)
- { this->init(&_M_stringbuf); }
- explicit
- basic_stringstream(const __string_type& __str,
- ios_base::openmode __m = ios_base::out | ios_base::in)
- : __iostream_type(), _M_stringbuf(__str, __m)
- { this->init(&_M_stringbuf); }
- ~basic_stringstream()
- { }
- __stringbuf_type*
- rdbuf() const
- { return const_cast<__stringbuf_type*>(&_M_stringbuf); }
- __string_type
- str() const
- { return _M_stringbuf.str(); }
- void
- str(const __string_type& __s)
- { _M_stringbuf.str(__s); }
- };
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template <class _CharT, class _Traits, class _Alloc>
- typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
- basic_stringbuf<_CharT, _Traits, _Alloc>::
- pbackfail(int_type __c)
- {
- int_type __ret = traits_type::eof();
- if (this->eback() < this->gptr())
- {
- const bool __testeof = traits_type::eq_int_type(__c, __ret);
- if (!__testeof)
- {
- const bool __testeq = traits_type::eq(traits_type::
- to_char_type(__c),
- this->gptr()[-1]);
- const bool __testout = this->_M_mode & ios_base::out;
- if (__testeq || __testout)
- {
- this->gbump(-1);
- if (!__testeq)
- *this->gptr() = traits_type::to_char_type(__c);
- __ret = __c;
- }
- }
- else
- {
- this->gbump(-1);
- __ret = traits_type::not_eof(__c);
- }
- }
- return __ret;
- }
- template <class _CharT, class _Traits, class _Alloc>
- typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
- basic_stringbuf<_CharT, _Traits, _Alloc>::
- overflow(int_type __c)
- {
- const bool __testout = this->_M_mode & ios_base::out;
- if (__builtin_expect(!__testout, false))
- return traits_type::eof();
- const bool __testeof = traits_type::eq_int_type(__c, traits_type::eof());
- if (__builtin_expect(__testeof, false))
- return traits_type::not_eof(__c);
- const __size_type __capacity = _M_string.capacity();
- const __size_type __max_size = _M_string.max_size();
- const bool __testput = this->pptr() < this->epptr();
- if (__builtin_expect(!__testput && __capacity == __max_size, false))
- return traits_type::eof();
- const char_type __conv = traits_type::to_char_type(__c);
- if (!__testput)
- {
- const __size_type __opt_len = std::max(__size_type(2 * __capacity),
- __size_type(512));
- const __size_type __len = std::min(__opt_len, __max_size);
- __string_type __tmp;
- __tmp.reserve(__len);
- if (this->pbase())
- __tmp.assign(this->pbase(), this->epptr() - this->pbase());
- __tmp.push_back(__conv);
- _M_string.swap(__tmp);
- _M_sync(const_cast<char_type*>(_M_string.data()),
- this->gptr() - this->eback(), this->pptr() - this->pbase());
- }
- else
- *this->pptr() = __conv;
- this->pbump(1);
- return __c;
- }
- template <class _CharT, class _Traits, class _Alloc>
- typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
- basic_stringbuf<_CharT, _Traits, _Alloc>::
- underflow()
- {
- int_type __ret = traits_type::eof();
- const bool __testin = this->_M_mode & ios_base::in;
- if (__testin)
- {
- _M_update_egptr();
- if (this->gptr() < this->egptr())
- __ret = traits_type::to_int_type(*this->gptr());
- }
- return __ret;
- }
- template <class _CharT, class _Traits, class _Alloc>
- typename basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type
- basic_stringbuf<_CharT, _Traits, _Alloc>::
- seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode)
- {
- pos_type __ret = pos_type(off_type(-1));
- bool __testin = (ios_base::in & this->_M_mode & __mode) != 0;
- bool __testout = (ios_base::out & this->_M_mode & __mode) != 0;
- const bool __testboth = __testin && __testout && __way != ios_base::cur;
- __testin &= !(__mode & ios_base::out);
- __testout &= !(__mode & ios_base::in);
- const char_type* __beg = __testin ? this->eback() : this->pbase();
- if ((__beg || !__off) && (__testin || __testout || __testboth))
- {
- _M_update_egptr();
- off_type __newoffi = __off;
- off_type __newoffo = __newoffi;
- if (__way == ios_base::cur)
- {
- __newoffi += this->gptr() - __beg;
- __newoffo += this->pptr() - __beg;
- }
- else if (__way == ios_base::end)
- __newoffo = __newoffi += this->egptr() - __beg;
- if ((__testin || __testboth)
- && __newoffi >= 0
- && this->egptr() - __beg >= __newoffi)
- {
- this->setg(this->eback(), this->eback() + __newoffi,
- this->egptr());
- __ret = pos_type(__newoffi);
- }
- if ((__testout || __testboth)
- && __newoffo >= 0
- && this->egptr() - __beg >= __newoffo)
- {
- _M_pbump(this->pbase(), this->epptr(), __newoffo);
- __ret = pos_type(__newoffo);
- }
- }
- return __ret;
- }
- template <class _CharT, class _Traits, class _Alloc>
- typename basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type
- basic_stringbuf<_CharT, _Traits, _Alloc>::
- seekpos(pos_type __sp, ios_base::openmode __mode)
- {
- pos_type __ret = pos_type(off_type(-1));
- const bool __testin = (ios_base::in & this->_M_mode & __mode) != 0;
- const bool __testout = (ios_base::out & this->_M_mode & __mode) != 0;
- const char_type* __beg = __testin ? this->eback() : this->pbase();
- if ((__beg || !off_type(__sp)) && (__testin || __testout))
- {
- _M_update_egptr();
- const off_type __pos(__sp);
- const bool __testpos = (0 <= __pos
- && __pos <= this->egptr() - __beg);
- if (__testpos)
- {
- if (__testin)
- this->setg(this->eback(), this->eback() + __pos,
- this->egptr());
- if (__testout)
- _M_pbump(this->pbase(), this->epptr(), __pos);
- __ret = __sp;
- }
- }
- return __ret;
- }
- template <class _CharT, class _Traits, class _Alloc>
- void
- basic_stringbuf<_CharT, _Traits, _Alloc>::
- _M_sync(char_type* __base, __size_type __i, __size_type __o)
- {
- const bool __testin = _M_mode & ios_base::in;
- const bool __testout = _M_mode & ios_base::out;
- char_type* __endg = __base + _M_string.size();
- char_type* __endp = __base + _M_string.capacity();
- if (__base != _M_string.data())
- {
- __endg += __i;
- __i = 0;
- __endp = __endg;
- }
- if (__testin)
- this->setg(__base, __base + __i, __endg);
- if (__testout)
- {
- _M_pbump(__base, __endp, __o);
- if (!__testin)
- this->setg(__endg, __endg, __endg);
- }
- }
- template <class _CharT, class _Traits, class _Alloc>
- void
- basic_stringbuf<_CharT, _Traits, _Alloc>::
- _M_pbump(char_type* __pbeg, char_type* __pend, off_type __off)
- {
- this->setp(__pbeg, __pend);
- while (__off > __gnu_cxx::__numeric_traits<int>::__max)
- {
- this->pbump(__gnu_cxx::__numeric_traits<int>::__max);
- __off -= __gnu_cxx::__numeric_traits<int>::__max;
- }
- this->pbump(__off);
- }
- extern template class basic_stringbuf<char>;
- extern template class basic_istringstream<char>;
- extern template class basic_ostringstream<char>;
- extern template class basic_stringstream<char>;
- extern template class basic_stringbuf<wchar_t>;
- extern template class basic_istringstream<wchar_t>;
- extern template class basic_ostringstream<wchar_t>;
- extern template class basic_stringstream<wchar_t>;
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _Tp> class complex;
- template<> class complex<float>;
- template<> class complex<double>;
- template<> class complex<long double>;
- template<typename _Tp> _Tp abs(const complex<_Tp>&);
- template<typename _Tp> _Tp arg(const complex<_Tp>&);
- template<typename _Tp> _Tp norm(const complex<_Tp>&);
- template<typename _Tp> complex<_Tp> conj(const complex<_Tp>&);
- template<typename _Tp> complex<_Tp> polar(const _Tp&, const _Tp& = 0);
- template<typename _Tp> complex<_Tp> cos(const complex<_Tp>&);
- template<typename _Tp> complex<_Tp> cosh(const complex<_Tp>&);
- template<typename _Tp> complex<_Tp> exp(const complex<_Tp>&);
- template<typename _Tp> complex<_Tp> log(const complex<_Tp>&);
- template<typename _Tp> complex<_Tp> log10(const complex<_Tp>&);
- template<typename _Tp> complex<_Tp> pow(const complex<_Tp>&, int);
- template<typename _Tp> complex<_Tp> pow(const complex<_Tp>&, const _Tp&);
- template<typename _Tp> complex<_Tp> pow(const complex<_Tp>&,
- const complex<_Tp>&);
- template<typename _Tp> complex<_Tp> pow(const _Tp&, const complex<_Tp>&);
- template<typename _Tp> complex<_Tp> sin(const complex<_Tp>&);
- template<typename _Tp> complex<_Tp> sinh(const complex<_Tp>&);
- template<typename _Tp> complex<_Tp> sqrt(const complex<_Tp>&);
- template<typename _Tp> complex<_Tp> tan(const complex<_Tp>&);
- template<typename _Tp> complex<_Tp> tanh(const complex<_Tp>&);
- template<typename _Tp>
- struct complex
- {
- typedef _Tp value_type;
- complex(const _Tp& __r = _Tp(), const _Tp& __i = _Tp())
- : _M_real(__r), _M_imag(__i) { }
- template<typename _Up>
- complex(const complex<_Up>& __z)
- : _M_real(__z.real()), _M_imag(__z.imag()) { }
- _Tp&
- real() { return _M_real; }
- const _Tp&
- real() const { return _M_real; }
- _Tp&
- imag() { return _M_imag; }
- const _Tp&
- imag() const { return _M_imag; }
- void
- real(_Tp __val) { _M_real = __val; }
- void
- imag(_Tp __val) { _M_imag = __val; }
- complex<_Tp>& operator=(const _Tp&);
- complex<_Tp>&
- operator+=(const _Tp& __t)
- {
- _M_real += __t;
- return *this;
- }
- complex<_Tp>&
- operator-=(const _Tp& __t)
- {
- _M_real -= __t;
- return *this;
- }
- complex<_Tp>& operator*=(const _Tp&);
- complex<_Tp>& operator/=(const _Tp&);
- template<typename _Up>
- complex<_Tp>& operator=(const complex<_Up>&);
- template<typename _Up>
- complex<_Tp>& operator+=(const complex<_Up>&);
- template<typename _Up>
- complex<_Tp>& operator-=(const complex<_Up>&);
- template<typename _Up>
- complex<_Tp>& operator*=(const complex<_Up>&);
- template<typename _Up>
- complex<_Tp>& operator/=(const complex<_Up>&);
- const complex __rep() const
- { return *this; }
- private:
- _Tp _M_real;
- _Tp _M_imag;
- };
- template<typename _Tp>
- complex<_Tp>&
- complex<_Tp>::operator=(const _Tp& __t)
- {
- _M_real = __t;
- _M_imag = _Tp();
- return *this;
- }
- template<typename _Tp>
- complex<_Tp>&
- complex<_Tp>::operator*=(const _Tp& __t)
- {
- _M_real *= __t;
- _M_imag *= __t;
- return *this;
- }
- template<typename _Tp>
- complex<_Tp>&
- complex<_Tp>::operator/=(const _Tp& __t)
- {
- _M_real /= __t;
- _M_imag /= __t;
- return *this;
- }
- template<typename _Tp>
- template<typename _Up>
- complex<_Tp>&
- complex<_Tp>::operator=(const complex<_Up>& __z)
- {
- _M_real = __z.real();
- _M_imag = __z.imag();
- return *this;
- }
- template<typename _Tp>
- template<typename _Up>
- complex<_Tp>&
- complex<_Tp>::operator+=(const complex<_Up>& __z)
- {
- _M_real += __z.real();
- _M_imag += __z.imag();
- return *this;
- }
- template<typename _Tp>
- template<typename _Up>
- complex<_Tp>&
- complex<_Tp>::operator-=(const complex<_Up>& __z)
- {
- _M_real -= __z.real();
- _M_imag -= __z.imag();
- return *this;
- }
- template<typename _Tp>
- template<typename _Up>
- complex<_Tp>&
- complex<_Tp>::operator*=(const complex<_Up>& __z)
- {
- const _Tp __r = _M_real * __z.real() - _M_imag * __z.imag();
- _M_imag = _M_real * __z.imag() + _M_imag * __z.real();
- _M_real = __r;
- return *this;
- }
- template<typename _Tp>
- template<typename _Up>
- complex<_Tp>&
- complex<_Tp>::operator/=(const complex<_Up>& __z)
- {
- const _Tp __r = _M_real * __z.real() + _M_imag * __z.imag();
- const _Tp __n = std::norm(__z);
- _M_imag = (_M_imag * __z.real() - _M_real * __z.imag()) / __n;
- _M_real = __r / __n;
- return *this;
- }
- template<typename _Tp>
- inline complex<_Tp>
- operator+(const complex<_Tp>& __x, const complex<_Tp>& __y)
- {
- complex<_Tp> __r = __x;
- __r += __y;
- return __r;
- }
- template<typename _Tp>
- inline complex<_Tp>
- operator+(const complex<_Tp>& __x, const _Tp& __y)
- {
- complex<_Tp> __r = __x;
- __r += __y;
- return __r;
- }
- template<typename _Tp>
- inline complex<_Tp>
- operator+(const _Tp& __x, const complex<_Tp>& __y)
- {
- complex<_Tp> __r = __y;
- __r += __x;
- return __r;
- }
- template<typename _Tp>
- inline complex<_Tp>
- operator-(const complex<_Tp>& __x, const complex<_Tp>& __y)
- {
- complex<_Tp> __r = __x;
- __r -= __y;
- return __r;
- }
- template<typename _Tp>
- inline complex<_Tp>
- operator-(const complex<_Tp>& __x, const _Tp& __y)
- {
- complex<_Tp> __r = __x;
- __r -= __y;
- return __r;
- }
- template<typename _Tp>
- inline complex<_Tp>
- operator-(const _Tp& __x, const complex<_Tp>& __y)
- {
- complex<_Tp> __r(__x, -__y.imag());
- __r -= __y.real();
- return __r;
- }
- template<typename _Tp>
- inline complex<_Tp>
- operator*(const complex<_Tp>& __x, const complex<_Tp>& __y)
- {
- complex<_Tp> __r = __x;
- __r *= __y;
- return __r;
- }
- template<typename _Tp>
- inline complex<_Tp>
- operator*(const complex<_Tp>& __x, const _Tp& __y)
- {
- complex<_Tp> __r = __x;
- __r *= __y;
- return __r;
- }
- template<typename _Tp>
- inline complex<_Tp>
- operator*(const _Tp& __x, const complex<_Tp>& __y)
- {
- complex<_Tp> __r = __y;
- __r *= __x;
- return __r;
- }
- template<typename _Tp>
- inline complex<_Tp>
- operator/(const complex<_Tp>& __x, const complex<_Tp>& __y)
- {
- complex<_Tp> __r = __x;
- __r /= __y;
- return __r;
- }
- template<typename _Tp>
- inline complex<_Tp>
- operator/(const complex<_Tp>& __x, const _Tp& __y)
- {
- complex<_Tp> __r = __x;
- __r /= __y;
- return __r;
- }
- template<typename _Tp>
- inline complex<_Tp>
- operator/(const _Tp& __x, const complex<_Tp>& __y)
- {
- complex<_Tp> __r = __x;
- __r /= __y;
- return __r;
- }
- template<typename _Tp>
- inline complex<_Tp>
- operator+(const complex<_Tp>& __x)
- { return __x; }
- template<typename _Tp>
- inline complex<_Tp>
- operator-(const complex<_Tp>& __x)
- { return complex<_Tp>(-__x.real(), -__x.imag()); }
- template<typename _Tp>
- inline bool
- operator==(const complex<_Tp>& __x, const complex<_Tp>& __y)
- { return __x.real() == __y.real() && __x.imag() == __y.imag(); }
- template<typename _Tp>
- inline bool
- operator==(const complex<_Tp>& __x, const _Tp& __y)
- { return __x.real() == __y && __x.imag() == _Tp(); }
- template<typename _Tp>
- inline bool
- operator==(const _Tp& __x, const complex<_Tp>& __y)
- { return __x == __y.real() && _Tp() == __y.imag(); }
- template<typename _Tp>
- inline bool
- operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y)
- { return __x.real() != __y.real() || __x.imag() != __y.imag(); }
- template<typename _Tp>
- inline bool
- operator!=(const complex<_Tp>& __x, const _Tp& __y)
- { return __x.real() != __y || __x.imag() != _Tp(); }
- template<typename _Tp>
- inline bool
- operator!=(const _Tp& __x, const complex<_Tp>& __y)
- { return __x != __y.real() || _Tp() != __y.imag(); }
- template<typename _Tp, typename _CharT, class _Traits>
- basic_istream<_CharT, _Traits>&
- operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)
- {
- _Tp __re_x, __im_x;
- _CharT __ch;
- __is >> __ch;
- if (__ch == '(')
- {
- __is >> __re_x >> __ch;
- if (__ch == ',')
- {
- __is >> __im_x >> __ch;
- if (__ch == ')')
- __x = complex<_Tp>(__re_x, __im_x);
- else
- __is.setstate(ios_base::failbit);
- }
- else if (__ch == ')')
- __x = __re_x;
- else
- __is.setstate(ios_base::failbit);
- }
- else
- {
- __is.putback(__ch);
- __is >> __re_x;
- __x = __re_x;
- }
- return __is;
- }
- template<typename _Tp, typename _CharT, class _Traits>
- basic_ostream<_CharT, _Traits>&
- operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x)
- {
- basic_ostringstream<_CharT, _Traits> __s;
- __s.flags(__os.flags());
- __s.imbue(__os.getloc());
- __s.precision(__os.precision());
- __s << '(' << __x.real() << ',' << __x.imag() << ')';
- return __os << __s.str();
- }
- template<typename _Tp>
- inline _Tp&
- real(complex<_Tp>& __z)
- { return __z.real(); }
- template<typename _Tp>
- inline const _Tp&
- real(const complex<_Tp>& __z)
- { return __z.real(); }
- template<typename _Tp>
- inline _Tp&
- imag(complex<_Tp>& __z)
- { return __z.imag(); }
- template<typename _Tp>
- inline const _Tp&
- imag(const complex<_Tp>& __z)
- { return __z.imag(); }
- template<typename _Tp>
- inline _Tp
- __complex_abs(const complex<_Tp>& __z)
- {
- _Tp __x = __z.real();
- _Tp __y = __z.imag();
- const _Tp __s = std::max(abs(__x), abs(__y));
- if (__s == _Tp())
- return __s;
- __x /= __s;
- __y /= __s;
- return __s * sqrt(__x * __x + __y * __y);
- }
- inline float
- __complex_abs(__complex__ float __z) { return __builtin_cabsf(__z); }
- inline double
- __complex_abs(__complex__ double __z) { return __builtin_cabs(__z); }
- inline long double
- __complex_abs(const __complex__ long double& __z)
- { return __builtin_cabsl(__z); }
- template<typename _Tp>
- inline _Tp
- abs(const complex<_Tp>& __z) { return __complex_abs(__z.__rep()); }
- template<typename _Tp>
- inline _Tp
- __complex_arg(const complex<_Tp>& __z)
- { return atan2(__z.imag(), __z.real()); }
- inline float
- __complex_arg(__complex__ float __z) { return __builtin_cargf(__z); }
- inline double
- __complex_arg(__complex__ double __z) { return __builtin_carg(__z); }
- inline long double
- __complex_arg(const __complex__ long double& __z)
- { return __builtin_cargl(__z); }
- template<typename _Tp>
- inline _Tp
- arg(const complex<_Tp>& __z) { return __complex_arg(__z.__rep()); }
- template<bool>
- struct _Norm_helper
- {
- template<typename _Tp>
- static inline _Tp _S_do_it(const complex<_Tp>& __z)
- {
- const _Tp __x = __z.real();
- const _Tp __y = __z.imag();
- return __x * __x + __y * __y;
- }
- };
- template<>
- struct _Norm_helper<true>
- {
- template<typename _Tp>
- static inline _Tp _S_do_it(const complex<_Tp>& __z)
- {
- _Tp __res = std::abs(__z);
- return __res * __res;
- }
- };
- template<typename _Tp>
- inline _Tp
- norm(const complex<_Tp>& __z)
- {
- return _Norm_helper<__is_floating<_Tp>::__value
- && !0>::_S_do_it(__z);
- }
- template<typename _Tp>
- inline complex<_Tp>
- polar(const _Tp& __rho, const _Tp& __theta)
- { return complex<_Tp>(__rho * cos(__theta), __rho * sin(__theta)); }
- template<typename _Tp>
- inline complex<_Tp>
- conj(const complex<_Tp>& __z)
- { return complex<_Tp>(__z.real(), -__z.imag()); }
- template<typename _Tp>
- inline complex<_Tp>
- __complex_cos(const complex<_Tp>& __z)
- {
- const _Tp __x = __z.real();
- const _Tp __y = __z.imag();
- return complex<_Tp>(cos(__x) * cosh(__y), -sin(__x) * sinh(__y));
- }
- inline __complex__ float
- __complex_cos(__complex__ float __z) { return __builtin_ccosf(__z); }
- inline __complex__ double
- __complex_cos(__complex__ double __z) { return __builtin_ccos(__z); }
- inline __complex__ long double
- __complex_cos(const __complex__ long double& __z)
- { return __builtin_ccosl(__z); }
- template<typename _Tp>
- inline complex<_Tp>
- cos(const complex<_Tp>& __z) { return __complex_cos(__z.__rep()); }
- template<typename _Tp>
- inline complex<_Tp>
- __complex_cosh(const complex<_Tp>& __z)
- {
- const _Tp __x = __z.real();
- const _Tp __y = __z.imag();
- return complex<_Tp>(cosh(__x) * cos(__y), sinh(__x) * sin(__y));
- }
- inline __complex__ float
- __complex_cosh(__complex__ float __z) { return __builtin_ccoshf(__z); }
- inline __complex__ double
- __complex_cosh(__complex__ double __z) { return __builtin_ccosh(__z); }
- inline __complex__ long double
- __complex_cosh(const __complex__ long double& __z)
- { return __builtin_ccoshl(__z); }
- template<typename _Tp>
- inline complex<_Tp>
- cosh(const complex<_Tp>& __z) { return __complex_cosh(__z.__rep()); }
- template<typename _Tp>
- inline complex<_Tp>
- __complex_exp(const complex<_Tp>& __z)
- { return std::polar(exp(__z.real()), __z.imag()); }
- inline __complex__ float
- __complex_exp(__complex__ float __z) { return __builtin_cexpf(__z); }
- inline __complex__ double
- __complex_exp(__complex__ double __z) { return __builtin_cexp(__z); }
- inline __complex__ long double
- __complex_exp(const __complex__ long double& __z)
- { return __builtin_cexpl(__z); }
- template<typename _Tp>
- inline complex<_Tp>
- exp(const complex<_Tp>& __z) { return __complex_exp(__z.__rep()); }
- template<typename _Tp>
- inline complex<_Tp>
- __complex_log(const complex<_Tp>& __z)
- { return complex<_Tp>(log(std::abs(__z)), std::arg(__z)); }
- inline __complex__ float
- __complex_log(__complex__ float __z) { return __builtin_clogf(__z); }
- inline __complex__ double
- __complex_log(__complex__ double __z) { return __builtin_clog(__z); }
- inline __complex__ long double
- __complex_log(const __complex__ long double& __z)
- { return __builtin_clogl(__z); }
- template<typename _Tp>
- inline complex<_Tp>
- log(const complex<_Tp>& __z) { return __complex_log(__z.__rep()); }
- template<typename _Tp>
- inline complex<_Tp>
- log10(const complex<_Tp>& __z)
- { return std::log(__z) / log(_Tp(10.0)); }
- template<typename _Tp>
- inline complex<_Tp>
- __complex_sin(const complex<_Tp>& __z)
- {
- const _Tp __x = __z.real();
- const _Tp __y = __z.imag();
- return complex<_Tp>(sin(__x) * cosh(__y), cos(__x) * sinh(__y));
- }
- inline __complex__ float
- __complex_sin(__complex__ float __z) { return __builtin_csinf(__z); }
- inline __complex__ double
- __complex_sin(__complex__ double __z) { return __builtin_csin(__z); }
- inline __complex__ long double
- __complex_sin(const __complex__ long double& __z)
- { return __builtin_csinl(__z); }
- template<typename _Tp>
- inline complex<_Tp>
- sin(const complex<_Tp>& __z) { return __complex_sin(__z.__rep()); }
- template<typename _Tp>
- inline complex<_Tp>
- __complex_sinh(const complex<_Tp>& __z)
- {
- const _Tp __x = __z.real();
- const _Tp __y = __z.imag();
- return complex<_Tp>(sinh(__x) * cos(__y), cosh(__x) * sin(__y));
- }
- inline __complex__ float
- __complex_sinh(__complex__ float __z) { return __builtin_csinhf(__z); }
- inline __complex__ double
- __complex_sinh(__complex__ double __z) { return __builtin_csinh(__z); }
- inline __complex__ long double
- __complex_sinh(const __complex__ long double& __z)
- { return __builtin_csinhl(__z); }
- template<typename _Tp>
- inline complex<_Tp>
- sinh(const complex<_Tp>& __z) { return __complex_sinh(__z.__rep()); }
- template<typename _Tp>
- complex<_Tp>
- __complex_sqrt(const complex<_Tp>& __z)
- {
- _Tp __x = __z.real();
- _Tp __y = __z.imag();
- if (__x == _Tp())
- {
- _Tp __t = sqrt(abs(__y) / 2);
- return complex<_Tp>(__t, __y < _Tp() ? -__t : __t);
- }
- else
- {
- _Tp __t = sqrt(2 * (std::abs(__z) + abs(__x)));
- _Tp __u = __t / 2;
- return __x > _Tp()
- ? complex<_Tp>(__u, __y / __t)
- : complex<_Tp>(abs(__y) / __t, __y < _Tp() ? -__u : __u);
- }
- }
- inline __complex__ float
- __complex_sqrt(__complex__ float __z) { return __builtin_csqrtf(__z); }
- inline __complex__ double
- __complex_sqrt(__complex__ double __z) { return __builtin_csqrt(__z); }
- inline __complex__ long double
- __complex_sqrt(const __complex__ long double& __z)
- { return __builtin_csqrtl(__z); }
- template<typename _Tp>
- inline complex<_Tp>
- sqrt(const complex<_Tp>& __z) { return __complex_sqrt(__z.__rep()); }
- template<typename _Tp>
- inline complex<_Tp>
- __complex_tan(const complex<_Tp>& __z)
- { return std::sin(__z) / std::cos(__z); }
- inline __complex__ float
- __complex_tan(__complex__ float __z) { return __builtin_ctanf(__z); }
- inline __complex__ double
- __complex_tan(__complex__ double __z) { return __builtin_ctan(__z); }
- inline __complex__ long double
- __complex_tan(const __complex__ long double& __z)
- { return __builtin_ctanl(__z); }
- template<typename _Tp>
- inline complex<_Tp>
- tan(const complex<_Tp>& __z) { return __complex_tan(__z.__rep()); }
- template<typename _Tp>
- inline complex<_Tp>
- __complex_tanh(const complex<_Tp>& __z)
- { return std::sinh(__z) / std::cosh(__z); }
- inline __complex__ float
- __complex_tanh(__complex__ float __z) { return __builtin_ctanhf(__z); }
- inline __complex__ double
- __complex_tanh(__complex__ double __z) { return __builtin_ctanh(__z); }
- inline __complex__ long double
- __complex_tanh(const __complex__ long double& __z)
- { return __builtin_ctanhl(__z); }
- template<typename _Tp>
- inline complex<_Tp>
- tanh(const complex<_Tp>& __z) { return __complex_tanh(__z.__rep()); }
- template<typename _Tp>
- complex<_Tp>
- __complex_pow_unsigned(complex<_Tp> __x, unsigned __n)
- {
- complex<_Tp> __y = __n % 2 ? __x : complex<_Tp>(1);
- while (__n >>= 1)
- {
- __x *= __x;
- if (__n % 2)
- __y *= __x;
- }
- return __y;
- }
- template<typename _Tp>
- inline complex<_Tp>
- pow(const complex<_Tp>& __z, int __n)
- {
- return __n < 0
- ? complex<_Tp>(1) / std::__complex_pow_unsigned(__z, -__n)
- : std::__complex_pow_unsigned(__z, __n);
- }
- template<typename _Tp>
- complex<_Tp>
- pow(const complex<_Tp>& __x, const _Tp& __y)
- {
- if (__x.imag() == _Tp() && __x.real() > _Tp())
- return pow(__x.real(), __y);
- complex<_Tp> __t = std::log(__x);
- return std::polar(exp(__y * __t.real()), __y * __t.imag());
- }
- template<typename _Tp>
- inline complex<_Tp>
- __complex_pow(const complex<_Tp>& __x, const complex<_Tp>& __y)
- { return __x == _Tp() ? _Tp() : std::exp(__y * std::log(__x)); }
- inline __complex__ float
- __complex_pow(__complex__ float __x, __complex__ float __y)
- { return __builtin_cpowf(__x, __y); }
- inline __complex__ double
- __complex_pow(__complex__ double __x, __complex__ double __y)
- { return __builtin_cpow(__x, __y); }
- inline __complex__ long double
- __complex_pow(const __complex__ long double& __x,
- const __complex__ long double& __y)
- { return __builtin_cpowl(__x, __y); }
- template<typename _Tp>
- inline complex<_Tp>
- pow(const complex<_Tp>& __x, const complex<_Tp>& __y)
- { return __complex_pow(__x.__rep(), __y.__rep()); }
- template<typename _Tp>
- inline complex<_Tp>
- pow(const _Tp& __x, const complex<_Tp>& __y)
- {
- return __x > _Tp() ? std::polar(pow(__x, __y.real()),
- __y.imag() * log(__x))
- : std::pow(complex<_Tp>(__x), __y);
- }
- template<>
- struct complex<float>
- {
- typedef float value_type;
- typedef __complex__ float _ComplexT;
- complex(_ComplexT __z) : _M_value(__z) { }
- complex(float __r = 0.0f, float __i = 0.0f)
- {
- __real__ _M_value = __r;
- __imag__ _M_value = __i;
- }
- explicit complex(const complex<double>&);
- explicit complex(const complex<long double>&);
- float&
- real() { return __real__ _M_value; }
- const float&
- real() const { return __real__ _M_value; }
- float&
- imag() { return __imag__ _M_value; }
- const float&
- imag() const { return __imag__ _M_value; }
- void
- real(float __val) { __real__ _M_value = __val; }
- void
- imag(float __val) { __imag__ _M_value = __val; }
- complex&
- operator=(float __f)
- {
- _M_value = __f;
- return *this;
- }
- complex&
- operator+=(float __f)
- {
- _M_value += __f;
- return *this;
- }
- complex&
- operator-=(float __f)
- {
- _M_value -= __f;
- return *this;
- }
- complex&
- operator*=(float __f)
- {
- _M_value *= __f;
- return *this;
- }
- complex&
- operator/=(float __f)
- {
- _M_value /= __f;
- return *this;
- }
- template<typename _Tp>
- complex&
- operator=(const complex<_Tp>& __z)
- {
- __real__ _M_value = __z.real();
- __imag__ _M_value = __z.imag();
- return *this;
- }
- template<typename _Tp>
- complex&
- operator+=(const complex<_Tp>& __z)
- {
- __real__ _M_value += __z.real();
- __imag__ _M_value += __z.imag();
- return *this;
- }
- template<class _Tp>
- complex&
- operator-=(const complex<_Tp>& __z)
- {
- __real__ _M_value -= __z.real();
- __imag__ _M_value -= __z.imag();
- return *this;
- }
- template<class _Tp>
- complex&
- operator*=(const complex<_Tp>& __z)
- {
- _ComplexT __t;
- __real__ __t = __z.real();
- __imag__ __t = __z.imag();
- _M_value *= __t;
- return *this;
- }
- template<class _Tp>
- complex&
- operator/=(const complex<_Tp>& __z)
- {
- _ComplexT __t;
- __real__ __t = __z.real();
- __imag__ __t = __z.imag();
- _M_value /= __t;
- return *this;
- }
- const _ComplexT __rep() const { return _M_value; }
- private:
- _ComplexT _M_value;
- };
- template<>
- struct complex<double>
- {
- typedef double value_type;
- typedef __complex__ double _ComplexT;
- complex(_ComplexT __z) : _M_value(__z) { }
- complex(double __r = 0.0, double __i = 0.0)
- {
- __real__ _M_value = __r;
- __imag__ _M_value = __i;
- }
- complex(const complex<float>& __z)
- : _M_value(__z.__rep()) { }
- explicit complex(const complex<long double>&);
- double&
- real() { return __real__ _M_value; }
- const double&
- real() const { return __real__ _M_value; }
- double&
- imag() { return __imag__ _M_value; }
- const double&
- imag() const { return __imag__ _M_value; }
- void
- real(double __val) { __real__ _M_value = __val; }
- void
- imag(double __val) { __imag__ _M_value = __val; }
- complex&
- operator=(double __d)
- {
- _M_value = __d;
- return *this;
- }
- complex&
- operator+=(double __d)
- {
- _M_value += __d;
- return *this;
- }
- complex&
- operator-=(double __d)
- {
- _M_value -= __d;
- return *this;
- }
- complex&
- operator*=(double __d)
- {
- _M_value *= __d;
- return *this;
- }
- complex&
- operator/=(double __d)
- {
- _M_value /= __d;
- return *this;
- }
- template<typename _Tp>
- complex&
- operator=(const complex<_Tp>& __z)
- {
- __real__ _M_value = __z.real();
- __imag__ _M_value = __z.imag();
- return *this;
- }
- template<typename _Tp>
- complex&
- operator+=(const complex<_Tp>& __z)
- {
- __real__ _M_value += __z.real();
- __imag__ _M_value += __z.imag();
- return *this;
- }
- template<typename _Tp>
- complex&
- operator-=(const complex<_Tp>& __z)
- {
- __real__ _M_value -= __z.real();
- __imag__ _M_value -= __z.imag();
- return *this;
- }
- template<typename _Tp>
- complex&
- operator*=(const complex<_Tp>& __z)
- {
- _ComplexT __t;
- __real__ __t = __z.real();
- __imag__ __t = __z.imag();
- _M_value *= __t;
- return *this;
- }
- template<typename _Tp>
- complex&
- operator/=(const complex<_Tp>& __z)
- {
- _ComplexT __t;
- __real__ __t = __z.real();
- __imag__ __t = __z.imag();
- _M_value /= __t;
- return *this;
- }
- const _ComplexT __rep() const { return _M_value; }
- private:
- _ComplexT _M_value;
- };
- template<>
- struct complex<long double>
- {
- typedef long double value_type;
- typedef __complex__ long double _ComplexT;
- complex(_ComplexT __z) : _M_value(__z) { }
- complex(long double __r = 0.0L,
- long double __i = 0.0L)
- {
- __real__ _M_value = __r;
- __imag__ _M_value = __i;
- }
- complex(const complex<float>& __z)
- : _M_value(__z.__rep()) { }
- complex(const complex<double>& __z)
- : _M_value(__z.__rep()) { }
- long double&
- real() { return __real__ _M_value; }
- const long double&
- real() const { return __real__ _M_value; }
- long double&
- imag() { return __imag__ _M_value; }
- const long double&
- imag() const { return __imag__ _M_value; }
- void
- real(long double __val) { __real__ _M_value = __val; }
- void
- imag(long double __val) { __imag__ _M_value = __val; }
- complex&
- operator=(long double __r)
- {
- _M_value = __r;
- return *this;
- }
- complex&
- operator+=(long double __r)
- {
- _M_value += __r;
- return *this;
- }
- complex&
- operator-=(long double __r)
- {
- _M_value -= __r;
- return *this;
- }
- complex&
- operator*=(long double __r)
- {
- _M_value *= __r;
- return *this;
- }
- complex&
- operator/=(long double __r)
- {
- _M_value /= __r;
- return *this;
- }
- template<typename _Tp>
- complex&
- operator=(const complex<_Tp>& __z)
- {
- __real__ _M_value = __z.real();
- __imag__ _M_value = __z.imag();
- return *this;
- }
- template<typename _Tp>
- complex&
- operator+=(const complex<_Tp>& __z)
- {
- __real__ _M_value += __z.real();
- __imag__ _M_value += __z.imag();
- return *this;
- }
- template<typename _Tp>
- complex&
- operator-=(const complex<_Tp>& __z)
- {
- __real__ _M_value -= __z.real();
- __imag__ _M_value -= __z.imag();
- return *this;
- }
- template<typename _Tp>
- complex&
- operator*=(const complex<_Tp>& __z)
- {
- _ComplexT __t;
- __real__ __t = __z.real();
- __imag__ __t = __z.imag();
- _M_value *= __t;
- return *this;
- }
- template<typename _Tp>
- complex&
- operator/=(const complex<_Tp>& __z)
- {
- _ComplexT __t;
- __real__ __t = __z.real();
- __imag__ __t = __z.imag();
- _M_value /= __t;
- return *this;
- }
- const _ComplexT __rep() const { return _M_value; }
- private:
- _ComplexT _M_value;
- };
- inline
- complex<float>::complex(const complex<double>& __z)
- : _M_value(__z.__rep()) { }
- inline
- complex<float>::complex(const complex<long double>& __z)
- : _M_value(__z.__rep()) { }
- inline
- complex<double>::complex(const complex<long double>& __z)
- : _M_value(__z.__rep()) { }
- extern template istream& operator>>(istream&, complex<float>&);
- extern template ostream& operator<<(ostream&, const complex<float>&);
- extern template istream& operator>>(istream&, complex<double>&);
- extern template ostream& operator<<(ostream&, const complex<double>&);
- extern template istream& operator>>(istream&, complex<long double>&);
- extern template ostream& operator<<(ostream&, const complex<long double>&);
- extern template wistream& operator>>(wistream&, complex<float>&);
- extern template wostream& operator<<(wostream&, const complex<float>&);
- extern template wistream& operator>>(wistream&, complex<double>&);
- extern template wostream& operator<<(wostream&, const complex<double>&);
- extern template wistream& operator>>(wistream&, complex<long double>&);
- extern template wostream& operator<<(wostream&, const complex<long double>&);
-}
-namespace __gnu_cxx __attribute__ ((__visibility__ ("default")))
-{
- template<typename _Tp, typename _Up>
- struct __promote_2<std::complex<_Tp>, _Up>
- {
- public:
- typedef std::complex<typename __promote_2<_Tp, _Up>::__type> __type;
- };
- template<typename _Tp, typename _Up>
- struct __promote_2<_Tp, std::complex<_Up> >
- {
- public:
- typedef std::complex<typename __promote_2<_Tp, _Up>::__type> __type;
- };
- template<typename _Tp, typename _Up>
- struct __promote_2<std::complex<_Tp>, std::complex<_Up> >
- {
- public:
- typedef std::complex<typename __promote_2<_Tp, _Up>::__type> __type;
- };
-}
-#pragma GCC visibility push(default)
-extern "C++" {
-namespace __cxxabiv1
-{
- class __class_type_info;
-}
-namespace std
-{
- class type_info
- {
- public:
- virtual ~type_info();
- const char* name() const
- { return __name[0] == '*' ? __name + 1 : __name; }
- bool before(const type_info& __arg) const
- { return (__name[0] == '*' && __arg.__name[0] == '*')
- ? __name < __arg.__name
- : __builtin_strcmp (__name, __arg.__name) < 0; }
- bool operator==(const type_info& __arg) const
- {
- return ((__name == __arg.__name)
- || (__name[0] != '*' &&
- __builtin_strcmp (__name, __arg.__name) == 0));
- }
- bool operator!=(const type_info& __arg) const
- { return !operator==(__arg); }
- virtual bool __is_pointer_p() const;
- virtual bool __is_function_p() const;
- virtual bool __do_catch(const type_info *__thr_type, void **__thr_obj,
- unsigned __outer) const;
- virtual bool __do_upcast(const __cxxabiv1::__class_type_info *__target,
- void **__obj_ptr) const;
- protected:
- const char *__name;
- explicit type_info(const char *__n): __name(__n) { }
- private:
- type_info& operator=(const type_info&);
- type_info(const type_info&);
- };
- class bad_cast : public exception
- {
- public:
- bad_cast() throw() { }
- virtual ~bad_cast() throw();
- virtual const char* what() const throw();
- };
- class bad_typeid : public exception
- {
- public:
- bad_typeid () throw() { }
- virtual ~bad_typeid() throw();
- virtual const char* what() const throw();
- };
-}
-#pragma GCC visibility pop
-}
-typedef long int ptrdiff_t;
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- extern istream cin;
- extern ostream cout;
- extern ostream cerr;
- extern ostream clog;
- extern wistream wcin;
- extern wostream wcout;
- extern wostream wcerr;
- extern wostream wclog;
- static ios_base::Init __ioinit;
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- class codecvt_base
- {
- public:
- enum result
- {
- ok,
- partial,
- error,
- noconv
- };
- };
- template<typename _InternT, typename _ExternT, typename _StateT>
- class __codecvt_abstract_base
- : public locale::facet, public codecvt_base
- {
- public:
- typedef codecvt_base::result result;
- typedef _InternT intern_type;
- typedef _ExternT extern_type;
- typedef _StateT state_type;
- result
- out(state_type& __state, const intern_type* __from,
- const intern_type* __from_end, const intern_type*& __from_next,
- extern_type* __to, extern_type* __to_end,
- extern_type*& __to_next) const
- {
- return this->do_out(__state, __from, __from_end, __from_next,
- __to, __to_end, __to_next);
- }
- result
- unshift(state_type& __state, extern_type* __to, extern_type* __to_end,
- extern_type*& __to_next) const
- { return this->do_unshift(__state, __to,__to_end,__to_next); }
- result
- in(state_type& __state, const extern_type* __from,
- const extern_type* __from_end, const extern_type*& __from_next,
- intern_type* __to, intern_type* __to_end,
- intern_type*& __to_next) const
- {
- return this->do_in(__state, __from, __from_end, __from_next,
- __to, __to_end, __to_next);
- }
- int
- encoding() const throw()
- { return this->do_encoding(); }
- bool
- always_noconv() const throw()
- { return this->do_always_noconv(); }
- int
- length(state_type& __state, const extern_type* __from,
- const extern_type* __end, size_t __max) const
- { return this->do_length(__state, __from, __end, __max); }
- int
- max_length() const throw()
- { return this->do_max_length(); }
- protected:
- explicit
- __codecvt_abstract_base(size_t __refs = 0) : locale::facet(__refs) { }
- virtual
- ~__codecvt_abstract_base() { }
- virtual result
- do_out(state_type& __state, const intern_type* __from,
- const intern_type* __from_end, const intern_type*& __from_next,
- extern_type* __to, extern_type* __to_end,
- extern_type*& __to_next) const = 0;
- virtual result
- do_unshift(state_type& __state, extern_type* __to,
- extern_type* __to_end, extern_type*& __to_next) const = 0;
- virtual result
- do_in(state_type& __state, const extern_type* __from,
- const extern_type* __from_end, const extern_type*& __from_next,
- intern_type* __to, intern_type* __to_end,
- intern_type*& __to_next) const = 0;
- virtual int
- do_encoding() const throw() = 0;
- virtual bool
- do_always_noconv() const throw() = 0;
- virtual int
- do_length(state_type&, const extern_type* __from,
- const extern_type* __end, size_t __max) const = 0;
- virtual int
- do_max_length() const throw() = 0;
- };
- template<typename _InternT, typename _ExternT, typename _StateT>
- class codecvt
- : public __codecvt_abstract_base<_InternT, _ExternT, _StateT>
- {
- public:
- typedef codecvt_base::result result;
- typedef _InternT intern_type;
- typedef _ExternT extern_type;
- typedef _StateT state_type;
- protected:
- __c_locale _M_c_locale_codecvt;
- public:
- static locale::id id;
- explicit
- codecvt(size_t __refs = 0)
- : __codecvt_abstract_base<_InternT, _ExternT, _StateT> (__refs) { }
- explicit
- codecvt(__c_locale __cloc, size_t __refs = 0);
- protected:
- virtual
- ~codecvt() { }
- virtual result
- do_out(state_type& __state, const intern_type* __from,
- const intern_type* __from_end, const intern_type*& __from_next,
- extern_type* __to, extern_type* __to_end,
- extern_type*& __to_next) const;
- virtual result
- do_unshift(state_type& __state, extern_type* __to,
- extern_type* __to_end, extern_type*& __to_next) const;
- virtual result
- do_in(state_type& __state, const extern_type* __from,
- const extern_type* __from_end, const extern_type*& __from_next,
- intern_type* __to, intern_type* __to_end,
- intern_type*& __to_next) const;
- virtual int
- do_encoding() const throw();
- virtual bool
- do_always_noconv() const throw();
- virtual int
- do_length(state_type&, const extern_type* __from,
- const extern_type* __end, size_t __max) const;
- virtual int
- do_max_length() const throw();
- };
- template<typename _InternT, typename _ExternT, typename _StateT>
- locale::id codecvt<_InternT, _ExternT, _StateT>::id;
- template<>
- class codecvt<char, char, mbstate_t>
- : public __codecvt_abstract_base<char, char, mbstate_t>
- {
- public:
- typedef char intern_type;
- typedef char extern_type;
- typedef mbstate_t state_type;
- protected:
- __c_locale _M_c_locale_codecvt;
- public:
- static locale::id id;
- explicit
- codecvt(size_t __refs = 0);
- explicit
- codecvt(__c_locale __cloc, size_t __refs = 0);
- protected:
- virtual
- ~codecvt();
- virtual result
- do_out(state_type& __state, const intern_type* __from,
- const intern_type* __from_end, const intern_type*& __from_next,
- extern_type* __to, extern_type* __to_end,
- extern_type*& __to_next) const;
- virtual result
- do_unshift(state_type& __state, extern_type* __to,
- extern_type* __to_end, extern_type*& __to_next) const;
- virtual result
- do_in(state_type& __state, const extern_type* __from,
- const extern_type* __from_end, const extern_type*& __from_next,
- intern_type* __to, intern_type* __to_end,
- intern_type*& __to_next) const;
- virtual int
- do_encoding() const throw();
- virtual bool
- do_always_noconv() const throw();
- virtual int
- do_length(state_type&, const extern_type* __from,
- const extern_type* __end, size_t __max) const;
- virtual int
- do_max_length() const throw();
- };
- template<>
- class codecvt<wchar_t, char, mbstate_t>
- : public __codecvt_abstract_base<wchar_t, char, mbstate_t>
- {
- public:
- typedef wchar_t intern_type;
- typedef char extern_type;
- typedef mbstate_t state_type;
- protected:
- __c_locale _M_c_locale_codecvt;
- public:
- static locale::id id;
- explicit
- codecvt(size_t __refs = 0);
- explicit
- codecvt(__c_locale __cloc, size_t __refs = 0);
- protected:
- virtual
- ~codecvt();
- virtual result
- do_out(state_type& __state, const intern_type* __from,
- const intern_type* __from_end, const intern_type*& __from_next,
- extern_type* __to, extern_type* __to_end,
- extern_type*& __to_next) const;
- virtual result
- do_unshift(state_type& __state,
- extern_type* __to, extern_type* __to_end,
- extern_type*& __to_next) const;
- virtual result
- do_in(state_type& __state,
- const extern_type* __from, const extern_type* __from_end,
- const extern_type*& __from_next,
- intern_type* __to, intern_type* __to_end,
- intern_type*& __to_next) const;
- virtual
- int do_encoding() const throw();
- virtual
- bool do_always_noconv() const throw();
- virtual
- int do_length(state_type&, const extern_type* __from,
- const extern_type* __end, size_t __max) const;
- virtual int
- do_max_length() const throw();
- };
- template<typename _InternT, typename _ExternT, typename _StateT>
- class codecvt_byname : public codecvt<_InternT, _ExternT, _StateT>
- {
- public:
- explicit
- codecvt_byname(const char* __s, size_t __refs = 0)
- : codecvt<_InternT, _ExternT, _StateT>(__refs)
- {
- if (__builtin_strcmp(__s, "C") != 0
- && __builtin_strcmp(__s, "POSIX") != 0)
- {
- this->_S_destroy_c_locale(this->_M_c_locale_codecvt);
- this->_S_create_c_locale(this->_M_c_locale_codecvt, __s);
- }
- }
- protected:
- virtual
- ~codecvt_byname() { }
- };
- extern template class codecvt_byname<char, char, mbstate_t>;
- extern template
- const codecvt<char, char, mbstate_t>&
- use_facet<codecvt<char, char, mbstate_t> >(const locale&);
- extern template
- bool
- has_facet<codecvt<char, char, mbstate_t> >(const locale&);
- extern template class codecvt_byname<wchar_t, char, mbstate_t>;
- extern template
- const codecvt<wchar_t, char, mbstate_t>&
- use_facet<codecvt<wchar_t, char, mbstate_t> >(const locale&);
- extern template
- bool
- has_facet<codecvt<wchar_t, char, mbstate_t> >(const locale&);
-}
-extern "C" {
-typedef struct
-{
- __off_t __pos;
- __mbstate_t __state;
-} _G_fpos_t;
-typedef struct
-{
- __off64_t __pos;
- __mbstate_t __state;
-} _G_fpos64_t;
-typedef int _G_int16_t __attribute__ ((__mode__ (__HI__)));
-typedef int _G_int32_t __attribute__ ((__mode__ (__SI__)));
-typedef unsigned int _G_uint16_t __attribute__ ((__mode__ (__HI__)));
-typedef unsigned int _G_uint32_t __attribute__ ((__mode__ (__SI__)));
-struct _IO_jump_t; struct _IO_FILE;
-typedef void _IO_lock_t;
-struct _IO_marker {
- struct _IO_marker *_next;
- struct _IO_FILE *_sbuf;
- int _pos;
-};
-enum __codecvt_result
-{
- __codecvt_ok,
- __codecvt_partial,
- __codecvt_error,
- __codecvt_noconv
-};
-struct _IO_FILE {
- int _flags;
- char* _IO_read_ptr;
- char* _IO_read_end;
- char* _IO_read_base;
- char* _IO_write_base;
- char* _IO_write_ptr;
- char* _IO_write_end;
- char* _IO_buf_base;
- char* _IO_buf_end;
- char *_IO_save_base;
- char *_IO_backup_base;
- char *_IO_save_end;
- struct _IO_marker *_markers;
- struct _IO_FILE *_chain;
- int _fileno;
- int _flags2;
- __off_t _old_offset;
- unsigned short _cur_column;
- signed char _vtable_offset;
- char _shortbuf[1];
- _IO_lock_t *_lock;
- __off64_t _offset;
- void *__pad1;
- void *__pad2;
- void *__pad3;
- void *__pad4;
- size_t __pad5;
- int _mode;
- char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)];
-};
-struct _IO_FILE_plus;
-extern struct _IO_FILE_plus _IO_2_1_stdin_;
-extern struct _IO_FILE_plus _IO_2_1_stdout_;
-extern struct _IO_FILE_plus _IO_2_1_stderr_;
-typedef __ssize_t __io_read_fn (void *__cookie, char *__buf, size_t __nbytes);
-typedef __ssize_t __io_write_fn (void *__cookie, __const char *__buf,
- size_t __n);
-typedef int __io_seek_fn (void *__cookie, __off64_t *__pos, int __w);
-typedef int __io_close_fn (void *__cookie);
-typedef __io_read_fn cookie_read_function_t;
-typedef __io_write_fn cookie_write_function_t;
-typedef __io_seek_fn cookie_seek_function_t;
-typedef __io_close_fn cookie_close_function_t;
-typedef struct
-{
- __io_read_fn *read;
- __io_write_fn *write;
- __io_seek_fn *seek;
- __io_close_fn *close;
-} _IO_cookie_io_functions_t;
-typedef _IO_cookie_io_functions_t cookie_io_functions_t;
-struct _IO_cookie_file;
-extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write,
- void *__cookie, _IO_cookie_io_functions_t __fns);
-extern "C" {
-extern int __underflow (_IO_FILE *);
-extern int __uflow (_IO_FILE *);
-extern int __overflow (_IO_FILE *, int);
-extern int _IO_getc (_IO_FILE *__fp);
-extern int _IO_putc (int __c, _IO_FILE *__fp);
-extern int _IO_feof (_IO_FILE *__fp) throw ();
-extern int _IO_ferror (_IO_FILE *__fp) throw ();
-extern int _IO_peekc_locked (_IO_FILE *__fp);
-extern void _IO_flockfile (_IO_FILE *) throw ();
-extern void _IO_funlockfile (_IO_FILE *) throw ();
-extern int _IO_ftrylockfile (_IO_FILE *) throw ();
-extern int _IO_vfscanf (_IO_FILE * __restrict, const char * __restrict,
- __gnuc_va_list, int *__restrict);
-extern int _IO_vfprintf (_IO_FILE *__restrict, const char *__restrict,
- __gnuc_va_list);
-extern __ssize_t _IO_padn (_IO_FILE *, int, __ssize_t);
-extern size_t _IO_sgetn (_IO_FILE *, void *, size_t);
-extern __off64_t _IO_seekoff (_IO_FILE *, __off64_t, int, int);
-extern __off64_t _IO_seekpos (_IO_FILE *, __off64_t, int);
-extern void _IO_free_backup_area (_IO_FILE *) throw ();
-}
-typedef __gnuc_va_list va_list;
-typedef _G_fpos_t fpos_t;
-typedef _G_fpos64_t fpos64_t;
-extern struct _IO_FILE *stdin;
-extern struct _IO_FILE *stdout;
-extern struct _IO_FILE *stderr;
-extern int remove (__const char *__filename) throw ();
-extern int rename (__const char *__old, __const char *__new) throw ();
-extern int renameat (int __oldfd, __const char *__old, int __newfd,
- __const char *__new) throw ();
-extern FILE *tmpfile (void) ;
-extern FILE *tmpfile64 (void) ;
-extern char *tmpnam (char *__s) throw () ;
-extern char *tmpnam_r (char *__s) throw () ;
-extern char *tempnam (__const char *__dir, __const char *__pfx)
- throw () __attribute__ ((__malloc__)) ;
-extern int fclose (FILE *__stream);
-extern int fflush (FILE *__stream);
-extern int fflush_unlocked (FILE *__stream);
-extern int fcloseall (void);
-extern FILE *fopen (__const char *__restrict __filename,
- __const char *__restrict __modes) ;
-extern FILE *freopen (__const char *__restrict __filename,
- __const char *__restrict __modes,
- FILE *__restrict __stream) ;
-extern FILE *fopen64 (__const char *__restrict __filename,
- __const char *__restrict __modes) ;
-extern FILE *freopen64 (__const char *__restrict __filename,
- __const char *__restrict __modes,
- FILE *__restrict __stream) ;
-extern FILE *fdopen (int __fd, __const char *__modes) throw () ;
-extern FILE *fopencookie (void *__restrict __magic_cookie,
- __const char *__restrict __modes,
- _IO_cookie_io_functions_t __io_funcs) throw () ;
-extern FILE *fmemopen (void *__s, size_t __len, __const char *__modes)
- throw () ;
-extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) throw () ;
-extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) throw ();
-extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
- int __modes, size_t __n) throw ();
-extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
- size_t __size) throw ();
-extern void setlinebuf (FILE *__stream) throw ();
-extern int fprintf (FILE *__restrict __stream,
- __const char *__restrict __format, ...);
-extern int printf (__const char *__restrict __format, ...);
-extern int sprintf (char *__restrict __s,
- __const char *__restrict __format, ...) throw ();
-extern int vfprintf (FILE *__restrict __s, __const char *__restrict __format,
- __gnuc_va_list __arg);
-extern int vprintf (__const char *__restrict __format, __gnuc_va_list __arg);
-extern int vsprintf (char *__restrict __s, __const char *__restrict __format,
- __gnuc_va_list __arg) throw ();
-extern int snprintf (char *__restrict __s, size_t __maxlen,
- __const char *__restrict __format, ...)
- throw () __attribute__ ((__format__ (__printf__, 3, 4)));
-extern int vsnprintf (char *__restrict __s, size_t __maxlen,
- __const char *__restrict __format, __gnuc_va_list __arg)
- throw () __attribute__ ((__format__ (__printf__, 3, 0)));
-extern int vasprintf (char **__restrict __ptr, __const char *__restrict __f,
- __gnuc_va_list __arg)
- throw () __attribute__ ((__format__ (__printf__, 2, 0))) ;
-extern int __asprintf (char **__restrict __ptr,
- __const char *__restrict __fmt, ...)
- throw () __attribute__ ((__format__ (__printf__, 2, 3))) ;
-extern int asprintf (char **__restrict __ptr,
- __const char *__restrict __fmt, ...)
- throw () __attribute__ ((__format__ (__printf__, 2, 3))) ;
-extern int vdprintf (int __fd, __const char *__restrict __fmt,
- __gnuc_va_list __arg)
- __attribute__ ((__format__ (__printf__, 2, 0)));
-extern int dprintf (int __fd, __const char *__restrict __fmt, ...)
- __attribute__ ((__format__ (__printf__, 2, 3)));
-extern int fscanf (FILE *__restrict __stream,
- __const char *__restrict __format, ...) ;
-extern int scanf (__const char *__restrict __format, ...) ;
-extern int sscanf (__const char *__restrict __s,
- __const char *__restrict __format, ...) throw ();
-extern int vfscanf (FILE *__restrict __s, __const char *__restrict __format,
- __gnuc_va_list __arg)
- __attribute__ ((__format__ (__scanf__, 2, 0))) ;
-extern int vscanf (__const char *__restrict __format, __gnuc_va_list __arg)
- __attribute__ ((__format__ (__scanf__, 1, 0))) ;
-extern int vsscanf (__const char *__restrict __s,
- __const char *__restrict __format, __gnuc_va_list __arg)
- throw () __attribute__ ((__format__ (__scanf__, 2, 0)));
-extern int fgetc (FILE *__stream);
-extern int getc (FILE *__stream);
-extern int getchar (void);
-extern int getc_unlocked (FILE *__stream);
-extern int getchar_unlocked (void);
-extern int fgetc_unlocked (FILE *__stream);
-extern int fputc (int __c, FILE *__stream);
-extern int putc (int __c, FILE *__stream);
-extern int putchar (int __c);
-extern int fputc_unlocked (int __c, FILE *__stream);
-extern int putc_unlocked (int __c, FILE *__stream);
-extern int putchar_unlocked (int __c);
-extern int getw (FILE *__stream);
-extern int putw (int __w, FILE *__stream);
-extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
- ;
-extern char *gets (char *__s) ;
-extern char *fgets_unlocked (char *__restrict __s, int __n,
- FILE *__restrict __stream) ;
-extern __ssize_t __getdelim (char **__restrict __lineptr,
- size_t *__restrict __n, int __delimiter,
- FILE *__restrict __stream) ;
-extern __ssize_t getdelim (char **__restrict __lineptr,
- size_t *__restrict __n, int __delimiter,
- FILE *__restrict __stream) ;
-extern __ssize_t getline (char **__restrict __lineptr,
- size_t *__restrict __n,
- FILE *__restrict __stream) ;
-extern int fputs (__const char *__restrict __s, FILE *__restrict __stream);
-extern int puts (__const char *__s);
-extern int ungetc (int __c, FILE *__stream);
-extern size_t fread (void *__restrict __ptr, size_t __size,
- size_t __n, FILE *__restrict __stream) ;
-extern size_t fwrite (__const void *__restrict __ptr, size_t __size,
- size_t __n, FILE *__restrict __s);
-extern int fputs_unlocked (__const char *__restrict __s,
- FILE *__restrict __stream);
-extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
- size_t __n, FILE *__restrict __stream) ;
-extern size_t fwrite_unlocked (__const void *__restrict __ptr, size_t __size,
- size_t __n, FILE *__restrict __stream);
-extern int fseek (FILE *__stream, long int __off, int __whence);
-extern long int ftell (FILE *__stream) ;
-extern void rewind (FILE *__stream);
-extern int fseeko (FILE *__stream, __off_t __off, int __whence);
-extern __off_t ftello (FILE *__stream) ;
-extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
-extern int fsetpos (FILE *__stream, __const fpos_t *__pos);
-extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);
-extern __off64_t ftello64 (FILE *__stream) ;
-extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);
-extern int fsetpos64 (FILE *__stream, __const fpos64_t *__pos);
-extern void clearerr (FILE *__stream) throw ();
-extern int feof (FILE *__stream) throw () ;
-extern int ferror (FILE *__stream) throw () ;
-extern void clearerr_unlocked (FILE *__stream) throw ();
-extern int feof_unlocked (FILE *__stream) throw () ;
-extern int ferror_unlocked (FILE *__stream) throw () ;
-extern void perror (__const char *__s);
-extern int sys_nerr;
-extern __const char *__const sys_errlist[];
-extern int _sys_nerr;
-extern __const char *__const _sys_errlist[];
-extern int fileno (FILE *__stream) throw () ;
-extern int fileno_unlocked (FILE *__stream) throw () ;
-extern FILE *popen (__const char *__command, __const char *__modes) ;
-extern int pclose (FILE *__stream);
-extern char *ctermid (char *__s) throw ();
-extern char *cuserid (char *__s);
-struct obstack;
-extern int obstack_printf (struct obstack *__restrict __obstack,
- __const char *__restrict __format, ...)
- throw () __attribute__ ((__format__ (__printf__, 2, 3)));
-extern int obstack_vprintf (struct obstack *__restrict __obstack,
- __const char *__restrict __format,
- __gnuc_va_list __args)
- throw () __attribute__ ((__format__ (__printf__, 2, 0)));
-extern void flockfile (FILE *__stream) throw ();
-extern int ftrylockfile (FILE *__stream) throw () ;
-extern void funlockfile (FILE *__stream) throw ();
-extern __inline __attribute__ ((__gnu_inline__)) int
-vprintf (__const char *__restrict __fmt, __gnuc_va_list __arg)
-{
- return vfprintf (stdout, __fmt, __arg);
-}
-extern __inline __attribute__ ((__gnu_inline__)) int
-getchar (void)
-{
- return _IO_getc (stdin);
-}
-extern __inline __attribute__ ((__gnu_inline__)) int
-fgetc_unlocked (FILE *__fp)
-{
- return (__builtin_expect (((__fp)->_IO_read_ptr >= (__fp)->_IO_read_end), 0) ? __uflow (__fp) : *(unsigned char *) (__fp)->_IO_read_ptr++);
-}
-extern __inline __attribute__ ((__gnu_inline__)) int
-getc_unlocked (FILE *__fp)
-{
- return (__builtin_expect (((__fp)->_IO_read_ptr >= (__fp)->_IO_read_end), 0) ? __uflow (__fp) : *(unsigned char *) (__fp)->_IO_read_ptr++);
-}
-extern __inline __attribute__ ((__gnu_inline__)) int
-getchar_unlocked (void)
-{
- return (__builtin_expect (((stdin)->_IO_read_ptr >= (stdin)->_IO_read_end), 0) ? __uflow (stdin) : *(unsigned char *) (stdin)->_IO_read_ptr++);
-}
-extern __inline __attribute__ ((__gnu_inline__)) int
-putchar (int __c)
-{
- return _IO_putc (__c, stdout);
-}
-extern __inline __attribute__ ((__gnu_inline__)) int
-fputc_unlocked (int __c, FILE *__stream)
-{
- return (__builtin_expect (((__stream)->_IO_write_ptr >= (__stream)->_IO_write_end), 0) ? __overflow (__stream, (unsigned char) (__c)) : (unsigned char) (*(__stream)->_IO_write_ptr++ = (__c)));
-}
-extern __inline __attribute__ ((__gnu_inline__)) int
-putc_unlocked (int __c, FILE *__stream)
-{
- return (__builtin_expect (((__stream)->_IO_write_ptr >= (__stream)->_IO_write_end), 0) ? __overflow (__stream, (unsigned char) (__c)) : (unsigned char) (*(__stream)->_IO_write_ptr++ = (__c)));
-}
-extern __inline __attribute__ ((__gnu_inline__)) int
-putchar_unlocked (int __c)
-{
- return (__builtin_expect (((stdout)->_IO_write_ptr >= (stdout)->_IO_write_end), 0) ? __overflow (stdout, (unsigned char) (__c)) : (unsigned char) (*(stdout)->_IO_write_ptr++ = (__c)));
-}
-extern __inline __attribute__ ((__gnu_inline__)) __ssize_t
-getline (char **__lineptr, size_t *__n, FILE *__stream)
-{
- return __getdelim (__lineptr, __n, '\n', __stream);
-}
-extern __inline __attribute__ ((__gnu_inline__)) int
-feof_unlocked (FILE *__stream) throw ()
-{
- return (((__stream)->_flags & 0x10) != 0);
-}
-extern __inline __attribute__ ((__gnu_inline__)) int
-ferror_unlocked (FILE *__stream) throw ()
-{
- return (((__stream)->_flags & 0x20) != 0);
-}
-}
-namespace std
-{
- using ::FILE;
- using ::fpos_t;
- using ::clearerr;
- using ::fclose;
- using ::feof;
- using ::ferror;
- using ::fflush;
- using ::fgetc;
- using ::fgetpos;
- using ::fgets;
- using ::fopen;
- using ::fprintf;
- using ::fputc;
- using ::fputs;
- using ::fread;
- using ::freopen;
- using ::fscanf;
- using ::fseek;
- using ::fsetpos;
- using ::ftell;
- using ::fwrite;
- using ::getc;
- using ::getchar;
- using ::gets;
- using ::perror;
- using ::printf;
- using ::putc;
- using ::putchar;
- using ::puts;
- using ::remove;
- using ::rename;
- using ::rewind;
- using ::scanf;
- using ::setbuf;
- using ::setvbuf;
- using ::sprintf;
- using ::sscanf;
- using ::tmpfile;
- using ::tmpnam;
- using ::ungetc;
- using ::vfprintf;
- using ::vprintf;
- using ::vsprintf;
-}
-namespace __gnu_cxx
-{
- using ::snprintf;
- using ::vfscanf;
- using ::vscanf;
- using ::vsnprintf;
- using ::vsscanf;
-}
-namespace std
-{
- using ::__gnu_cxx::snprintf;
- using ::__gnu_cxx::vfscanf;
- using ::__gnu_cxx::vscanf;
- using ::__gnu_cxx::vsnprintf;
- using ::__gnu_cxx::vsscanf;
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- typedef __gthread_mutex_t __c_lock;
- typedef FILE __c_file;
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _CharT>
- class __basic_file;
- template<>
- class __basic_file<char>
- {
- __c_file* _M_cfile;
- bool _M_cfile_created;
- public:
- __basic_file(__c_lock* __lock = 0) throw ();
- __basic_file*
- open(const char* __name, ios_base::openmode __mode, int __prot = 0664);
- __basic_file*
- sys_open(__c_file* __file, ios_base::openmode);
- __basic_file*
- sys_open(int __fd, ios_base::openmode __mode) throw ();
- __basic_file*
- close();
- __attribute__ ((__pure__)) bool
- is_open() const throw ();
- __attribute__ ((__pure__)) int
- fd() throw ();
- __attribute__ ((__pure__)) __c_file*
- file() throw ();
- ~__basic_file();
- streamsize
- xsputn(const char* __s, streamsize __n);
- streamsize
- xsputn_2(const char* __s1, streamsize __n1,
- const char* __s2, streamsize __n2);
- streamsize
- xsgetn(char* __s, streamsize __n);
- streamoff
- seekoff(streamoff __off, ios_base::seekdir __way) throw ();
- int
- sync();
- streamsize
- showmanyc();
- };
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _CharT, typename _Traits>
- class basic_filebuf : public basic_streambuf<_CharT, _Traits>
- {
- public:
- typedef _CharT char_type;
- typedef _Traits traits_type;
- typedef typename traits_type::int_type int_type;
- typedef typename traits_type::pos_type pos_type;
- typedef typename traits_type::off_type off_type;
- typedef basic_streambuf<char_type, traits_type> __streambuf_type;
- typedef basic_filebuf<char_type, traits_type> __filebuf_type;
- typedef __basic_file<char> __file_type;
- typedef typename traits_type::state_type __state_type;
- typedef codecvt<char_type, char, __state_type> __codecvt_type;
- friend class ios_base;
- protected:
- __c_lock _M_lock;
- __file_type _M_file;
- ios_base::openmode _M_mode;
- __state_type _M_state_beg;
- __state_type _M_state_cur;
- __state_type _M_state_last;
- char_type* _M_buf;
- size_t _M_buf_size;
- bool _M_buf_allocated;
- bool _M_reading;
- bool _M_writing;
- char_type _M_pback;
- char_type* _M_pback_cur_save;
- char_type* _M_pback_end_save;
- bool _M_pback_init;
- const __codecvt_type* _M_codecvt;
- char* _M_ext_buf;
- streamsize _M_ext_buf_size;
- const char* _M_ext_next;
- char* _M_ext_end;
- void
- _M_create_pback()
- {
- if (!_M_pback_init)
- {
- _M_pback_cur_save = this->gptr();
- _M_pback_end_save = this->egptr();
- this->setg(&_M_pback, &_M_pback, &_M_pback + 1);
- _M_pback_init = true;
- }
- }
- void
- _M_destroy_pback() throw()
- {
- if (_M_pback_init)
- {
- _M_pback_cur_save += this->gptr() != this->eback();
- this->setg(_M_buf, _M_pback_cur_save, _M_pback_end_save);
- _M_pback_init = false;
- }
- }
- public:
- basic_filebuf();
- virtual
- ~basic_filebuf()
- { this->close(); }
- bool
- is_open() const throw()
- { return _M_file.is_open(); }
- __filebuf_type*
- open(const char* __s, ios_base::openmode __mode);
- __filebuf_type*
- close();
- protected:
- void
- _M_allocate_internal_buffer();
- void
- _M_destroy_internal_buffer() throw();
- virtual streamsize
- showmanyc();
- virtual int_type
- underflow();
- virtual int_type
- pbackfail(int_type __c = _Traits::eof());
- virtual int_type
- overflow(int_type __c = _Traits::eof());
- bool
- _M_convert_to_external(char_type*, streamsize);
- virtual __streambuf_type*
- setbuf(char_type* __s, streamsize __n);
- virtual pos_type
- seekoff(off_type __off, ios_base::seekdir __way,
- ios_base::openmode __mode = ios_base::in | ios_base::out);
- virtual pos_type
- seekpos(pos_type __pos,
- ios_base::openmode __mode = ios_base::in | ios_base::out);
- pos_type
- _M_seek(off_type __off, ios_base::seekdir __way, __state_type __state);
- int
- _M_get_ext_pos(__state_type &__state);
- virtual int
- sync();
- virtual void
- imbue(const locale& __loc);
- virtual streamsize
- xsgetn(char_type* __s, streamsize __n);
- virtual streamsize
- xsputn(const char_type* __s, streamsize __n);
- bool
- _M_terminate_output();
- void
- _M_set_buffer(streamsize __off)
- {
- const bool __testin = _M_mode & ios_base::in;
- const bool __testout = _M_mode & ios_base::out;
- if (__testin && __off > 0)
- this->setg(_M_buf, _M_buf, _M_buf + __off);
- else
- this->setg(_M_buf, _M_buf, _M_buf);
- if (__testout && __off == 0 && _M_buf_size > 1 )
- this->setp(_M_buf, _M_buf + _M_buf_size - 1);
- else
- this->setp(0, 0);
- }
- };
- template<typename _CharT, typename _Traits>
- class basic_ifstream : public basic_istream<_CharT, _Traits>
- {
- public:
- typedef _CharT char_type;
- typedef _Traits traits_type;
- typedef typename traits_type::int_type int_type;
- typedef typename traits_type::pos_type pos_type;
- typedef typename traits_type::off_type off_type;
- typedef basic_filebuf<char_type, traits_type> __filebuf_type;
- typedef basic_istream<char_type, traits_type> __istream_type;
- private:
- __filebuf_type _M_filebuf;
- public:
- basic_ifstream() : __istream_type(), _M_filebuf()
- { this->init(&_M_filebuf); }
- explicit
- basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in)
- : __istream_type(), _M_filebuf()
- {
- this->init(&_M_filebuf);
- this->open(__s, __mode);
- }
- ~basic_ifstream()
- { }
- __filebuf_type*
- rdbuf() const
- { return const_cast<__filebuf_type*>(&_M_filebuf); }
- bool
- is_open()
- { return _M_filebuf.is_open(); }
- bool
- is_open() const
- { return _M_filebuf.is_open(); }
- void
- open(const char* __s, ios_base::openmode __mode = ios_base::in)
- {
- if (!_M_filebuf.open(__s, __mode | ios_base::in))
- this->setstate(ios_base::failbit);
- else
- this->clear();
- }
- void
- close()
- {
- if (!_M_filebuf.close())
- this->setstate(ios_base::failbit);
- }
- };
- template<typename _CharT, typename _Traits>
- class basic_ofstream : public basic_ostream<_CharT,_Traits>
- {
- public:
- typedef _CharT char_type;
- typedef _Traits traits_type;
- typedef typename traits_type::int_type int_type;
- typedef typename traits_type::pos_type pos_type;
- typedef typename traits_type::off_type off_type;
- typedef basic_filebuf<char_type, traits_type> __filebuf_type;
- typedef basic_ostream<char_type, traits_type> __ostream_type;
- private:
- __filebuf_type _M_filebuf;
- public:
- basic_ofstream(): __ostream_type(), _M_filebuf()
- { this->init(&_M_filebuf); }
- explicit
- basic_ofstream(const char* __s,
- ios_base::openmode __mode = ios_base::out|ios_base::trunc)
- : __ostream_type(), _M_filebuf()
- {
- this->init(&_M_filebuf);
- this->open(__s, __mode);
- }
- ~basic_ofstream()
- { }
- __filebuf_type*
- rdbuf() const
- { return const_cast<__filebuf_type*>(&_M_filebuf); }
- bool
- is_open()
- { return _M_filebuf.is_open(); }
- bool
- is_open() const
- { return _M_filebuf.is_open(); }
- void
- open(const char* __s,
- ios_base::openmode __mode = ios_base::out | ios_base::trunc)
- {
- if (!_M_filebuf.open(__s, __mode | ios_base::out))
- this->setstate(ios_base::failbit);
- else
- this->clear();
- }
- void
- close()
- {
- if (!_M_filebuf.close())
- this->setstate(ios_base::failbit);
- }
- };
- template<typename _CharT, typename _Traits>
- class basic_fstream : public basic_iostream<_CharT, _Traits>
- {
- public:
- typedef _CharT char_type;
- typedef _Traits traits_type;
- typedef typename traits_type::int_type int_type;
- typedef typename traits_type::pos_type pos_type;
- typedef typename traits_type::off_type off_type;
- typedef basic_filebuf<char_type, traits_type> __filebuf_type;
- typedef basic_ios<char_type, traits_type> __ios_type;
- typedef basic_iostream<char_type, traits_type> __iostream_type;
- private:
- __filebuf_type _M_filebuf;
- public:
- basic_fstream()
- : __iostream_type(), _M_filebuf()
- { this->init(&_M_filebuf); }
- explicit
- basic_fstream(const char* __s,
- ios_base::openmode __mode = ios_base::in | ios_base::out)
- : __iostream_type(0), _M_filebuf()
- {
- this->init(&_M_filebuf);
- this->open(__s, __mode);
- }
- ~basic_fstream()
- { }
- __filebuf_type*
- rdbuf() const
- { return const_cast<__filebuf_type*>(&_M_filebuf); }
- bool
- is_open()
- { return _M_filebuf.is_open(); }
- bool
- is_open() const
- { return _M_filebuf.is_open(); }
- void
- open(const char* __s,
- ios_base::openmode __mode = ios_base::in | ios_base::out)
- {
- if (!_M_filebuf.open(__s, __mode))
- this->setstate(ios_base::failbit);
- else
- this->clear();
- }
- void
- close()
- {
- if (!_M_filebuf.close())
- this->setstate(ios_base::failbit);
- }
- };
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _CharT, typename _Traits>
- void
- basic_filebuf<_CharT, _Traits>::
- _M_allocate_internal_buffer()
- {
- if (!_M_buf_allocated && !_M_buf)
- {
- _M_buf = new char_type[_M_buf_size];
- _M_buf_allocated = true;
- }
- }
- template<typename _CharT, typename _Traits>
- void
- basic_filebuf<_CharT, _Traits>::
- _M_destroy_internal_buffer() throw()
- {
- if (_M_buf_allocated)
- {
- delete [] _M_buf;
- _M_buf = 0;
- _M_buf_allocated = false;
- }
- delete [] _M_ext_buf;
- _M_ext_buf = 0;
- _M_ext_buf_size = 0;
- _M_ext_next = 0;
- _M_ext_end = 0;
- }
- template<typename _CharT, typename _Traits>
- basic_filebuf<_CharT, _Traits>::
- basic_filebuf() : __streambuf_type(), _M_lock(), _M_file(&_M_lock),
- _M_mode(ios_base::openmode(0)), _M_state_beg(), _M_state_cur(),
- _M_state_last(), _M_buf(0), _M_buf_size(8192),
- _M_buf_allocated(false), _M_reading(false), _M_writing(false), _M_pback(),
- _M_pback_cur_save(0), _M_pback_end_save(0), _M_pback_init(false),
- _M_codecvt(0), _M_ext_buf(0), _M_ext_buf_size(0), _M_ext_next(0),
- _M_ext_end(0)
- {
- if (has_facet<__codecvt_type>(this->_M_buf_locale))
- _M_codecvt = &use_facet<__codecvt_type>(this->_M_buf_locale);
- }
- template<typename _CharT, typename _Traits>
- typename basic_filebuf<_CharT, _Traits>::__filebuf_type*
- basic_filebuf<_CharT, _Traits>::
- open(const char* __s, ios_base::openmode __mode)
- {
- __filebuf_type *__ret = 0;
- if (!this->is_open())
- {
- _M_file.open(__s, __mode);
- if (this->is_open())
- {
- _M_allocate_internal_buffer();
- _M_mode = __mode;
- _M_reading = false;
- _M_writing = false;
- _M_set_buffer(-1);
- _M_state_last = _M_state_cur = _M_state_beg;
- if ((__mode & ios_base::ate)
- && this->seekoff(0, ios_base::end, __mode)
- == pos_type(off_type(-1)))
- this->close();
- else
- __ret = this;
- }
- }
- return __ret;
- }
- template<typename _CharT, typename _Traits>
- typename basic_filebuf<_CharT, _Traits>::__filebuf_type*
- basic_filebuf<_CharT, _Traits>::
- close()
- {
- if (!this->is_open())
- return 0;
- bool __testfail = false;
- {
- struct __close_sentry
- {
- basic_filebuf *__fb;
- __close_sentry (basic_filebuf *__fbi): __fb(__fbi) { }
- ~__close_sentry ()
- {
- __fb->_M_mode = ios_base::openmode(0);
- __fb->_M_pback_init = false;
- __fb->_M_destroy_internal_buffer();
- __fb->_M_reading = false;
- __fb->_M_writing = false;
- __fb->_M_set_buffer(-1);
- __fb->_M_state_last = __fb->_M_state_cur = __fb->_M_state_beg;
- }
- } __cs (this);
- try
- {
- if (!_M_terminate_output())
- __testfail = true;
- }
- catch(__cxxabiv1::__forced_unwind&)
- {
- _M_file.close();
- throw;
- }
- catch(...)
- { __testfail = true; }
- }
- if (!_M_file.close())
- __testfail = true;
- if (__testfail)
- return 0;
- else
- return this;
- }
- template<typename _CharT, typename _Traits>
- streamsize
- basic_filebuf<_CharT, _Traits>::
- showmanyc()
- {
- streamsize __ret = -1;
- const bool __testin = _M_mode & ios_base::in;
- if (__testin && this->is_open())
- {
- __ret = this->egptr() - this->gptr();
- if (__check_facet(_M_codecvt).encoding() >= 0)
- __ret += _M_file.showmanyc() / _M_codecvt->max_length();
- }
- return __ret;
- }
- template<typename _CharT, typename _Traits>
- typename basic_filebuf<_CharT, _Traits>::int_type
- basic_filebuf<_CharT, _Traits>::
- underflow()
- {
- int_type __ret = traits_type::eof();
- const bool __testin = _M_mode & ios_base::in;
- if (__testin)
- {
- if (_M_writing)
- {
- if (overflow() == traits_type::eof())
- return __ret;
- _M_set_buffer(-1);
- _M_writing = false;
- }
- _M_destroy_pback();
- if (this->gptr() < this->egptr())
- return traits_type::to_int_type(*this->gptr());
- const size_t __buflen = _M_buf_size > 1 ? _M_buf_size - 1 : 1;
- bool __got_eof = false;
- streamsize __ilen = 0;
- codecvt_base::result __r = codecvt_base::ok;
- if (__check_facet(_M_codecvt).always_noconv())
- {
- __ilen = _M_file.xsgetn(reinterpret_cast<char*>(this->eback()),
- __buflen);
- if (__ilen == 0)
- __got_eof = true;
- }
- else
- {
- const int __enc = _M_codecvt->encoding();
- streamsize __blen;
- streamsize __rlen;
- if (__enc > 0)
- __blen = __rlen = __buflen * __enc;
- else
- {
- __blen = __buflen + _M_codecvt->max_length() - 1;
- __rlen = __buflen;
- }
- const streamsize __remainder = _M_ext_end - _M_ext_next;
- __rlen = __rlen > __remainder ? __rlen - __remainder : 0;
- if (_M_reading && this->egptr() == this->eback() && __remainder)
- __rlen = 0;
- if (_M_ext_buf_size < __blen)
- {
- char* __buf = new char[__blen];
- if (__remainder)
- __builtin_memcpy(__buf, _M_ext_next, __remainder);
- delete [] _M_ext_buf;
- _M_ext_buf = __buf;
- _M_ext_buf_size = __blen;
- }
- else if (__remainder)
- __builtin_memmove(_M_ext_buf, _M_ext_next, __remainder);
- _M_ext_next = _M_ext_buf;
- _M_ext_end = _M_ext_buf + __remainder;
- _M_state_last = _M_state_cur;
- do
- {
- if (__rlen > 0)
- {
- if (_M_ext_end - _M_ext_buf + __rlen > _M_ext_buf_size)
- {
- __throw_ios_failure(("basic_filebuf::underflow " "codecvt::max_length() " "is not valid")
- );
- }
- streamsize __elen = _M_file.xsgetn(_M_ext_end, __rlen);
- if (__elen == 0)
- __got_eof = true;
- else if (__elen == -1)
- break;
- _M_ext_end += __elen;
- }
- char_type* __iend = this->eback();
- if (_M_ext_next < _M_ext_end)
- __r = _M_codecvt->in(_M_state_cur, _M_ext_next,
- _M_ext_end, _M_ext_next,
- this->eback(),
- this->eback() + __buflen, __iend);
- if (__r == codecvt_base::noconv)
- {
- size_t __avail = _M_ext_end - _M_ext_buf;
- __ilen = std::min(__avail, __buflen);
- traits_type::copy(this->eback(),
- reinterpret_cast<char_type*>
- (_M_ext_buf), __ilen);
- _M_ext_next = _M_ext_buf + __ilen;
- }
- else
- __ilen = __iend - this->eback();
- if (__r == codecvt_base::error)
- break;
- __rlen = 1;
- }
- while (__ilen == 0 && !__got_eof);
- }
- if (__ilen > 0)
- {
- _M_set_buffer(__ilen);
- _M_reading = true;
- __ret = traits_type::to_int_type(*this->gptr());
- }
- else if (__got_eof)
- {
- _M_set_buffer(-1);
- _M_reading = false;
- if (__r == codecvt_base::partial)
- __throw_ios_failure(("basic_filebuf::underflow " "incomplete character in file")
- );
- }
- else if (__r == codecvt_base::error)
- __throw_ios_failure(("basic_filebuf::underflow " "invalid byte sequence in file")
- );
- else
- __throw_ios_failure(("basic_filebuf::underflow " "error reading the file")
- );
- }
- return __ret;
- }
- template<typename _CharT, typename _Traits>
- typename basic_filebuf<_CharT, _Traits>::int_type
- basic_filebuf<_CharT, _Traits>::
- pbackfail(int_type __i)
- {
- int_type __ret = traits_type::eof();
- const bool __testin = _M_mode & ios_base::in;
- if (__testin)
- {
- if (_M_writing)
- {
- if (overflow() == traits_type::eof())
- return __ret;
- _M_set_buffer(-1);
- _M_writing = false;
- }
- const bool __testpb = _M_pback_init;
- const bool __testeof = traits_type::eq_int_type(__i, __ret);
- int_type __tmp;
- if (this->eback() < this->gptr())
- {
- this->gbump(-1);
- __tmp = traits_type::to_int_type(*this->gptr());
- }
- else if (this->seekoff(-1, ios_base::cur) != pos_type(off_type(-1)))
- {
- __tmp = this->underflow();
- if (traits_type::eq_int_type(__tmp, __ret))
- return __ret;
- }
- else
- {
- return __ret;
- }
- if (!__testeof && traits_type::eq_int_type(__i, __tmp))
- __ret = __i;
- else if (__testeof)
- __ret = traits_type::not_eof(__i);
- else if (!__testpb)
- {
- _M_create_pback();
- _M_reading = true;
- *this->gptr() = traits_type::to_char_type(__i);
- __ret = __i;
- }
- }
- return __ret;
- }
- template<typename _CharT, typename _Traits>
- typename basic_filebuf<_CharT, _Traits>::int_type
- basic_filebuf<_CharT, _Traits>::
- overflow(int_type __c)
- {
- int_type __ret = traits_type::eof();
- const bool __testeof = traits_type::eq_int_type(__c, __ret);
- const bool __testout = _M_mode & ios_base::out;
- if (__testout)
- {
- if (_M_reading)
- {
- _M_destroy_pback();
- const int __gptr_off = _M_get_ext_pos(_M_state_last);
- if (_M_seek(__gptr_off, ios_base::cur, _M_state_last)
- == pos_type(off_type(-1)))
- return __ret;
- }
- if (this->pbase() < this->pptr())
- {
- if (!__testeof)
- {
- *this->pptr() = traits_type::to_char_type(__c);
- this->pbump(1);
- }
- if (_M_convert_to_external(this->pbase(),
- this->pptr() - this->pbase()))
- {
- _M_set_buffer(0);
- __ret = traits_type::not_eof(__c);
- }
- }
- else if (_M_buf_size > 1)
- {
- _M_set_buffer(0);
- _M_writing = true;
- if (!__testeof)
- {
- *this->pptr() = traits_type::to_char_type(__c);
- this->pbump(1);
- }
- __ret = traits_type::not_eof(__c);
- }
- else
- {
- char_type __conv = traits_type::to_char_type(__c);
- if (__testeof || _M_convert_to_external(&__conv, 1))
- {
- _M_writing = true;
- __ret = traits_type::not_eof(__c);
- }
- }
- }
- return __ret;
- }
- template<typename _CharT, typename _Traits>
- bool
- basic_filebuf<_CharT, _Traits>::
- _M_convert_to_external(_CharT* __ibuf, streamsize __ilen)
- {
- streamsize __elen;
- streamsize __plen;
- if (__check_facet(_M_codecvt).always_noconv())
- {
- __elen = _M_file.xsputn(reinterpret_cast<char*>(__ibuf), __ilen);
- __plen = __ilen;
- }
- else
- {
- streamsize __blen = __ilen * _M_codecvt->max_length();
- char* __buf = static_cast<char*>(__builtin_alloca(__blen));
- char* __bend;
- const char_type* __iend;
- codecvt_base::result __r;
- __r = _M_codecvt->out(_M_state_cur, __ibuf, __ibuf + __ilen,
- __iend, __buf, __buf + __blen, __bend);
- if (__r == codecvt_base::ok || __r == codecvt_base::partial)
- __blen = __bend - __buf;
- else if (__r == codecvt_base::noconv)
- {
- __buf = reinterpret_cast<char*>(__ibuf);
- __blen = __ilen;
- }
- else
- __throw_ios_failure(("basic_filebuf::_M_convert_to_external " "conversion error")
- );
- __elen = _M_file.xsputn(__buf, __blen);
- __plen = __blen;
- if (__r == codecvt_base::partial && __elen == __plen)
- {
- const char_type* __iresume = __iend;
- streamsize __rlen = this->pptr() - __iend;
- __r = _M_codecvt->out(_M_state_cur, __iresume,
- __iresume + __rlen, __iend, __buf,
- __buf + __blen, __bend);
- if (__r != codecvt_base::error)
- {
- __rlen = __bend - __buf;
- __elen = _M_file.xsputn(__buf, __rlen);
- __plen = __rlen;
- }
- else
- __throw_ios_failure(("basic_filebuf::_M_convert_to_external " "conversion error")
- );
- }
- }
- return __elen == __plen;
- }
- template<typename _CharT, typename _Traits>
- streamsize
- basic_filebuf<_CharT, _Traits>::
- xsgetn(_CharT* __s, streamsize __n)
- {
- streamsize __ret = 0;
- if (_M_pback_init)
- {
- if (__n > 0 && this->gptr() == this->eback())
- {
- *__s++ = *this->gptr();
- this->gbump(1);
- __ret = 1;
- --__n;
- }
- _M_destroy_pback();
- }
- else if (_M_writing)
- {
- if (overflow() == traits_type::eof())
- return __ret;
- _M_set_buffer(-1);
- _M_writing = false;
- }
- const bool __testin = _M_mode & ios_base::in;
- const streamsize __buflen = _M_buf_size > 1 ? _M_buf_size - 1 : 1;
- if (__n > __buflen && __check_facet(_M_codecvt).always_noconv()
- && __testin)
- {
- const streamsize __avail = this->egptr() - this->gptr();
- if (__avail != 0)
- {
- traits_type::copy(__s, this->gptr(), __avail);
- __s += __avail;
- this->setg(this->eback(), this->gptr() + __avail,
- this->egptr());
- __ret += __avail;
- __n -= __avail;
- }
- streamsize __len;
- for (;;)
- {
- __len = _M_file.xsgetn(reinterpret_cast<char*>(__s),
- __n);
- if (__len == -1)
- __throw_ios_failure(("basic_filebuf::xsgetn " "error reading the file")
- );
- if (__len == 0)
- break;
- __n -= __len;
- __ret += __len;
- if (__n == 0)
- break;
- __s += __len;
- }
- if (__n == 0)
- {
- _M_set_buffer(0);
- _M_reading = true;
- }
- else if (__len == 0)
- {
- _M_set_buffer(-1);
- _M_reading = false;
- }
- }
- else
- __ret += __streambuf_type::xsgetn(__s, __n);
- return __ret;
- }
- template<typename _CharT, typename _Traits>
- streamsize
- basic_filebuf<_CharT, _Traits>::
- xsputn(const _CharT* __s, streamsize __n)
- {
- streamsize __ret = 0;
- const bool __testout = _M_mode & ios_base::out;
- if (__check_facet(_M_codecvt).always_noconv()
- && __testout && !_M_reading)
- {
- const streamsize __chunk = 1ul << 10;
- streamsize __bufavail = this->epptr() - this->pptr();
- if (!_M_writing && _M_buf_size > 1)
- __bufavail = _M_buf_size - 1;
- const streamsize __limit = std::min(__chunk, __bufavail);
- if (__n >= __limit)
- {
- const streamsize __buffill = this->pptr() - this->pbase();
- const char* __buf = reinterpret_cast<const char*>(this->pbase());
- __ret = _M_file.xsputn_2(__buf, __buffill,
- reinterpret_cast<const char*>(__s),
- __n);
- if (__ret == __buffill + __n)
- {
- _M_set_buffer(0);
- _M_writing = true;
- }
- if (__ret > __buffill)
- __ret -= __buffill;
- else
- __ret = 0;
- }
- else
- __ret = __streambuf_type::xsputn(__s, __n);
- }
- else
- __ret = __streambuf_type::xsputn(__s, __n);
- return __ret;
- }
- template<typename _CharT, typename _Traits>
- typename basic_filebuf<_CharT, _Traits>::__streambuf_type*
- basic_filebuf<_CharT, _Traits>::
- setbuf(char_type* __s, streamsize __n)
- {
- if (!this->is_open())
- {
- if (__s == 0 && __n == 0)
- _M_buf_size = 1;
- else if (__s && __n > 0)
- {
- _M_buf = __s;
- _M_buf_size = __n;
- }
- }
- return this;
- }
- template<typename _CharT, typename _Traits>
- typename basic_filebuf<_CharT, _Traits>::pos_type
- basic_filebuf<_CharT, _Traits>::
- seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode)
- {
- int __width = 0;
- if (_M_codecvt)
- __width = _M_codecvt->encoding();
- if (__width < 0)
- __width = 0;
- pos_type __ret = pos_type(off_type(-1));
- const bool __testfail = __off != 0 && __width <= 0;
- if (this->is_open() && !__testfail)
- {
- bool __no_movement = __way == ios_base::cur && __off == 0
- && (!_M_writing || _M_codecvt->always_noconv());
- if (!__no_movement)
- _M_destroy_pback();
- __state_type __state = _M_state_beg;
- off_type __computed_off = __off * __width;
- if (_M_reading && __way == ios_base::cur)
- {
- __state = _M_state_last;
- __computed_off += _M_get_ext_pos(__state);
- }
- if (!__no_movement)
- __ret = _M_seek(__computed_off, __way, __state);
- else
- {
- if (_M_writing)
- __computed_off = this->pptr() - this->pbase();
- off_type __file_off = _M_file.seekoff(0, ios_base::cur);
- if (__file_off != off_type(-1))
- {
- __ret = __file_off + __computed_off;
- __ret.state(__state);
- }
- }
- }
- return __ret;
- }
- template<typename _CharT, typename _Traits>
- typename basic_filebuf<_CharT, _Traits>::pos_type
- basic_filebuf<_CharT, _Traits>::
- seekpos(pos_type __pos, ios_base::openmode)
- {
- pos_type __ret = pos_type(off_type(-1));
- if (this->is_open())
- {
- _M_destroy_pback();
- __ret = _M_seek(off_type(__pos), ios_base::beg, __pos.state());
- }
- return __ret;
- }
- template<typename _CharT, typename _Traits>
- typename basic_filebuf<_CharT, _Traits>::pos_type
- basic_filebuf<_CharT, _Traits>::
- _M_seek(off_type __off, ios_base::seekdir __way, __state_type __state)
- {
- pos_type __ret = pos_type(off_type(-1));
- if (_M_terminate_output())
- {
- off_type __file_off = _M_file.seekoff(__off, __way);
- if (__file_off != off_type(-1))
- {
- _M_reading = false;
- _M_writing = false;
- _M_ext_next = _M_ext_end = _M_ext_buf;
- _M_set_buffer(-1);
- _M_state_cur = __state;
- __ret = __file_off;
- __ret.state(_M_state_cur);
- }
- }
- return __ret;
- }
- template<typename _CharT, typename _Traits>
- int basic_filebuf<_CharT, _Traits>::
- _M_get_ext_pos(__state_type& __state)
- {
- if (_M_codecvt->always_noconv())
- return this->gptr() - this->egptr();
- else
- {
- const int __gptr_off =
- _M_codecvt->length(__state, _M_ext_buf, _M_ext_next,
- this->gptr() - this->eback());
- return _M_ext_buf + __gptr_off - _M_ext_end;
- }
- }
- template<typename _CharT, typename _Traits>
- bool
- basic_filebuf<_CharT, _Traits>::
- _M_terminate_output()
- {
- bool __testvalid = true;
- if (this->pbase() < this->pptr())
- {
- const int_type __tmp = this->overflow();
- if (traits_type::eq_int_type(__tmp, traits_type::eof()))
- __testvalid = false;
- }
- if (_M_writing && !__check_facet(_M_codecvt).always_noconv()
- && __testvalid)
- {
- const size_t __blen = 128;
- char __buf[__blen];
- codecvt_base::result __r;
- streamsize __ilen = 0;
- do
- {
- char* __next;
- __r = _M_codecvt->unshift(_M_state_cur, __buf,
- __buf + __blen, __next);
- if (__r == codecvt_base::error)
- __testvalid = false;
- else if (__r == codecvt_base::ok ||
- __r == codecvt_base::partial)
- {
- __ilen = __next - __buf;
- if (__ilen > 0)
- {
- const streamsize __elen = _M_file.xsputn(__buf, __ilen);
- if (__elen != __ilen)
- __testvalid = false;
- }
- }
- }
- while (__r == codecvt_base::partial && __ilen > 0 && __testvalid);
- if (__testvalid)
- {
- const int_type __tmp = this->overflow();
- if (traits_type::eq_int_type(__tmp, traits_type::eof()))
- __testvalid = false;
- }
- }
- return __testvalid;
- }
- template<typename _CharT, typename _Traits>
- int
- basic_filebuf<_CharT, _Traits>::
- sync()
- {
- int __ret = 0;
- if (this->pbase() < this->pptr())
- {
- const int_type __tmp = this->overflow();
- if (traits_type::eq_int_type(__tmp, traits_type::eof()))
- __ret = -1;
- }
- return __ret;
- }
- template<typename _CharT, typename _Traits>
- void
- basic_filebuf<_CharT, _Traits>::
- imbue(const locale& __loc)
- {
- bool __testvalid = true;
- const __codecvt_type* _M_codecvt_tmp = 0;
- if (__builtin_expect(has_facet<__codecvt_type>(__loc), true))
- _M_codecvt_tmp = &use_facet<__codecvt_type>(__loc);
- if (this->is_open())
- {
- if ((_M_reading || _M_writing)
- && __check_facet(_M_codecvt).encoding() == -1)
- __testvalid = false;
- else
- {
- if (_M_reading)
- {
- if (__check_facet(_M_codecvt).always_noconv())
- {
- if (_M_codecvt_tmp
- && !__check_facet(_M_codecvt_tmp).always_noconv())
- __testvalid = this->seekoff(0, ios_base::cur, _M_mode)
- != pos_type(off_type(-1));
- }
- else
- {
- _M_ext_next = _M_ext_buf
- + _M_codecvt->length(_M_state_last, _M_ext_buf,
- _M_ext_next,
- this->gptr() - this->eback());
- const streamsize __remainder = _M_ext_end - _M_ext_next;
- if (__remainder)
- __builtin_memmove(_M_ext_buf, _M_ext_next, __remainder);
- _M_ext_next = _M_ext_buf;
- _M_ext_end = _M_ext_buf + __remainder;
- _M_set_buffer(-1);
- _M_state_last = _M_state_cur = _M_state_beg;
- }
- }
- else if (_M_writing && (__testvalid = _M_terminate_output()))
- _M_set_buffer(-1);
- }
- }
- if (__testvalid)
- _M_codecvt = _M_codecvt_tmp;
- else
- _M_codecvt = 0;
- }
- extern template class basic_filebuf<char>;
- extern template class basic_ifstream<char>;
- extern template class basic_ofstream<char>;
- extern template class basic_fstream<char>;
- extern template class basic_filebuf<wchar_t>;
- extern template class basic_ifstream<wchar_t>;
- extern template class basic_ofstream<wchar_t>;
- extern template class basic_fstream<wchar_t>;
-}
-extern "C" {
-extern void *memcpy (void *__restrict __dest,
- __const void *__restrict __src, size_t __n)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern void *memmove (void *__dest, __const void *__src, size_t __n)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern void *memccpy (void *__restrict __dest, __const void *__restrict __src,
- int __c, size_t __n)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern void *memset (void *__s, int __c, size_t __n) throw () __attribute__ ((__nonnull__ (1)));
-extern int memcmp (__const void *__s1, __const void *__s2, size_t __n)
- throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
-extern "C++"
-{
-extern void *memchr (void *__s, int __c, size_t __n)
- throw () __asm ("memchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
-extern __const void *memchr (__const void *__s, int __c, size_t __n)
- throw () __asm ("memchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
-extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__, __artificial__)) void *
-memchr (void *__s, int __c, size_t __n) throw ()
-{
- return __builtin_memchr (__s, __c, __n);
-}
-extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__, __artificial__)) __const void *
-memchr (__const void *__s, int __c, size_t __n) throw ()
-{
- return __builtin_memchr (__s, __c, __n);
-}
-}
-extern "C++" void *rawmemchr (void *__s, int __c)
- throw () __asm ("rawmemchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
-extern "C++" __const void *rawmemchr (__const void *__s, int __c)
- throw () __asm ("rawmemchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
-extern "C++" void *memrchr (void *__s, int __c, size_t __n)
- throw () __asm ("memrchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
-extern "C++" __const void *memrchr (__const void *__s, int __c, size_t __n)
- throw () __asm ("memrchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
-extern char *strcpy (char *__restrict __dest, __const char *__restrict __src)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern char *strncpy (char *__restrict __dest,
- __const char *__restrict __src, size_t __n)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern char *strcat (char *__restrict __dest, __const char *__restrict __src)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern char *strncat (char *__restrict __dest, __const char *__restrict __src,
- size_t __n) throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int strcmp (__const char *__s1, __const char *__s2)
- throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
-extern int strncmp (__const char *__s1, __const char *__s2, size_t __n)
- throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
-extern int strcoll (__const char *__s1, __const char *__s2)
- throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
-extern size_t strxfrm (char *__restrict __dest,
- __const char *__restrict __src, size_t __n)
- throw () __attribute__ ((__nonnull__ (2)));
-extern int strcoll_l (__const char *__s1, __const char *__s2, __locale_t __l)
- throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 3)));
-extern size_t strxfrm_l (char *__dest, __const char *__src, size_t __n,
- __locale_t __l) throw () __attribute__ ((__nonnull__ (2, 4)));
-extern char *strdup (__const char *__s)
- throw () __attribute__ ((__malloc__)) __attribute__ ((__nonnull__ (1)));
-extern char *strndup (__const char *__string, size_t __n)
- throw () __attribute__ ((__malloc__)) __attribute__ ((__nonnull__ (1)));
-extern "C++"
-{
-extern char *strchr (char *__s, int __c)
- throw () __asm ("strchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
-extern __const char *strchr (__const char *__s, int __c)
- throw () __asm ("strchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
-extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__, __artificial__)) char *
-strchr (char *__s, int __c) throw ()
-{
- return __builtin_strchr (__s, __c);
-}
-extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__, __artificial__)) __const char *
-strchr (__const char *__s, int __c) throw ()
-{
- return __builtin_strchr (__s, __c);
-}
-}
-extern "C++"
-{
-extern char *strrchr (char *__s, int __c)
- throw () __asm ("strrchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
-extern __const char *strrchr (__const char *__s, int __c)
- throw () __asm ("strrchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
-extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__, __artificial__)) char *
-strrchr (char *__s, int __c) throw ()
-{
- return __builtin_strrchr (__s, __c);
-}
-extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__, __artificial__)) __const char *
-strrchr (__const char *__s, int __c) throw ()
-{
- return __builtin_strrchr (__s, __c);
-}
-}
-extern "C++" char *strchrnul (char *__s, int __c)
- throw () __asm ("strchrnul") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
-extern "C++" __const char *strchrnul (__const char *__s, int __c)
- throw () __asm ("strchrnul") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
-extern size_t strcspn (__const char *__s, __const char *__reject)
- throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
-extern size_t strspn (__const char *__s, __const char *__accept)
- throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
-extern "C++"
-{
-extern char *strpbrk (char *__s, __const char *__accept)
- throw () __asm ("strpbrk") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
-extern __const char *strpbrk (__const char *__s, __const char *__accept)
- throw () __asm ("strpbrk") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
-extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__, __artificial__)) char *
-strpbrk (char *__s, __const char *__accept) throw ()
-{
- return __builtin_strpbrk (__s, __accept);
-}
-extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__, __artificial__)) __const char *
-strpbrk (__const char *__s, __const char *__accept) throw ()
-{
- return __builtin_strpbrk (__s, __accept);
-}
-}
-extern "C++"
-{
-extern char *strstr (char *__haystack, __const char *__needle)
- throw () __asm ("strstr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
-extern __const char *strstr (__const char *__haystack,
- __const char *__needle)
- throw () __asm ("strstr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
-extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__, __artificial__)) char *
-strstr (char *__haystack, __const char *__needle) throw ()
-{
- return __builtin_strstr (__haystack, __needle);
-}
-extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__, __artificial__)) __const char *
-strstr (__const char *__haystack, __const char *__needle) throw ()
-{
- return __builtin_strstr (__haystack, __needle);
-}
-}
-extern char *strtok (char *__restrict __s, __const char *__restrict __delim)
- throw () __attribute__ ((__nonnull__ (2)));
-extern char *__strtok_r (char *__restrict __s,
- __const char *__restrict __delim,
- char **__restrict __save_ptr)
- throw () __attribute__ ((__nonnull__ (2, 3)));
-extern char *strtok_r (char *__restrict __s, __const char *__restrict __delim,
- char **__restrict __save_ptr)
- throw () __attribute__ ((__nonnull__ (2, 3)));
-extern "C++" char *strcasestr (char *__haystack, __const char *__needle)
- throw () __asm ("strcasestr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
-extern "C++" __const char *strcasestr (__const char *__haystack,
- __const char *__needle)
- throw () __asm ("strcasestr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
-extern void *memmem (__const void *__haystack, size_t __haystacklen,
- __const void *__needle, size_t __needlelen)
- throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 3)));
-extern void *__mempcpy (void *__restrict __dest,
- __const void *__restrict __src, size_t __n)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern void *mempcpy (void *__restrict __dest,
- __const void *__restrict __src, size_t __n)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern size_t strlen (__const char *__s)
- throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
-extern size_t strnlen (__const char *__string, size_t __maxlen)
- throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
-extern char *strerror (int __errnum) throw ();
-extern char *strerror_r (int __errnum, char *__buf, size_t __buflen)
- throw () __attribute__ ((__nonnull__ (2)));
-extern char *strerror_l (int __errnum, __locale_t __l) throw ();
-extern void __bzero (void *__s, size_t __n) throw () __attribute__ ((__nonnull__ (1)));
-extern void bcopy (__const void *__src, void *__dest, size_t __n)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern void bzero (void *__s, size_t __n) throw () __attribute__ ((__nonnull__ (1)));
-extern int bcmp (__const void *__s1, __const void *__s2, size_t __n)
- throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
-extern "C++"
-{
-extern char *index (char *__s, int __c)
- throw () __asm ("index") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
-extern __const char *index (__const char *__s, int __c)
- throw () __asm ("index") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
-extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__, __artificial__)) char *
-index (char *__s, int __c) throw ()
-{
- return __builtin_index (__s, __c);
-}
-extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__, __artificial__)) __const char *
-index (__const char *__s, int __c) throw ()
-{
- return __builtin_index (__s, __c);
-}
-}
-extern "C++"
-{
-extern char *rindex (char *__s, int __c)
- throw () __asm ("rindex") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
-extern __const char *rindex (__const char *__s, int __c)
- throw () __asm ("rindex") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
-extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__, __artificial__)) char *
-rindex (char *__s, int __c) throw ()
-{
- return __builtin_rindex (__s, __c);
-}
-extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__, __artificial__)) __const char *
-rindex (__const char *__s, int __c) throw ()
-{
- return __builtin_rindex (__s, __c);
-}
-}
-extern int ffs (int __i) throw () __attribute__ ((__const__));
-extern int ffsl (long int __l) throw () __attribute__ ((__const__));
-__extension__ extern int ffsll (long long int __ll)
- throw () __attribute__ ((__const__));
-extern int strcasecmp (__const char *__s1, __const char *__s2)
- throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
-extern int strncasecmp (__const char *__s1, __const char *__s2, size_t __n)
- throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
-extern int strcasecmp_l (__const char *__s1, __const char *__s2,
- __locale_t __loc)
- throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 3)));
-extern int strncasecmp_l (__const char *__s1, __const char *__s2,
- size_t __n, __locale_t __loc)
- throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 4)));
-extern char *strsep (char **__restrict __stringp,
- __const char *__restrict __delim)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern char *strsignal (int __sig) throw ();
-extern char *__stpcpy (char *__restrict __dest, __const char *__restrict __src)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern char *stpcpy (char *__restrict __dest, __const char *__restrict __src)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern char *__stpncpy (char *__restrict __dest,
- __const char *__restrict __src, size_t __n)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern char *stpncpy (char *__restrict __dest,
- __const char *__restrict __src, size_t __n)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int strverscmp (__const char *__s1, __const char *__s2)
- throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
-extern char *strfry (char *__string) throw () __attribute__ ((__nonnull__ (1)));
-extern void *memfrob (void *__s, size_t __n) throw () __attribute__ ((__nonnull__ (1)));
-extern "C++" char *basename (char *__filename)
- throw () __asm ("basename") __attribute__ ((__nonnull__ (1)));
-extern "C++" __const char *basename (__const char *__filename)
- throw () __asm ("basename") __attribute__ ((__nonnull__ (1)));
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- using ::memchr;
- using ::memcmp;
- using ::memcpy;
- using ::memmove;
- using ::memset;
- using ::strcat;
- using ::strcmp;
- using ::strcoll;
- using ::strcpy;
- using ::strcspn;
- using ::strerror;
- using ::strlen;
- using ::strncat;
- using ::strncmp;
- using ::strncpy;
- using ::strspn;
- using ::strtok;
- using ::strxfrm;
- using ::strchr;
- using ::strpbrk;
- using ::strrchr;
- using ::strstr;
-}
-extern int TheCurrentLine;
- using std::exception;
-extern long mpirank;
-class Error : public exception
-{ public:
- enum CODE_ERROR { NONE, COMPILE_ERROR,EXEC_ERROR, MEM_ERROR,MESH_ERROR,ASSERT_ERROR,INTERNAL_ERROR, UNKNOWN };
-private:
- std::string message;
- const CODE_ERROR code;
-protected:
- Error(CODE_ERROR c,const char * t1,const char * t2,const char * t3=0,
- int n=0,const char * t4=0,const char * t5=0,const char * t6=0,
- const char * t7=0,const char * t8=0,const char * t9=0)
- : message(),code(c)
- {
- using namespace std;
- ostringstream mess;
- if(t1) mess << t1;
- if(t2) mess << t2;
- if(t3) mess << t3 << n ;
- if(t4) mess << t4;
- if(t5) mess << t5;
- if(t6) mess << t6;
- if(t7) mess << t7;
- if(t8) mess << t8;
- if(t9) mess << t9;
- message = mess.str();
- extern void ShowDebugStack();
- ShowDebugStack();
- if (c!=NONE && mpirank==0) cout << message << endl;
- }
-public:
- virtual int errcode() const {return code;}
- virtual const char * what() const throw () { return message.c_str(); }
- virtual ~Error() throw () {}
-};
-class ErrorCompile : public Error
-{
- public:
- ErrorCompile(const char * Text,int l,const char * t2="") :
- Error(COMPILE_ERROR,"Compile error : ",Text,"\n\tline number :",l,", ", t2) {}
-};
-class ErrorExec : public Error
-{
- public:
- ErrorExec(const char * Text,int l) :
- Error(UNKNOWN,"Exec error : ",Text, "\n -- number :", l) {}
-};
-class ErrorInternal : public Error
-{
- public:
- ErrorInternal(const char * Text,int l,const char * t2="") :
- Error(INTERNAL_ERROR,"Internal error : ",Text, "\n\tline :",l,", in file ", t2) {}
-};
-class ErrorAssert : public Error
-{
- public:
- ErrorAssert(const char * Text,const char *file,const int line) :
- Error(ASSERT_ERROR,"Assertion fail : (",Text, ")\n\tline :", line,", in file ",file) {}
-};
-class ErrorMemory : public Error
-{ public:
- ErrorMemory(const char * Text,int l=0) :
- Error(MEM_ERROR,"Memory Error : ",Text," number: ",l) {}
-};
-class ErrorExit : public Error
-{
- int codeexit;
-public:
- ErrorExit(const char * ,int l) :
- Error(NONE,"exit","(","",l,")"), codeexit(l) {}
- int errcode() const{return codeexit;}
-};
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- enum _Rb_tree_color { _S_red = false, _S_black = true };
- struct _Rb_tree_node_base
- {
- typedef _Rb_tree_node_base* _Base_ptr;
- typedef const _Rb_tree_node_base* _Const_Base_ptr;
- _Rb_tree_color _M_color;
- _Base_ptr _M_parent;
- _Base_ptr _M_left;
- _Base_ptr _M_right;
- static _Base_ptr
- _S_minimum(_Base_ptr __x)
- {
- while (__x->_M_left != 0) __x = __x->_M_left;
- return __x;
- }
- static _Const_Base_ptr
- _S_minimum(_Const_Base_ptr __x)
- {
- while (__x->_M_left != 0) __x = __x->_M_left;
- return __x;
- }
- static _Base_ptr
- _S_maximum(_Base_ptr __x)
- {
- while (__x->_M_right != 0) __x = __x->_M_right;
- return __x;
- }
- static _Const_Base_ptr
- _S_maximum(_Const_Base_ptr __x)
- {
- while (__x->_M_right != 0) __x = __x->_M_right;
- return __x;
- }
- };
- template<typename _Val>
- struct _Rb_tree_node : public _Rb_tree_node_base
- {
- typedef _Rb_tree_node<_Val>* _Link_type;
- _Val _M_value_field;
- };
- __attribute__ ((__pure__)) _Rb_tree_node_base*
- _Rb_tree_increment(_Rb_tree_node_base* __x) throw ();
- __attribute__ ((__pure__)) const _Rb_tree_node_base*
- _Rb_tree_increment(const _Rb_tree_node_base* __x) throw ();
- __attribute__ ((__pure__)) _Rb_tree_node_base*
- _Rb_tree_decrement(_Rb_tree_node_base* __x) throw ();
- __attribute__ ((__pure__)) const _Rb_tree_node_base*
- _Rb_tree_decrement(const _Rb_tree_node_base* __x) throw ();
- template<typename _Tp>
- struct _Rb_tree_iterator
- {
- typedef _Tp value_type;
- typedef _Tp& reference;
- typedef _Tp* pointer;
- typedef bidirectional_iterator_tag iterator_category;
- typedef ptrdiff_t difference_type;
- typedef _Rb_tree_iterator<_Tp> _Self;
- typedef _Rb_tree_node_base::_Base_ptr _Base_ptr;
- typedef _Rb_tree_node<_Tp>* _Link_type;
- _Rb_tree_iterator()
- : _M_node() { }
- explicit
- _Rb_tree_iterator(_Link_type __x)
- : _M_node(__x) { }
- reference
- operator*() const
- { return static_cast<_Link_type>(_M_node)->_M_value_field; }
- pointer
- operator->() const
- { return std::__addressof(static_cast<_Link_type>
- (_M_node)->_M_value_field); }
- _Self&
- operator++()
- {
- _M_node = _Rb_tree_increment(_M_node);
- return *this;
- }
- _Self
- operator++(int)
- {
- _Self __tmp = *this;
- _M_node = _Rb_tree_increment(_M_node);
- return __tmp;
- }
- _Self&
- operator--()
- {
- _M_node = _Rb_tree_decrement(_M_node);
- return *this;
- }
- _Self
- operator--(int)
- {
- _Self __tmp = *this;
- _M_node = _Rb_tree_decrement(_M_node);
- return __tmp;
- }
- bool
- operator==(const _Self& __x) const
- { return _M_node == __x._M_node; }
- bool
- operator!=(const _Self& __x) const
- { return _M_node != __x._M_node; }
- _Base_ptr _M_node;
- };
- template<typename _Tp>
- struct _Rb_tree_const_iterator
- {
- typedef _Tp value_type;
- typedef const _Tp& reference;
- typedef const _Tp* pointer;
- typedef _Rb_tree_iterator<_Tp> iterator;
- typedef bidirectional_iterator_tag iterator_category;
- typedef ptrdiff_t difference_type;
- typedef _Rb_tree_const_iterator<_Tp> _Self;
- typedef _Rb_tree_node_base::_Const_Base_ptr _Base_ptr;
- typedef const _Rb_tree_node<_Tp>* _Link_type;
- _Rb_tree_const_iterator()
- : _M_node() { }
- explicit
- _Rb_tree_const_iterator(_Link_type __x)
- : _M_node(__x) { }
- _Rb_tree_const_iterator(const iterator& __it)
- : _M_node(__it._M_node) { }
- iterator
- _M_const_cast() const
- { return iterator(static_cast<typename iterator::_Link_type>
- (const_cast<typename iterator::_Base_ptr>(_M_node))); }
- reference
- operator*() const
- { return static_cast<_Link_type>(_M_node)->_M_value_field; }
- pointer
- operator->() const
- { return std::__addressof(static_cast<_Link_type>
- (_M_node)->_M_value_field); }
- _Self&
- operator++()
- {
- _M_node = _Rb_tree_increment(_M_node);
- return *this;
- }
- _Self
- operator++(int)
- {
- _Self __tmp = *this;
- _M_node = _Rb_tree_increment(_M_node);
- return __tmp;
- }
- _Self&
- operator--()
- {
- _M_node = _Rb_tree_decrement(_M_node);
- return *this;
- }
- _Self
- operator--(int)
- {
- _Self __tmp = *this;
- _M_node = _Rb_tree_decrement(_M_node);
- return __tmp;
- }
- bool
- operator==(const _Self& __x) const
- { return _M_node == __x._M_node; }
- bool
- operator!=(const _Self& __x) const
- { return _M_node != __x._M_node; }
- _Base_ptr _M_node;
- };
- template<typename _Val>
- inline bool
- operator==(const _Rb_tree_iterator<_Val>& __x,
- const _Rb_tree_const_iterator<_Val>& __y)
- { return __x._M_node == __y._M_node; }
- template<typename _Val>
- inline bool
- operator!=(const _Rb_tree_iterator<_Val>& __x,
- const _Rb_tree_const_iterator<_Val>& __y)
- { return __x._M_node != __y._M_node; }
- void
- _Rb_tree_insert_and_rebalance(const bool __insert_left,
- _Rb_tree_node_base* __x,
- _Rb_tree_node_base* __p,
- _Rb_tree_node_base& __header) throw ();
- _Rb_tree_node_base*
- _Rb_tree_rebalance_for_erase(_Rb_tree_node_base* const __z,
- _Rb_tree_node_base& __header) throw ();
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc = allocator<_Val> >
- class _Rb_tree
- {
- typedef typename _Alloc::template rebind<_Rb_tree_node<_Val> >::other
- _Node_allocator;
- protected:
- typedef _Rb_tree_node_base* _Base_ptr;
- typedef const _Rb_tree_node_base* _Const_Base_ptr;
- public:
- typedef _Key key_type;
- typedef _Val value_type;
- typedef value_type* pointer;
- typedef const value_type* const_pointer;
- typedef value_type& reference;
- typedef const value_type& const_reference;
- typedef _Rb_tree_node<_Val>* _Link_type;
- typedef const _Rb_tree_node<_Val>* _Const_Link_type;
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
- typedef _Alloc allocator_type;
- _Node_allocator&
- _M_get_Node_allocator()
- { return *static_cast<_Node_allocator*>(&this->_M_impl); }
- const _Node_allocator&
- _M_get_Node_allocator() const
- { return *static_cast<const _Node_allocator*>(&this->_M_impl); }
- allocator_type
- get_allocator() const
- { return allocator_type(_M_get_Node_allocator()); }
- protected:
- _Link_type
- _M_get_node()
- { return _M_impl._Node_allocator::allocate(1); }
- void
- _M_put_node(_Link_type __p)
- { _M_impl._Node_allocator::deallocate(__p, 1); }
- _Link_type
- _M_create_node(const value_type& __x)
- {
- _Link_type __tmp = _M_get_node();
- try
- { get_allocator().construct
- (std::__addressof(__tmp->_M_value_field), __x); }
- catch(...)
- {
- _M_put_node(__tmp);
- throw;
- }
- return __tmp;
- }
- void
- _M_destroy_node(_Link_type __p)
- {
- get_allocator().destroy(std::__addressof(__p->_M_value_field));
- _M_put_node(__p);
- }
- _Link_type
- _M_clone_node(_Const_Link_type __x)
- {
- _Link_type __tmp = _M_create_node(__x->_M_value_field);
- __tmp->_M_color = __x->_M_color;
- __tmp->_M_left = 0;
- __tmp->_M_right = 0;
- return __tmp;
- }
- protected:
- template<typename _Key_compare,
- bool _Is_pod_comparator = __is_pod(_Key_compare)>
- struct _Rb_tree_impl : public _Node_allocator
- {
- _Key_compare _M_key_compare;
- _Rb_tree_node_base _M_header;
- size_type _M_node_count;
- _Rb_tree_impl()
- : _Node_allocator(), _M_key_compare(), _M_header(),
- _M_node_count(0)
- { _M_initialize(); }
- _Rb_tree_impl(const _Key_compare& __comp, const _Node_allocator& __a)
- : _Node_allocator(__a), _M_key_compare(__comp), _M_header(),
- _M_node_count(0)
- { _M_initialize(); }
- private:
- void
- _M_initialize()
- {
- this->_M_header._M_color = _S_red;
- this->_M_header._M_parent = 0;
- this->_M_header._M_left = &this->_M_header;
- this->_M_header._M_right = &this->_M_header;
- }
- };
- _Rb_tree_impl<_Compare> _M_impl;
- protected:
- _Base_ptr&
- _M_root()
- { return this->_M_impl._M_header._M_parent; }
- _Const_Base_ptr
- _M_root() const
- { return this->_M_impl._M_header._M_parent; }
- _Base_ptr&
- _M_leftmost()
- { return this->_M_impl._M_header._M_left; }
- _Const_Base_ptr
- _M_leftmost() const
- { return this->_M_impl._M_header._M_left; }
- _Base_ptr&
- _M_rightmost()
- { return this->_M_impl._M_header._M_right; }
- _Const_Base_ptr
- _M_rightmost() const
- { return this->_M_impl._M_header._M_right; }
- _Link_type
- _M_begin()
- { return static_cast<_Link_type>(this->_M_impl._M_header._M_parent); }
- _Const_Link_type
- _M_begin() const
- {
- return static_cast<_Const_Link_type>
- (this->_M_impl._M_header._M_parent);
- }
- _Link_type
- _M_end()
- { return static_cast<_Link_type>(&this->_M_impl._M_header); }
- _Const_Link_type
- _M_end() const
- { return static_cast<_Const_Link_type>(&this->_M_impl._M_header); }
- static const_reference
- _S_value(_Const_Link_type __x)
- { return __x->_M_value_field; }
- static const _Key&
- _S_key(_Const_Link_type __x)
- { return _KeyOfValue()(_S_value(__x)); }
- static _Link_type
- _S_left(_Base_ptr __x)
- { return static_cast<_Link_type>(__x->_M_left); }
- static _Const_Link_type
- _S_left(_Const_Base_ptr __x)
- { return static_cast<_Const_Link_type>(__x->_M_left); }
- static _Link_type
- _S_right(_Base_ptr __x)
- { return static_cast<_Link_type>(__x->_M_right); }
- static _Const_Link_type
- _S_right(_Const_Base_ptr __x)
- { return static_cast<_Const_Link_type>(__x->_M_right); }
- static const_reference
- _S_value(_Const_Base_ptr __x)
- { return static_cast<_Const_Link_type>(__x)->_M_value_field; }
- static const _Key&
- _S_key(_Const_Base_ptr __x)
- { return _KeyOfValue()(_S_value(__x)); }
- static _Base_ptr
- _S_minimum(_Base_ptr __x)
- { return _Rb_tree_node_base::_S_minimum(__x); }
- static _Const_Base_ptr
- _S_minimum(_Const_Base_ptr __x)
- { return _Rb_tree_node_base::_S_minimum(__x); }
- static _Base_ptr
- _S_maximum(_Base_ptr __x)
- { return _Rb_tree_node_base::_S_maximum(__x); }
- static _Const_Base_ptr
- _S_maximum(_Const_Base_ptr __x)
- { return _Rb_tree_node_base::_S_maximum(__x); }
- public:
- typedef _Rb_tree_iterator<value_type> iterator;
- typedef _Rb_tree_const_iterator<value_type> const_iterator;
- typedef std::reverse_iterator<iterator> reverse_iterator;
- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
- private:
- iterator
- _M_insert_(_Const_Base_ptr __x, _Const_Base_ptr __y,
- const value_type& __v);
- iterator
- _M_insert_lower(_Base_ptr __x, _Base_ptr __y, const value_type& __v);
- iterator
- _M_insert_equal_lower(const value_type& __x);
- _Link_type
- _M_copy(_Const_Link_type __x, _Link_type __p);
- void
- _M_erase(_Link_type __x);
- iterator
- _M_lower_bound(_Link_type __x, _Link_type __y,
- const _Key& __k);
- const_iterator
- _M_lower_bound(_Const_Link_type __x, _Const_Link_type __y,
- const _Key& __k) const;
- iterator
- _M_upper_bound(_Link_type __x, _Link_type __y,
- const _Key& __k);
- const_iterator
- _M_upper_bound(_Const_Link_type __x, _Const_Link_type __y,
- const _Key& __k) const;
- public:
- _Rb_tree() { }
- _Rb_tree(const _Compare& __comp,
- const allocator_type& __a = allocator_type())
- : _M_impl(__comp, __a) { }
- _Rb_tree(const _Rb_tree& __x)
- : _M_impl(__x._M_impl._M_key_compare, __x._M_get_Node_allocator())
- {
- if (__x._M_root() != 0)
- {
- _M_root() = _M_copy(__x._M_begin(), _M_end());
- _M_leftmost() = _S_minimum(_M_root());
- _M_rightmost() = _S_maximum(_M_root());
- _M_impl._M_node_count = __x._M_impl._M_node_count;
- }
- }
- ~_Rb_tree()
- { _M_erase(_M_begin()); }
- _Rb_tree&
- operator=(const _Rb_tree& __x);
- _Compare
- key_comp() const
- { return _M_impl._M_key_compare; }
- iterator
- begin()
- {
- return iterator(static_cast<_Link_type>
- (this->_M_impl._M_header._M_left));
- }
- const_iterator
- begin() const
- {
- return const_iterator(static_cast<_Const_Link_type>
- (this->_M_impl._M_header._M_left));
- }
- iterator
- end()
- { return iterator(static_cast<_Link_type>(&this->_M_impl._M_header)); }
- const_iterator
- end() const
- {
- return const_iterator(static_cast<_Const_Link_type>
- (&this->_M_impl._M_header));
- }
- 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()); }
- bool
- empty() const
- { return _M_impl._M_node_count == 0; }
- size_type
- size() const
- { return _M_impl._M_node_count; }
- size_type
- max_size() const
- { return _M_get_Node_allocator().max_size(); }
- void
- swap(_Rb_tree& __t);
- pair<iterator, bool>
- _M_insert_unique(const value_type& __x);
- iterator
- _M_insert_equal(const value_type& __x);
- iterator
- _M_insert_unique_(const_iterator __position, const value_type& __x);
- iterator
- _M_insert_equal_(const_iterator __position, const value_type& __x);
- template<typename _InputIterator>
- void
- _M_insert_unique(_InputIterator __first, _InputIterator __last);
- template<typename _InputIterator>
- void
- _M_insert_equal(_InputIterator __first, _InputIterator __last);
- private:
- void
- _M_erase_aux(const_iterator __position);
- void
- _M_erase_aux(const_iterator __first, const_iterator __last);
- public:
- void
- erase(iterator __position)
- { _M_erase_aux(__position); }
- void
- erase(const_iterator __position)
- { _M_erase_aux(__position); }
- size_type
- erase(const key_type& __x);
- void
- erase(iterator __first, iterator __last)
- { _M_erase_aux(__first, __last); }
- void
- erase(const_iterator __first, const_iterator __last)
- { _M_erase_aux(__first, __last); }
- void
- erase(const key_type* __first, const key_type* __last);
- void
- clear()
- {
- _M_erase(_M_begin());
- _M_leftmost() = _M_end();
- _M_root() = 0;
- _M_rightmost() = _M_end();
- _M_impl._M_node_count = 0;
- }
- iterator
- find(const key_type& __k);
- const_iterator
- find(const key_type& __k) const;
- size_type
- count(const key_type& __k) const;
- iterator
- lower_bound(const key_type& __k)
- { return _M_lower_bound(_M_begin(), _M_end(), __k); }
- const_iterator
- lower_bound(const key_type& __k) const
- { return _M_lower_bound(_M_begin(), _M_end(), __k); }
- iterator
- upper_bound(const key_type& __k)
- { return _M_upper_bound(_M_begin(), _M_end(), __k); }
- const_iterator
- upper_bound(const key_type& __k) const
- { return _M_upper_bound(_M_begin(), _M_end(), __k); }
- pair<iterator, iterator>
- equal_range(const key_type& __k);
- pair<const_iterator, const_iterator>
- equal_range(const key_type& __k) const;
- bool
- __rb_verify() const;
- };
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- inline bool
- operator==(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
- const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y)
- {
- return __x.size() == __y.size()
- && std::equal(__x.begin(), __x.end(), __y.begin());
- }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- inline bool
- operator<(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
- const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y)
- {
- return std::lexicographical_compare(__x.begin(), __x.end(),
- __y.begin(), __y.end());
- }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- inline bool
- operator!=(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
- const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y)
- { return !(__x == __y); }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- inline bool
- operator>(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
- const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y)
- { return __y < __x; }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- inline bool
- operator<=(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
- const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y)
- { return !(__y < __x); }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- inline bool
- operator>=(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
- const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y)
- { return !(__x < __y); }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- inline void
- swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
- _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y)
- { __x.swap(__y); }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&
- _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- operator=(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x)
- {
- if (this != &__x)
- {
- clear();
- _M_impl._M_key_compare = __x._M_impl._M_key_compare;
- if (__x._M_root() != 0)
- {
- _M_root() = _M_copy(__x._M_begin(), _M_end());
- _M_leftmost() = _S_minimum(_M_root());
- _M_rightmost() = _S_maximum(_M_root());
- _M_impl._M_node_count = __x._M_impl._M_node_count;
- }
- }
- return *this;
- }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
- _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- _M_insert_(_Const_Base_ptr __x, _Const_Base_ptr __p, const _Val& __v)
- {
- bool __insert_left = (__x != 0 || __p == _M_end()
- || _M_impl._M_key_compare(_KeyOfValue()(__v),
- _S_key(__p)));
- _Link_type __z = _M_create_node((__v));
- _Rb_tree_insert_and_rebalance(__insert_left, __z,
- const_cast<_Base_ptr>(__p),
- this->_M_impl._M_header);
- ++_M_impl._M_node_count;
- return iterator(__z);
- }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
- _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- _M_insert_lower(_Base_ptr __x, _Base_ptr __p, const _Val& __v)
- {
- bool __insert_left = (__x != 0 || __p == _M_end()
- || !_M_impl._M_key_compare(_S_key(__p),
- _KeyOfValue()(__v)));
- _Link_type __z = _M_create_node((__v));
- _Rb_tree_insert_and_rebalance(__insert_left, __z, __p,
- this->_M_impl._M_header);
- ++_M_impl._M_node_count;
- return iterator(__z);
- }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
- _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- _M_insert_equal_lower(const _Val& __v)
- {
- _Link_type __x = _M_begin();
- _Link_type __y = _M_end();
- while (__x != 0)
- {
- __y = __x;
- __x = !_M_impl._M_key_compare(_S_key(__x), _KeyOfValue()(__v)) ?
- _S_left(__x) : _S_right(__x);
- }
- return _M_insert_lower(__x, __y, (__v));
- }
- template<typename _Key, typename _Val, typename _KoV,
- typename _Compare, typename _Alloc>
- typename _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>::_Link_type
- _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>::
- _M_copy(_Const_Link_type __x, _Link_type __p)
- {
- _Link_type __top = _M_clone_node(__x);
- __top->_M_parent = __p;
- try
- {
- if (__x->_M_right)
- __top->_M_right = _M_copy(_S_right(__x), __top);
- __p = __top;
- __x = _S_left(__x);
- while (__x != 0)
- {
- _Link_type __y = _M_clone_node(__x);
- __p->_M_left = __y;
- __y->_M_parent = __p;
- if (__x->_M_right)
- __y->_M_right = _M_copy(_S_right(__x), __y);
- __p = __y;
- __x = _S_left(__x);
- }
- }
- catch(...)
- {
- _M_erase(__top);
- throw;
- }
- return __top;
- }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- void
- _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- _M_erase(_Link_type __x)
- {
- while (__x != 0)
- {
- _M_erase(_S_right(__x));
- _Link_type __y = _S_left(__x);
- _M_destroy_node(__x);
- __x = __y;
- }
- }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- typename _Rb_tree<_Key, _Val, _KeyOfValue,
- _Compare, _Alloc>::iterator
- _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- _M_lower_bound(_Link_type __x, _Link_type __y,
- const _Key& __k)
- {
- while (__x != 0)
- if (!_M_impl._M_key_compare(_S_key(__x), __k))
- __y = __x, __x = _S_left(__x);
- else
- __x = _S_right(__x);
- return iterator(__y);
- }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- typename _Rb_tree<_Key, _Val, _KeyOfValue,
- _Compare, _Alloc>::const_iterator
- _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- _M_lower_bound(_Const_Link_type __x, _Const_Link_type __y,
- const _Key& __k) const
- {
- while (__x != 0)
- if (!_M_impl._M_key_compare(_S_key(__x), __k))
- __y = __x, __x = _S_left(__x);
- else
- __x = _S_right(__x);
- return const_iterator(__y);
- }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- typename _Rb_tree<_Key, _Val, _KeyOfValue,
- _Compare, _Alloc>::iterator
- _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- _M_upper_bound(_Link_type __x, _Link_type __y,
- const _Key& __k)
- {
- while (__x != 0)
- if (_M_impl._M_key_compare(__k, _S_key(__x)))
- __y = __x, __x = _S_left(__x);
- else
- __x = _S_right(__x);
- return iterator(__y);
- }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- typename _Rb_tree<_Key, _Val, _KeyOfValue,
- _Compare, _Alloc>::const_iterator
- _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- _M_upper_bound(_Const_Link_type __x, _Const_Link_type __y,
- const _Key& __k) const
- {
- while (__x != 0)
- if (_M_impl._M_key_compare(__k, _S_key(__x)))
- __y = __x, __x = _S_left(__x);
- else
- __x = _S_right(__x);
- return const_iterator(__y);
- }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- pair<typename _Rb_tree<_Key, _Val, _KeyOfValue,
- _Compare, _Alloc>::iterator,
- typename _Rb_tree<_Key, _Val, _KeyOfValue,
- _Compare, _Alloc>::iterator>
- _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- equal_range(const _Key& __k)
- {
- _Link_type __x = _M_begin();
- _Link_type __y = _M_end();
- while (__x != 0)
- {
- if (_M_impl._M_key_compare(_S_key(__x), __k))
- __x = _S_right(__x);
- else if (_M_impl._M_key_compare(__k, _S_key(__x)))
- __y = __x, __x = _S_left(__x);
- else
- {
- _Link_type __xu(__x), __yu(__y);
- __y = __x, __x = _S_left(__x);
- __xu = _S_right(__xu);
- return pair<iterator,
- iterator>(_M_lower_bound(__x, __y, __k),
- _M_upper_bound(__xu, __yu, __k));
- }
- }
- return pair<iterator, iterator>(iterator(__y),
- iterator(__y));
- }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- pair<typename _Rb_tree<_Key, _Val, _KeyOfValue,
- _Compare, _Alloc>::const_iterator,
- typename _Rb_tree<_Key, _Val, _KeyOfValue,
- _Compare, _Alloc>::const_iterator>
- _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- equal_range(const _Key& __k) const
- {
- _Const_Link_type __x = _M_begin();
- _Const_Link_type __y = _M_end();
- while (__x != 0)
- {
- if (_M_impl._M_key_compare(_S_key(__x), __k))
- __x = _S_right(__x);
- else if (_M_impl._M_key_compare(__k, _S_key(__x)))
- __y = __x, __x = _S_left(__x);
- else
- {
- _Const_Link_type __xu(__x), __yu(__y);
- __y = __x, __x = _S_left(__x);
- __xu = _S_right(__xu);
- return pair<const_iterator,
- const_iterator>(_M_lower_bound(__x, __y, __k),
- _M_upper_bound(__xu, __yu, __k));
- }
- }
- return pair<const_iterator, const_iterator>(const_iterator(__y),
- const_iterator(__y));
- }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- void
- _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __t)
- {
- if (_M_root() == 0)
- {
- if (__t._M_root() != 0)
- {
- _M_root() = __t._M_root();
- _M_leftmost() = __t._M_leftmost();
- _M_rightmost() = __t._M_rightmost();
- _M_root()->_M_parent = _M_end();
- __t._M_root() = 0;
- __t._M_leftmost() = __t._M_end();
- __t._M_rightmost() = __t._M_end();
- }
- }
- else if (__t._M_root() == 0)
- {
- __t._M_root() = _M_root();
- __t._M_leftmost() = _M_leftmost();
- __t._M_rightmost() = _M_rightmost();
- __t._M_root()->_M_parent = __t._M_end();
- _M_root() = 0;
- _M_leftmost() = _M_end();
- _M_rightmost() = _M_end();
- }
- else
- {
- std::swap(_M_root(),__t._M_root());
- std::swap(_M_leftmost(),__t._M_leftmost());
- std::swap(_M_rightmost(),__t._M_rightmost());
- _M_root()->_M_parent = _M_end();
- __t._M_root()->_M_parent = __t._M_end();
- }
- std::swap(this->_M_impl._M_node_count, __t._M_impl._M_node_count);
- std::swap(this->_M_impl._M_key_compare, __t._M_impl._M_key_compare);
- std::__alloc_swap<_Node_allocator>::
- _S_do_it(_M_get_Node_allocator(), __t._M_get_Node_allocator());
- }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- pair<typename _Rb_tree<_Key, _Val, _KeyOfValue,
- _Compare, _Alloc>::iterator, bool>
- _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- _M_insert_unique(const _Val& __v)
- {
- _Link_type __x = _M_begin();
- _Link_type __y = _M_end();
- bool __comp = true;
- while (__x != 0)
- {
- __y = __x;
- __comp = _M_impl._M_key_compare(_KeyOfValue()(__v), _S_key(__x));
- __x = __comp ? _S_left(__x) : _S_right(__x);
- }
- iterator __j = iterator(__y);
- if (__comp)
- {
- if (__j == begin())
- return pair<iterator, bool>
- (_M_insert_(__x, __y, (__v)), true);
- else
- --__j;
- }
- if (_M_impl._M_key_compare(_S_key(__j._M_node), _KeyOfValue()(__v)))
- return pair<iterator, bool>
- (_M_insert_(__x, __y, (__v)), true);
- return pair<iterator, bool>(__j, false);
- }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
- _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- _M_insert_equal(const _Val& __v)
- {
- _Link_type __x = _M_begin();
- _Link_type __y = _M_end();
- while (__x != 0)
- {
- __y = __x;
- __x = _M_impl._M_key_compare(_KeyOfValue()(__v), _S_key(__x)) ?
- _S_left(__x) : _S_right(__x);
- }
- return _M_insert_(__x, __y, (__v));
- }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
- _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- _M_insert_unique_(const_iterator __position, const _Val& __v)
- {
- if (__position._M_node == _M_end())
- {
- if (size() > 0
- && _M_impl._M_key_compare(_S_key(_M_rightmost()),
- _KeyOfValue()(__v)))
- return _M_insert_(0, _M_rightmost(), (__v));
- else
- return _M_insert_unique((__v)).first;
- }
- else if (_M_impl._M_key_compare(_KeyOfValue()(__v),
- _S_key(__position._M_node)))
- {
- const_iterator __before = __position;
- if (__position._M_node == _M_leftmost())
- return _M_insert_(_M_leftmost(), _M_leftmost(),
- (__v));
- else if (_M_impl._M_key_compare(_S_key((--__before)._M_node),
- _KeyOfValue()(__v)))
- {
- if (_S_right(__before._M_node) == 0)
- return _M_insert_(0, __before._M_node,
- (__v));
- else
- return _M_insert_(__position._M_node,
- __position._M_node,
- (__v));
- }
- else
- return _M_insert_unique((__v)).first;
- }
- else if (_M_impl._M_key_compare(_S_key(__position._M_node),
- _KeyOfValue()(__v)))
- {
- const_iterator __after = __position;
- if (__position._M_node == _M_rightmost())
- return _M_insert_(0, _M_rightmost(),
- (__v));
- else if (_M_impl._M_key_compare(_KeyOfValue()(__v),
- _S_key((++__after)._M_node)))
- {
- if (_S_right(__position._M_node) == 0)
- return _M_insert_(0, __position._M_node,
- (__v));
- else
- return _M_insert_(__after._M_node, __after._M_node,
- (__v));
- }
- else
- return _M_insert_unique((__v)).first;
- }
- else
- return __position._M_const_cast();
- }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
- _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- _M_insert_equal_(const_iterator __position, const _Val& __v)
- {
- if (__position._M_node == _M_end())
- {
- if (size() > 0
- && !_M_impl._M_key_compare(_KeyOfValue()(__v),
- _S_key(_M_rightmost())))
- return _M_insert_(0, _M_rightmost(),
- (__v));
- else
- return _M_insert_equal((__v));
- }
- else if (!_M_impl._M_key_compare(_S_key(__position._M_node),
- _KeyOfValue()(__v)))
- {
- const_iterator __before = __position;
- if (__position._M_node == _M_leftmost())
- return _M_insert_(_M_leftmost(), _M_leftmost(),
- (__v));
- else if (!_M_impl._M_key_compare(_KeyOfValue()(__v),
- _S_key((--__before)._M_node)))
- {
- if (_S_right(__before._M_node) == 0)
- return _M_insert_(0, __before._M_node,
- (__v));
- else
- return _M_insert_(__position._M_node,
- __position._M_node,
- (__v));
- }
- else
- return _M_insert_equal((__v));
- }
- else
- {
- const_iterator __after = __position;
- if (__position._M_node == _M_rightmost())
- return _M_insert_(0, _M_rightmost(),
- (__v));
- else if (!_M_impl._M_key_compare(_S_key((++__after)._M_node),
- _KeyOfValue()(__v)))
- {
- if (_S_right(__position._M_node) == 0)
- return _M_insert_(0, __position._M_node,
- (__v));
- else
- return _M_insert_(__after._M_node, __after._M_node,
- (__v));
- }
- else
- return _M_insert_equal_lower((__v));
- }
- }
- template<typename _Key, typename _Val, typename _KoV,
- typename _Cmp, typename _Alloc>
- template<class _II>
- void
- _Rb_tree<_Key, _Val, _KoV, _Cmp, _Alloc>::
- _M_insert_unique(_II __first, _II __last)
- {
- for (; __first != __last; ++__first)
- _M_insert_unique_(end(), *__first);
- }
- template<typename _Key, typename _Val, typename _KoV,
- typename _Cmp, typename _Alloc>
- template<class _II>
- void
- _Rb_tree<_Key, _Val, _KoV, _Cmp, _Alloc>::
- _M_insert_equal(_II __first, _II __last)
- {
- for (; __first != __last; ++__first)
- _M_insert_equal_(end(), *__first);
- }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- void
- _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- _M_erase_aux(const_iterator __position)
- {
- _Link_type __y =
- static_cast<_Link_type>(_Rb_tree_rebalance_for_erase
- (const_cast<_Base_ptr>(__position._M_node),
- this->_M_impl._M_header));
- _M_destroy_node(__y);
- --_M_impl._M_node_count;
- }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- void
- _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- _M_erase_aux(const_iterator __first, const_iterator __last)
- {
- if (__first == begin() && __last == end())
- clear();
- else
- while (__first != __last)
- erase(__first++);
- }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type
- _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- erase(const _Key& __x)
- {
- pair<iterator, iterator> __p = equal_range(__x);
- const size_type __old_size = size();
- erase(__p.first, __p.second);
- return __old_size - size();
- }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- void
- _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- erase(const _Key* __first, const _Key* __last)
- {
- while (__first != __last)
- erase(*__first++);
- }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- typename _Rb_tree<_Key, _Val, _KeyOfValue,
- _Compare, _Alloc>::iterator
- _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- find(const _Key& __k)
- {
- iterator __j = _M_lower_bound(_M_begin(), _M_end(), __k);
- return (__j == end()
- || _M_impl._M_key_compare(__k,
- _S_key(__j._M_node))) ? end() : __j;
- }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- typename _Rb_tree<_Key, _Val, _KeyOfValue,
- _Compare, _Alloc>::const_iterator
- _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- find(const _Key& __k) const
- {
- const_iterator __j = _M_lower_bound(_M_begin(), _M_end(), __k);
- return (__j == end()
- || _M_impl._M_key_compare(__k,
- _S_key(__j._M_node))) ? end() : __j;
- }
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type
- _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- count(const _Key& __k) const
- {
- pair<const_iterator, const_iterator> __p = equal_range(__k);
- const size_type __n = std::distance(__p.first, __p.second);
- return __n;
- }
- __attribute__ ((__pure__)) unsigned int
- _Rb_tree_black_count(const _Rb_tree_node_base* __node,
- const _Rb_tree_node_base* __root) throw ();
- template<typename _Key, typename _Val, typename _KeyOfValue,
- typename _Compare, typename _Alloc>
- bool
- _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::__rb_verify() const
- {
- if (_M_impl._M_node_count == 0 || begin() == end())
- return _M_impl._M_node_count == 0 && begin() == end()
- && this->_M_impl._M_header._M_left == _M_end()
- && this->_M_impl._M_header._M_right == _M_end();
- unsigned int __len = _Rb_tree_black_count(_M_leftmost(), _M_root());
- for (const_iterator __it = begin(); __it != end(); ++__it)
- {
- _Const_Link_type __x = static_cast<_Const_Link_type>(__it._M_node);
- _Const_Link_type __L = _S_left(__x);
- _Const_Link_type __R = _S_right(__x);
- if (__x->_M_color == _S_red)
- if ((__L && __L->_M_color == _S_red)
- || (__R && __R->_M_color == _S_red))
- return false;
- if (__L && _M_impl._M_key_compare(_S_key(__x), _S_key(__L)))
- return false;
- if (__R && _M_impl._M_key_compare(_S_key(__R), _S_key(__x)))
- return false;
- if (!__L && !__R && _Rb_tree_black_count(__x, _M_root()) != __len)
- return false;
- }
- if (_M_leftmost() != _Rb_tree_node_base::_S_minimum(_M_root()))
- return false;
- if (_M_rightmost() != _Rb_tree_node_base::_S_maximum(_M_root()))
- return false;
- return true;
- }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template <typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
- typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
- class map
- {
- public:
- typedef _Key key_type;
- typedef _Tp mapped_type;
- typedef std::pair<const _Key, _Tp> value_type;
- typedef _Compare key_compare;
- typedef _Alloc allocator_type;
- private:
- typedef typename _Alloc::value_type _Alloc_value_type;
- public:
- class value_compare
- : public std::binary_function<value_type, value_type, bool>
- {
- friend class map<_Key, _Tp, _Compare, _Alloc>;
- protected:
- _Compare comp;
- value_compare(_Compare __c)
- : comp(__c) { }
- public:
- bool operator()(const value_type& __x, const value_type& __y) const
- { return comp(__x.first, __y.first); }
- };
- private:
- typedef typename _Alloc::template rebind<value_type>::other
- _Pair_alloc_type;
- typedef _Rb_tree<key_type, value_type, _Select1st<value_type>,
- key_compare, _Pair_alloc_type> _Rep_type;
- _Rep_type _M_t;
- public:
- typedef typename _Pair_alloc_type::pointer pointer;
- typedef typename _Pair_alloc_type::const_pointer const_pointer;
- typedef typename _Pair_alloc_type::reference reference;
- typedef typename _Pair_alloc_type::const_reference const_reference;
- typedef typename _Rep_type::iterator iterator;
- typedef typename _Rep_type::const_iterator const_iterator;
- typedef typename _Rep_type::size_type size_type;
- typedef typename _Rep_type::difference_type difference_type;
- typedef typename _Rep_type::reverse_iterator reverse_iterator;
- typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
- map()
- : _M_t() { }
- explicit
- map(const _Compare& __comp,
- const allocator_type& __a = allocator_type())
- : _M_t(__comp, __a) { }
- map(const map& __x)
- : _M_t(__x._M_t) { }
- template<typename _InputIterator>
- map(_InputIterator __first, _InputIterator __last)
- : _M_t()
- { _M_t._M_insert_unique(__first, __last); }
- template<typename _InputIterator>
- map(_InputIterator __first, _InputIterator __last,
- const _Compare& __comp,
- const allocator_type& __a = allocator_type())
- : _M_t(__comp, __a)
- { _M_t._M_insert_unique(__first, __last); }
- map&
- operator=(const map& __x)
- {
- _M_t = __x._M_t;
- return *this;
- }
- allocator_type
- get_allocator() const
- { return _M_t.get_allocator(); }
- iterator
- begin()
- { return _M_t.begin(); }
- const_iterator
- begin() const
- { return _M_t.begin(); }
- iterator
- end()
- { return _M_t.end(); }
- const_iterator
- end() const
- { return _M_t.end(); }
- reverse_iterator
- rbegin()
- { return _M_t.rbegin(); }
- const_reverse_iterator
- rbegin() const
- { return _M_t.rbegin(); }
- reverse_iterator
- rend()
- { return _M_t.rend(); }
- const_reverse_iterator
- rend() const
- { return _M_t.rend(); }
- bool
- empty() const
- { return _M_t.empty(); }
- size_type
- size() const
- { return _M_t.size(); }
- size_type
- max_size() const
- { return _M_t.max_size(); }
- mapped_type&
- operator[](const key_type& __k)
- {
- iterator __i = lower_bound(__k);
- if (__i == end() || key_comp()(__k, (*__i).first))
- __i = insert(__i, value_type(__k, mapped_type()));
- return (*__i).second;
- }
- mapped_type&
- at(const key_type& __k)
- {
- iterator __i = lower_bound(__k);
- if (__i == end() || key_comp()(__k, (*__i).first))
- __throw_out_of_range(("map::at"));
- return (*__i).second;
- }
- const mapped_type&
- at(const key_type& __k) const
- {
- const_iterator __i = lower_bound(__k);
- if (__i == end() || key_comp()(__k, (*__i).first))
- __throw_out_of_range(("map::at"));
- return (*__i).second;
- }
- std::pair<iterator, bool>
- insert(const value_type& __x)
- { return _M_t._M_insert_unique(__x); }
- iterator
- insert(iterator __position, const value_type& __x)
- { return _M_t._M_insert_unique_(__position, __x); }
- template<typename _InputIterator>
- void
- insert(_InputIterator __first, _InputIterator __last)
- { _M_t._M_insert_unique(__first, __last); }
- void
- erase(iterator __position)
- { _M_t.erase(__position); }
- size_type
- erase(const key_type& __x)
- { return _M_t.erase(__x); }
- void
- erase(iterator __first, iterator __last)
- { _M_t.erase(__first, __last); }
- void
- swap(map& __x)
- { _M_t.swap(__x._M_t); }
- void
- clear()
- { _M_t.clear(); }
- key_compare
- key_comp() const
- { return _M_t.key_comp(); }
- value_compare
- value_comp() const
- { return value_compare(_M_t.key_comp()); }
- iterator
- find(const key_type& __x)
- { return _M_t.find(__x); }
- const_iterator
- find(const key_type& __x) const
- { return _M_t.find(__x); }
- size_type
- count(const key_type& __x) const
- { return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
- iterator
- lower_bound(const key_type& __x)
- { return _M_t.lower_bound(__x); }
- const_iterator
- lower_bound(const key_type& __x) const
- { return _M_t.lower_bound(__x); }
- iterator
- upper_bound(const key_type& __x)
- { return _M_t.upper_bound(__x); }
- const_iterator
- upper_bound(const key_type& __x) const
- { return _M_t.upper_bound(__x); }
- std::pair<iterator, iterator>
- equal_range(const key_type& __x)
- { return _M_t.equal_range(__x); }
- std::pair<const_iterator, const_iterator>
- equal_range(const key_type& __x) const
- { return _M_t.equal_range(__x); }
- template<typename _K1, typename _T1, typename _C1, typename _A1>
- friend bool
- operator==(const map<_K1, _T1, _C1, _A1>&,
- const map<_K1, _T1, _C1, _A1>&);
- template<typename _K1, typename _T1, typename _C1, typename _A1>
- friend bool
- operator<(const map<_K1, _T1, _C1, _A1>&,
- const map<_K1, _T1, _C1, _A1>&);
- };
- template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
- inline bool
- operator==(const map<_Key, _Tp, _Compare, _Alloc>& __x,
- const map<_Key, _Tp, _Compare, _Alloc>& __y)
- { return __x._M_t == __y._M_t; }
- template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
- inline bool
- operator<(const map<_Key, _Tp, _Compare, _Alloc>& __x,
- const map<_Key, _Tp, _Compare, _Alloc>& __y)
- { return __x._M_t < __y._M_t; }
- template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
- inline bool
- operator!=(const map<_Key, _Tp, _Compare, _Alloc>& __x,
- const map<_Key, _Tp, _Compare, _Alloc>& __y)
- { return !(__x == __y); }
- template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
- inline bool
- operator>(const map<_Key, _Tp, _Compare, _Alloc>& __x,
- const map<_Key, _Tp, _Compare, _Alloc>& __y)
- { return __y < __x; }
- template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
- inline bool
- operator<=(const map<_Key, _Tp, _Compare, _Alloc>& __x,
- const map<_Key, _Tp, _Compare, _Alloc>& __y)
- { return !(__y < __x); }
- template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
- inline bool
- operator>=(const map<_Key, _Tp, _Compare, _Alloc>& __x,
- const map<_Key, _Tp, _Compare, _Alloc>& __y)
- { return !(__x < __y); }
- template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
- inline void
- swap(map<_Key, _Tp, _Compare, _Alloc>& __x,
- map<_Key, _Tp, _Compare, _Alloc>& __y)
- { __x.swap(__y); }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template <typename _Key, typename _Tp,
- typename _Compare = std::less<_Key>,
- typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
- class multimap
- {
- public:
- typedef _Key key_type;
- typedef _Tp mapped_type;
- typedef std::pair<const _Key, _Tp> value_type;
- typedef _Compare key_compare;
- typedef _Alloc allocator_type;
- private:
- typedef typename _Alloc::value_type _Alloc_value_type;
- public:
- class value_compare
- : public std::binary_function<value_type, value_type, bool>
- {
- friend class multimap<_Key, _Tp, _Compare, _Alloc>;
- protected:
- _Compare comp;
- value_compare(_Compare __c)
- : comp(__c) { }
- public:
- bool operator()(const value_type& __x, const value_type& __y) const
- { return comp(__x.first, __y.first); }
- };
- private:
- typedef typename _Alloc::template rebind<value_type>::other
- _Pair_alloc_type;
- typedef _Rb_tree<key_type, value_type, _Select1st<value_type>,
- key_compare, _Pair_alloc_type> _Rep_type;
- _Rep_type _M_t;
- public:
- typedef typename _Pair_alloc_type::pointer pointer;
- typedef typename _Pair_alloc_type::const_pointer const_pointer;
- typedef typename _Pair_alloc_type::reference reference;
- typedef typename _Pair_alloc_type::const_reference const_reference;
- typedef typename _Rep_type::iterator iterator;
- typedef typename _Rep_type::const_iterator const_iterator;
- typedef typename _Rep_type::size_type size_type;
- typedef typename _Rep_type::difference_type difference_type;
- typedef typename _Rep_type::reverse_iterator reverse_iterator;
- typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
- multimap()
- : _M_t() { }
- explicit
- multimap(const _Compare& __comp,
- const allocator_type& __a = allocator_type())
- : _M_t(__comp, __a) { }
- multimap(const multimap& __x)
- : _M_t(__x._M_t) { }
- template<typename _InputIterator>
- multimap(_InputIterator __first, _InputIterator __last)
- : _M_t()
- { _M_t._M_insert_equal(__first, __last); }
- template<typename _InputIterator>
- multimap(_InputIterator __first, _InputIterator __last,
- const _Compare& __comp,
- const allocator_type& __a = allocator_type())
- : _M_t(__comp, __a)
- { _M_t._M_insert_equal(__first, __last); }
- multimap&
- operator=(const multimap& __x)
- {
- _M_t = __x._M_t;
- return *this;
- }
- allocator_type
- get_allocator() const
- { return _M_t.get_allocator(); }
- iterator
- begin()
- { return _M_t.begin(); }
- const_iterator
- begin() const
- { return _M_t.begin(); }
- iterator
- end()
- { return _M_t.end(); }
- const_iterator
- end() const
- { return _M_t.end(); }
- reverse_iterator
- rbegin()
- { return _M_t.rbegin(); }
- const_reverse_iterator
- rbegin() const
- { return _M_t.rbegin(); }
- reverse_iterator
- rend()
- { return _M_t.rend(); }
- const_reverse_iterator
- rend() const
- { return _M_t.rend(); }
- bool
- empty() const
- { return _M_t.empty(); }
- size_type
- size() const
- { return _M_t.size(); }
- size_type
- max_size() const
- { return _M_t.max_size(); }
- iterator
- insert(const value_type& __x)
- { return _M_t._M_insert_equal(__x); }
- iterator
- insert(iterator __position, const value_type& __x)
- { return _M_t._M_insert_equal_(__position, __x); }
- template<typename _InputIterator>
- void
- insert(_InputIterator __first, _InputIterator __last)
- { _M_t._M_insert_equal(__first, __last); }
- void
- erase(iterator __position)
- { _M_t.erase(__position); }
- size_type
- erase(const key_type& __x)
- { return _M_t.erase(__x); }
- void
- erase(iterator __first, iterator __last)
- { _M_t.erase(__first, __last); }
- void
- swap(multimap& __x)
- { _M_t.swap(__x._M_t); }
- void
- clear()
- { _M_t.clear(); }
- key_compare
- key_comp() const
- { return _M_t.key_comp(); }
- value_compare
- value_comp() const
- { return value_compare(_M_t.key_comp()); }
- iterator
- find(const key_type& __x)
- { return _M_t.find(__x); }
- const_iterator
- find(const key_type& __x) const
- { return _M_t.find(__x); }
- size_type
- count(const key_type& __x) const
- { return _M_t.count(__x); }
- iterator
- lower_bound(const key_type& __x)
- { return _M_t.lower_bound(__x); }
- const_iterator
- lower_bound(const key_type& __x) const
- { return _M_t.lower_bound(__x); }
- iterator
- upper_bound(const key_type& __x)
- { return _M_t.upper_bound(__x); }
- const_iterator
- upper_bound(const key_type& __x) const
- { return _M_t.upper_bound(__x); }
- std::pair<iterator, iterator>
- equal_range(const key_type& __x)
- { return _M_t.equal_range(__x); }
- std::pair<const_iterator, const_iterator>
- equal_range(const key_type& __x) const
- { return _M_t.equal_range(__x); }
- template<typename _K1, typename _T1, typename _C1, typename _A1>
- friend bool
- operator==(const multimap<_K1, _T1, _C1, _A1>&,
- const multimap<_K1, _T1, _C1, _A1>&);
- template<typename _K1, typename _T1, typename _C1, typename _A1>
- friend bool
- operator<(const multimap<_K1, _T1, _C1, _A1>&,
- const multimap<_K1, _T1, _C1, _A1>&);
- };
- template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
- inline bool
- operator==(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
- const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
- { return __x._M_t == __y._M_t; }
- template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
- inline bool
- operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
- const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
- { return __x._M_t < __y._M_t; }
- template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
- inline bool
- operator!=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
- const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
- { return !(__x == __y); }
- template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
- inline bool
- operator>(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
- const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
- { return __y < __x; }
- template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
- inline bool
- operator<=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
- const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
- { return !(__y < __x); }
- template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
- inline bool
- operator>=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
- const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
- { return !(__x < __y); }
- template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
- inline void
- swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x,
- multimap<_Key, _Tp, _Compare, _Alloc>& __y)
- { __x.swap(__y); }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _T1, typename _T2>
- inline void
- _Construct(_T1* __p, const _T2& __value)
- {
- ::new(static_cast<void*>(__p)) _T1(__value);
- }
- template<typename _Tp>
- inline void
- _Destroy(_Tp* __pointer)
- { __pointer->~_Tp(); }
- template<bool>
- struct _Destroy_aux
- {
- template<typename _ForwardIterator>
- static void
- __destroy(_ForwardIterator __first, _ForwardIterator __last)
- {
- for (; __first != __last; ++__first)
- std::_Destroy(std::__addressof(*__first));
- }
- };
- template<>
- struct _Destroy_aux<true>
- {
- template<typename _ForwardIterator>
- static void
- __destroy(_ForwardIterator, _ForwardIterator) { }
- };
- template<typename _ForwardIterator>
- inline void
- _Destroy(_ForwardIterator __first, _ForwardIterator __last)
- {
- typedef typename iterator_traits<_ForwardIterator>::value_type
- _Value_type;
- std::_Destroy_aux<__has_trivial_destructor(_Value_type)>::
- __destroy(__first, __last);
- }
- template <typename _Tp> class allocator;
- template<typename _ForwardIterator, typename _Allocator>
- void
- _Destroy(_ForwardIterator __first, _ForwardIterator __last,
- _Allocator& __alloc)
- {
- for (; __first != __last; ++__first)
- __alloc.destroy(std::__addressof(*__first));
- }
- template<typename _ForwardIterator, typename _Tp>
- inline void
- _Destroy(_ForwardIterator __first, _ForwardIterator __last,
- allocator<_Tp>&)
- {
- _Destroy(__first, __last);
- }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<bool _TrivialValueTypes>
- struct __uninitialized_copy
- {
- template<typename _InputIterator, typename _ForwardIterator>
- static _ForwardIterator
- __uninit_copy(_InputIterator __first, _InputIterator __last,
- _ForwardIterator __result)
- {
- _ForwardIterator __cur = __result;
- try
- {
- for (; __first != __last; ++__first, ++__cur)
- std::_Construct(std::__addressof(*__cur), *__first);
- return __cur;
- }
- catch(...)
- {
- std::_Destroy(__result, __cur);
- throw;
- }
- }
- };
- template<>
- struct __uninitialized_copy<true>
- {
- template<typename _InputIterator, typename _ForwardIterator>
- static _ForwardIterator
- __uninit_copy(_InputIterator __first, _InputIterator __last,
- _ForwardIterator __result)
- { return std::copy(__first, __last, __result); }
- };
- template<typename _InputIterator, typename _ForwardIterator>
- inline _ForwardIterator
- uninitialized_copy(_InputIterator __first, _InputIterator __last,
- _ForwardIterator __result)
- {
- typedef typename iterator_traits<_InputIterator>::value_type
- _ValueType1;
- typedef typename iterator_traits<_ForwardIterator>::value_type
- _ValueType2;
- return std::__uninitialized_copy<(__is_trivial(_ValueType1)
- && __is_trivial(_ValueType2))>::
- __uninit_copy(__first, __last, __result);
- }
- template<bool _TrivialValueType>
- struct __uninitialized_fill
- {
- template<typename _ForwardIterator, typename _Tp>
- static void
- __uninit_fill(_ForwardIterator __first, _ForwardIterator __last,
- const _Tp& __x)
- {
- _ForwardIterator __cur = __first;
- try
- {
- for (; __cur != __last; ++__cur)
- std::_Construct(std::__addressof(*__cur), __x);
- }
- catch(...)
- {
- std::_Destroy(__first, __cur);
- throw;
- }
- }
- };
- template<>
- struct __uninitialized_fill<true>
- {
- template<typename _ForwardIterator, typename _Tp>
- static void
- __uninit_fill(_ForwardIterator __first, _ForwardIterator __last,
- const _Tp& __x)
- { std::fill(__first, __last, __x); }
- };
- template<typename _ForwardIterator, typename _Tp>
- inline void
- uninitialized_fill(_ForwardIterator __first, _ForwardIterator __last,
- const _Tp& __x)
- {
- typedef typename iterator_traits<_ForwardIterator>::value_type
- _ValueType;
- std::__uninitialized_fill<__is_trivial(_ValueType)>::
- __uninit_fill(__first, __last, __x);
- }
- template<bool _TrivialValueType>
- struct __uninitialized_fill_n
- {
- template<typename _ForwardIterator, typename _Size, typename _Tp>
- static void
- __uninit_fill_n(_ForwardIterator __first, _Size __n,
- const _Tp& __x)
- {
- _ForwardIterator __cur = __first;
- try
- {
- for (; __n > 0; --__n, ++__cur)
- std::_Construct(std::__addressof(*__cur), __x);
- }
- catch(...)
- {
- std::_Destroy(__first, __cur);
- throw;
- }
- }
- };
- template<>
- struct __uninitialized_fill_n<true>
- {
- template<typename _ForwardIterator, typename _Size, typename _Tp>
- static void
- __uninit_fill_n(_ForwardIterator __first, _Size __n,
- const _Tp& __x)
- { std::fill_n(__first, __n, __x); }
- };
- template<typename _ForwardIterator, typename _Size, typename _Tp>
- inline void
- uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x)
- {
- typedef typename iterator_traits<_ForwardIterator>::value_type
- _ValueType;
- std::__uninitialized_fill_n<__is_trivial(_ValueType)>::
- __uninit_fill_n(__first, __n, __x);
- }
- template<typename _InputIterator, typename _ForwardIterator,
- typename _Allocator>
- _ForwardIterator
- __uninitialized_copy_a(_InputIterator __first, _InputIterator __last,
- _ForwardIterator __result, _Allocator& __alloc)
- {
- _ForwardIterator __cur = __result;
- try
- {
- for (; __first != __last; ++__first, ++__cur)
- __alloc.construct(std::__addressof(*__cur), *__first);
- return __cur;
- }
- catch(...)
- {
- std::_Destroy(__result, __cur, __alloc);
- throw;
- }
- }
- template<typename _InputIterator, typename _ForwardIterator, typename _Tp>
- inline _ForwardIterator
- __uninitialized_copy_a(_InputIterator __first, _InputIterator __last,
- _ForwardIterator __result, allocator<_Tp>&)
- { return std::uninitialized_copy(__first, __last, __result); }
- template<typename _InputIterator, typename _ForwardIterator,
- typename _Allocator>
- inline _ForwardIterator
- __uninitialized_move_a(_InputIterator __first, _InputIterator __last,
- _ForwardIterator __result, _Allocator& __alloc)
- {
- return std::__uninitialized_copy_a((__first),
- (__last),
- __result, __alloc);
- }
- template<typename _ForwardIterator, typename _Tp, typename _Allocator>
- void
- __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
- const _Tp& __x, _Allocator& __alloc)
- {
- _ForwardIterator __cur = __first;
- try
- {
- for (; __cur != __last; ++__cur)
- __alloc.construct(std::__addressof(*__cur), __x);
- }
- catch(...)
- {
- std::_Destroy(__first, __cur, __alloc);
- throw;
- }
- }
- template<typename _ForwardIterator, typename _Tp, typename _Tp2>
- inline void
- __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
- const _Tp& __x, allocator<_Tp2>&)
- { std::uninitialized_fill(__first, __last, __x); }
- template<typename _ForwardIterator, typename _Size, typename _Tp,
- typename _Allocator>
- void
- __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
- const _Tp& __x, _Allocator& __alloc)
- {
- _ForwardIterator __cur = __first;
- try
- {
- for (; __n > 0; --__n, ++__cur)
- __alloc.construct(std::__addressof(*__cur), __x);
- }
- catch(...)
- {
- std::_Destroy(__first, __cur, __alloc);
- throw;
- }
- }
- template<typename _ForwardIterator, typename _Size, typename _Tp,
- typename _Tp2>
- inline void
- __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
- const _Tp& __x, allocator<_Tp2>&)
- { std::uninitialized_fill_n(__first, __n, __x); }
- template<typename _InputIterator1, typename _InputIterator2,
- typename _ForwardIterator, typename _Allocator>
- inline _ForwardIterator
- __uninitialized_copy_move(_InputIterator1 __first1,
- _InputIterator1 __last1,
- _InputIterator2 __first2,
- _InputIterator2 __last2,
- _ForwardIterator __result,
- _Allocator& __alloc)
- {
- _ForwardIterator __mid = std::__uninitialized_copy_a(__first1, __last1,
- __result,
- __alloc);
- try
- {
- return std::__uninitialized_move_a(__first2, __last2, __mid, __alloc);
- }
- catch(...)
- {
- std::_Destroy(__result, __mid, __alloc);
- throw;
- }
- }
- template<typename _InputIterator1, typename _InputIterator2,
- typename _ForwardIterator, typename _Allocator>
- inline _ForwardIterator
- __uninitialized_move_copy(_InputIterator1 __first1,
- _InputIterator1 __last1,
- _InputIterator2 __first2,
- _InputIterator2 __last2,
- _ForwardIterator __result,
- _Allocator& __alloc)
- {
- _ForwardIterator __mid = std::__uninitialized_move_a(__first1, __last1,
- __result,
- __alloc);
- try
- {
- return std::__uninitialized_copy_a(__first2, __last2, __mid, __alloc);
- }
- catch(...)
- {
- std::_Destroy(__result, __mid, __alloc);
- throw;
- }
- }
- template<typename _ForwardIterator, typename _Tp, typename _InputIterator,
- typename _Allocator>
- inline _ForwardIterator
- __uninitialized_fill_move(_ForwardIterator __result, _ForwardIterator __mid,
- const _Tp& __x, _InputIterator __first,
- _InputIterator __last, _Allocator& __alloc)
- {
- std::__uninitialized_fill_a(__result, __mid, __x, __alloc);
- try
- {
- return std::__uninitialized_move_a(__first, __last, __mid, __alloc);
- }
- catch(...)
- {
- std::_Destroy(__result, __mid, __alloc);
- throw;
- }
- }
- template<typename _InputIterator, typename _ForwardIterator, typename _Tp,
- typename _Allocator>
- inline void
- __uninitialized_move_fill(_InputIterator __first1, _InputIterator __last1,
- _ForwardIterator __first2,
- _ForwardIterator __last2, const _Tp& __x,
- _Allocator& __alloc)
- {
- _ForwardIterator __mid2 = std::__uninitialized_move_a(__first1, __last1,
- __first2,
- __alloc);
- try
- {
- std::__uninitialized_fill_a(__mid2, __last2, __x, __alloc);
- }
- catch(...)
- {
- std::_Destroy(__first2, __mid2, __alloc);
- throw;
- }
- }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- inline size_t
- __deque_buf_size(size_t __size)
- { return (__size < 512
- ? size_t(512 / __size) : size_t(1)); }
- template<typename _Tp, typename _Ref, typename _Ptr>
- struct _Deque_iterator
- {
- typedef _Deque_iterator<_Tp, _Tp&, _Tp*> iterator;
- typedef _Deque_iterator<_Tp, const _Tp&, const _Tp*> const_iterator;
- static size_t _S_buffer_size()
- { return __deque_buf_size(sizeof(_Tp)); }
- typedef std::random_access_iterator_tag iterator_category;
- typedef _Tp value_type;
- typedef _Ptr pointer;
- typedef _Ref reference;
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
- typedef _Tp** _Map_pointer;
- typedef _Deque_iterator _Self;
- _Tp* _M_cur;
- _Tp* _M_first;
- _Tp* _M_last;
- _Map_pointer _M_node;
- _Deque_iterator(_Tp* __x, _Map_pointer __y)
- : _M_cur(__x), _M_first(*__y),
- _M_last(*__y + _S_buffer_size()), _M_node(__y) { }
- _Deque_iterator()
- : _M_cur(0), _M_first(0), _M_last(0), _M_node(0) { }
- _Deque_iterator(const iterator& __x)
- : _M_cur(__x._M_cur), _M_first(__x._M_first),
- _M_last(__x._M_last), _M_node(__x._M_node) { }
- reference
- operator*() const
- { return *_M_cur; }
- pointer
- operator->() const
- { return _M_cur; }
- _Self&
- operator++()
- {
- ++_M_cur;
- if (_M_cur == _M_last)
- {
- _M_set_node(_M_node + 1);
- _M_cur = _M_first;
- }
- return *this;
- }
- _Self
- operator++(int)
- {
- _Self __tmp = *this;
- ++*this;
- return __tmp;
- }
- _Self&
- operator--()
- {
- if (_M_cur == _M_first)
- {
- _M_set_node(_M_node - 1);
- _M_cur = _M_last;
- }
- --_M_cur;
- return *this;
- }
- _Self
- operator--(int)
- {
- _Self __tmp = *this;
- --*this;
- return __tmp;
- }
- _Self&
- operator+=(difference_type __n)
- {
- const difference_type __offset = __n + (_M_cur - _M_first);
- if (__offset >= 0 && __offset < difference_type(_S_buffer_size()))
- _M_cur += __n;
- else
- {
- const difference_type __node_offset =
- __offset > 0 ? __offset / difference_type(_S_buffer_size())
- : -difference_type((-__offset - 1)
- / _S_buffer_size()) - 1;
- _M_set_node(_M_node + __node_offset);
- _M_cur = _M_first + (__offset - __node_offset
- * difference_type(_S_buffer_size()));
- }
- return *this;
- }
- _Self
- operator+(difference_type __n) const
- {
- _Self __tmp = *this;
- return __tmp += __n;
- }
- _Self&
- operator-=(difference_type __n)
- { return *this += -__n; }
- _Self
- operator-(difference_type __n) const
- {
- _Self __tmp = *this;
- return __tmp -= __n;
- }
- reference
- operator[](difference_type __n) const
- { return *(*this + __n); }
- void
- _M_set_node(_Map_pointer __new_node)
- {
- _M_node = __new_node;
- _M_first = *__new_node;
- _M_last = _M_first + difference_type(_S_buffer_size());
- }
- };
- template<typename _Tp, typename _Ref, typename _Ptr>
- inline bool
- operator==(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
- const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
- { return __x._M_cur == __y._M_cur; }
- template<typename _Tp, typename _RefL, typename _PtrL,
- typename _RefR, typename _PtrR>
- inline bool
- operator==(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
- const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
- { return __x._M_cur == __y._M_cur; }
- template<typename _Tp, typename _Ref, typename _Ptr>
- inline bool
- operator!=(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
- const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
- { return !(__x == __y); }
- template<typename _Tp, typename _RefL, typename _PtrL,
- typename _RefR, typename _PtrR>
- inline bool
- operator!=(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
- const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
- { return !(__x == __y); }
- template<typename _Tp, typename _Ref, typename _Ptr>
- inline bool
- operator<(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
- const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
- { return (__x._M_node == __y._M_node) ? (__x._M_cur < __y._M_cur)
- : (__x._M_node < __y._M_node); }
- template<typename _Tp, typename _RefL, typename _PtrL,
- typename _RefR, typename _PtrR>
- inline bool
- operator<(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
- const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
- { return (__x._M_node == __y._M_node) ? (__x._M_cur < __y._M_cur)
- : (__x._M_node < __y._M_node); }
- template<typename _Tp, typename _Ref, typename _Ptr>
- inline bool
- operator>(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
- const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
- { return __y < __x; }
- template<typename _Tp, typename _RefL, typename _PtrL,
- typename _RefR, typename _PtrR>
- inline bool
- operator>(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
- const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
- { return __y < __x; }
- template<typename _Tp, typename _Ref, typename _Ptr>
- inline bool
- operator<=(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
- const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
- { return !(__y < __x); }
- template<typename _Tp, typename _RefL, typename _PtrL,
- typename _RefR, typename _PtrR>
- inline bool
- operator<=(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
- const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
- { return !(__y < __x); }
- template<typename _Tp, typename _Ref, typename _Ptr>
- inline bool
- operator>=(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
- const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
- { return !(__x < __y); }
- template<typename _Tp, typename _RefL, typename _PtrL,
- typename _RefR, typename _PtrR>
- inline bool
- operator>=(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
- const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
- { return !(__x < __y); }
- template<typename _Tp, typename _Ref, typename _Ptr>
- inline typename _Deque_iterator<_Tp, _Ref, _Ptr>::difference_type
- operator-(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
- const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
- {
- return typename _Deque_iterator<_Tp, _Ref, _Ptr>::difference_type
- (_Deque_iterator<_Tp, _Ref, _Ptr>::_S_buffer_size())
- * (__x._M_node - __y._M_node - 1) + (__x._M_cur - __x._M_first)
- + (__y._M_last - __y._M_cur);
- }
- template<typename _Tp, typename _RefL, typename _PtrL,
- typename _RefR, typename _PtrR>
- inline typename _Deque_iterator<_Tp, _RefL, _PtrL>::difference_type
- operator-(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
- const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
- {
- return typename _Deque_iterator<_Tp, _RefL, _PtrL>::difference_type
- (_Deque_iterator<_Tp, _RefL, _PtrL>::_S_buffer_size())
- * (__x._M_node - __y._M_node - 1) + (__x._M_cur - __x._M_first)
- + (__y._M_last - __y._M_cur);
- }
- template<typename _Tp, typename _Ref, typename _Ptr>
- inline _Deque_iterator<_Tp, _Ref, _Ptr>
- operator+(ptrdiff_t __n, const _Deque_iterator<_Tp, _Ref, _Ptr>& __x)
- { return __x + __n; }
- template<typename _Tp>
- void
- fill(const _Deque_iterator<_Tp, _Tp&, _Tp*>&,
- const _Deque_iterator<_Tp, _Tp&, _Tp*>&, const _Tp&);
- template<typename _Tp>
- _Deque_iterator<_Tp, _Tp&, _Tp*>
- copy(_Deque_iterator<_Tp, const _Tp&, const _Tp*>,
- _Deque_iterator<_Tp, const _Tp&, const _Tp*>,
- _Deque_iterator<_Tp, _Tp&, _Tp*>);
- template<typename _Tp>
- inline _Deque_iterator<_Tp, _Tp&, _Tp*>
- copy(_Deque_iterator<_Tp, _Tp&, _Tp*> __first,
- _Deque_iterator<_Tp, _Tp&, _Tp*> __last,
- _Deque_iterator<_Tp, _Tp&, _Tp*> __result)
- { return std::copy(_Deque_iterator<_Tp, const _Tp&, const _Tp*>(__first),
- _Deque_iterator<_Tp, const _Tp&, const _Tp*>(__last),
- __result); }
- template<typename _Tp>
- _Deque_iterator<_Tp, _Tp&, _Tp*>
- copy_backward(_Deque_iterator<_Tp, const _Tp&, const _Tp*>,
- _Deque_iterator<_Tp, const _Tp&, const _Tp*>,
- _Deque_iterator<_Tp, _Tp&, _Tp*>);
- template<typename _Tp>
- inline _Deque_iterator<_Tp, _Tp&, _Tp*>
- copy_backward(_Deque_iterator<_Tp, _Tp&, _Tp*> __first,
- _Deque_iterator<_Tp, _Tp&, _Tp*> __last,
- _Deque_iterator<_Tp, _Tp&, _Tp*> __result)
- { return std::copy_backward(_Deque_iterator<_Tp,
- const _Tp&, const _Tp*>(__first),
- _Deque_iterator<_Tp,
- const _Tp&, const _Tp*>(__last),
- __result); }
- template<typename _Tp, typename _Alloc>
- class _Deque_base
- {
- public:
- typedef _Alloc allocator_type;
- allocator_type
- get_allocator() const
- { return allocator_type(_M_get_Tp_allocator()); }
- typedef _Deque_iterator<_Tp, _Tp&, _Tp*> iterator;
- typedef _Deque_iterator<_Tp, const _Tp&, const _Tp*> const_iterator;
- _Deque_base()
- : _M_impl()
- { _M_initialize_map(0); }
- _Deque_base(size_t __num_elements)
- : _M_impl()
- { _M_initialize_map(__num_elements); }
- _Deque_base(const allocator_type& __a, size_t __num_elements)
- : _M_impl(__a)
- { _M_initialize_map(__num_elements); }
- _Deque_base(const allocator_type& __a)
- : _M_impl(__a)
- { }
- ~_Deque_base();
- protected:
- typedef typename _Alloc::template rebind<_Tp*>::other _Map_alloc_type;
- typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type;
- struct _Deque_impl
- : public _Tp_alloc_type
- {
- _Tp** _M_map;
- size_t _M_map_size;
- iterator _M_start;
- iterator _M_finish;
- _Deque_impl()
- : _Tp_alloc_type(), _M_map(0), _M_map_size(0),
- _M_start(), _M_finish()
- { }
- _Deque_impl(const _Tp_alloc_type& __a)
- : _Tp_alloc_type(__a), _M_map(0), _M_map_size(0),
- _M_start(), _M_finish()
- { }
- };
- _Tp_alloc_type&
- _M_get_Tp_allocator()
- { return *static_cast<_Tp_alloc_type*>(&this->_M_impl); }
- const _Tp_alloc_type&
- _M_get_Tp_allocator() const
- { return *static_cast<const _Tp_alloc_type*>(&this->_M_impl); }
- _Map_alloc_type
- _M_get_map_allocator() const
- { return _Map_alloc_type(_M_get_Tp_allocator()); }
- _Tp*
- _M_allocate_node()
- {
- return _M_impl._Tp_alloc_type::allocate(__deque_buf_size(sizeof(_Tp)));
- }
- void
- _M_deallocate_node(_Tp* __p)
- {
- _M_impl._Tp_alloc_type::deallocate(__p, __deque_buf_size(sizeof(_Tp)));
- }
- _Tp**
- _M_allocate_map(size_t __n)
- { return _M_get_map_allocator().allocate(__n); }
- void
- _M_deallocate_map(_Tp** __p, size_t __n)
- { _M_get_map_allocator().deallocate(__p, __n); }
- protected:
- void _M_initialize_map(size_t);
- void _M_create_nodes(_Tp** __nstart, _Tp** __nfinish);
- void _M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish);
- enum { _S_initial_map_size = 8 };
- _Deque_impl _M_impl;
- };
- template<typename _Tp, typename _Alloc>
- _Deque_base<_Tp, _Alloc>::
- ~_Deque_base()
- {
- if (this->_M_impl._M_map)
- {
- _M_destroy_nodes(this->_M_impl._M_start._M_node,
- this->_M_impl._M_finish._M_node + 1);
- _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size);
- }
- }
- template<typename _Tp, typename _Alloc>
- void
- _Deque_base<_Tp, _Alloc>::
- _M_initialize_map(size_t __num_elements)
- {
- const size_t __num_nodes = (__num_elements/ __deque_buf_size(sizeof(_Tp))
- + 1);
- this->_M_impl._M_map_size = std::max((size_t) _S_initial_map_size,
- size_t(__num_nodes + 2));
- this->_M_impl._M_map = _M_allocate_map(this->_M_impl._M_map_size);
- _Tp** __nstart = (this->_M_impl._M_map
- + (this->_M_impl._M_map_size - __num_nodes) / 2);
- _Tp** __nfinish = __nstart + __num_nodes;
- try
- { _M_create_nodes(__nstart, __nfinish); }
- catch(...)
- {
- _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size);
- this->_M_impl._M_map = 0;
- this->_M_impl._M_map_size = 0;
- throw;
- }
- this->_M_impl._M_start._M_set_node(__nstart);
- this->_M_impl._M_finish._M_set_node(__nfinish - 1);
- this->_M_impl._M_start._M_cur = _M_impl._M_start._M_first;
- this->_M_impl._M_finish._M_cur = (this->_M_impl._M_finish._M_first
- + __num_elements
- % __deque_buf_size(sizeof(_Tp)));
- }
- template<typename _Tp, typename _Alloc>
- void
- _Deque_base<_Tp, _Alloc>::
- _M_create_nodes(_Tp** __nstart, _Tp** __nfinish)
- {
- _Tp** __cur;
- try
- {
- for (__cur = __nstart; __cur < __nfinish; ++__cur)
- *__cur = this->_M_allocate_node();
- }
- catch(...)
- {
- _M_destroy_nodes(__nstart, __cur);
- throw;
- }
- }
- template<typename _Tp, typename _Alloc>
- void
- _Deque_base<_Tp, _Alloc>::
- _M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish)
- {
- for (_Tp** __n = __nstart; __n < __nfinish; ++__n)
- _M_deallocate_node(*__n);
- }
- template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
- class deque : protected _Deque_base<_Tp, _Alloc>
- {
- typedef typename _Alloc::value_type _Alloc_value_type;
- typedef _Deque_base<_Tp, _Alloc> _Base;
- typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
- public:
- typedef _Tp value_type;
- typedef typename _Tp_alloc_type::pointer pointer;
- typedef typename _Tp_alloc_type::const_pointer const_pointer;
- typedef typename _Tp_alloc_type::reference reference;
- typedef typename _Tp_alloc_type::const_reference const_reference;
- typedef typename _Base::iterator iterator;
- typedef typename _Base::const_iterator const_iterator;
- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
- typedef std::reverse_iterator<iterator> reverse_iterator;
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
- typedef _Alloc allocator_type;
- protected:
- typedef pointer* _Map_pointer;
- static size_t _S_buffer_size()
- { return __deque_buf_size(sizeof(_Tp)); }
- using _Base::_M_initialize_map;
- using _Base::_M_create_nodes;
- using _Base::_M_destroy_nodes;
- using _Base::_M_allocate_node;
- using _Base::_M_deallocate_node;
- using _Base::_M_allocate_map;
- using _Base::_M_deallocate_map;
- using _Base::_M_get_Tp_allocator;
- using _Base::_M_impl;
- public:
- deque()
- : _Base() { }
- explicit
- deque(const allocator_type& __a)
- : _Base(__a, 0) { }
- explicit
- deque(size_type __n, const value_type& __value = value_type(),
- const allocator_type& __a = allocator_type())
- : _Base(__a, __n)
- { _M_fill_initialize(__value); }
- deque(const deque& __x)
- : _Base(__x._M_get_Tp_allocator(), __x.size())
- { std::__uninitialized_copy_a(__x.begin(), __x.end(),
- this->_M_impl._M_start,
- _M_get_Tp_allocator()); }
- template<typename _InputIterator>
- deque(_InputIterator __first, _InputIterator __last,
- const allocator_type& __a = allocator_type())
- : _Base(__a)
- {
- typedef typename std::__is_integer<_InputIterator>::__type _Integral;
- _M_initialize_dispatch(__first, __last, _Integral());
- }
- ~deque()
- { _M_destroy_data(begin(), end(), _M_get_Tp_allocator()); }
- deque&
- operator=(const deque& __x);
- void
- assign(size_type __n, const value_type& __val)
- { _M_fill_assign(__n, __val); }
- template<typename _InputIterator>
- void
- assign(_InputIterator __first, _InputIterator __last)
- {
- typedef typename std::__is_integer<_InputIterator>::__type _Integral;
- _M_assign_dispatch(__first, __last, _Integral());
- }
- allocator_type
- get_allocator() const
- { return _Base::get_allocator(); }
- iterator
- begin()
- { return this->_M_impl._M_start; }
- const_iterator
- begin() const
- { return this->_M_impl._M_start; }
- iterator
- end()
- { return this->_M_impl._M_finish; }
- const_iterator
- end() const
- { return this->_M_impl._M_finish; }
- reverse_iterator
- rbegin()
- { return reverse_iterator(this->_M_impl._M_finish); }
- const_reverse_iterator
- rbegin() const
- { return const_reverse_iterator(this->_M_impl._M_finish); }
- reverse_iterator
- rend()
- { return reverse_iterator(this->_M_impl._M_start); }
- const_reverse_iterator
- rend() const
- { return const_reverse_iterator(this->_M_impl._M_start); }
- size_type
- size() const
- { return this->_M_impl._M_finish - this->_M_impl._M_start; }
- size_type
- max_size() const
- { return _M_get_Tp_allocator().max_size(); }
- void
- resize(size_type __new_size, value_type __x = value_type())
- {
- const size_type __len = size();
- if (__new_size > __len)
- insert(this->_M_impl._M_finish, __new_size - __len, __x);
- else if (__new_size < __len)
- _M_erase_at_end(this->_M_impl._M_start
- + difference_type(__new_size));
- }
- bool
- empty() const
- { return this->_M_impl._M_finish == this->_M_impl._M_start; }
- reference
- operator[](size_type __n)
- { return this->_M_impl._M_start[difference_type(__n)]; }
- const_reference
- operator[](size_type __n) const
- { return this->_M_impl._M_start[difference_type(__n)]; }
- protected:
- void
- _M_range_check(size_type __n) const
- {
- if (__n >= this->size())
- __throw_out_of_range(("deque::_M_range_check"));
- }
- public:
- reference
- at(size_type __n)
- {
- _M_range_check(__n);
- return (*this)[__n];
- }
- const_reference
- at(size_type __n) const
- {
- _M_range_check(__n);
- return (*this)[__n];
- }
- reference
- front()
- { return *begin(); }
- const_reference
- front() const
- { return *begin(); }
- reference
- back()
- {
- iterator __tmp = end();
- --__tmp;
- return *__tmp;
- }
- const_reference
- back() const
- {
- const_iterator __tmp = end();
- --__tmp;
- return *__tmp;
- }
- void
- push_front(const value_type& __x)
- {
- if (this->_M_impl._M_start._M_cur != this->_M_impl._M_start._M_first)
- {
- this->_M_impl.construct(this->_M_impl._M_start._M_cur - 1, __x);
- --this->_M_impl._M_start._M_cur;
- }
- else
- _M_push_front_aux(__x);
- }
- void
- push_back(const value_type& __x)
- {
- if (this->_M_impl._M_finish._M_cur
- != this->_M_impl._M_finish._M_last - 1)
- {
- this->_M_impl.construct(this->_M_impl._M_finish._M_cur, __x);
- ++this->_M_impl._M_finish._M_cur;
- }
- else
- _M_push_back_aux(__x);
- }
- void
- pop_front()
- {
- if (this->_M_impl._M_start._M_cur
- != this->_M_impl._M_start._M_last - 1)
- {
- this->_M_impl.destroy(this->_M_impl._M_start._M_cur);
- ++this->_M_impl._M_start._M_cur;
- }
- else
- _M_pop_front_aux();
- }
- void
- pop_back()
- {
- if (this->_M_impl._M_finish._M_cur
- != this->_M_impl._M_finish._M_first)
- {
- --this->_M_impl._M_finish._M_cur;
- this->_M_impl.destroy(this->_M_impl._M_finish._M_cur);
- }
- else
- _M_pop_back_aux();
- }
- iterator
- insert(iterator __position, const value_type& __x);
- void
- insert(iterator __position, size_type __n, const value_type& __x)
- { _M_fill_insert(__position, __n, __x); }
- template<typename _InputIterator>
- void
- insert(iterator __position, _InputIterator __first,
- _InputIterator __last)
- {
- typedef typename std::__is_integer<_InputIterator>::__type _Integral;
- _M_insert_dispatch(__position, __first, __last, _Integral());
- }
- iterator
- erase(iterator __position);
- iterator
- erase(iterator __first, iterator __last);
- void
- swap(deque& __x)
- {
- std::swap(this->_M_impl._M_start, __x._M_impl._M_start);
- std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish);
- std::swap(this->_M_impl._M_map, __x._M_impl._M_map);
- std::swap(this->_M_impl._M_map_size, __x._M_impl._M_map_size);
- std::__alloc_swap<_Tp_alloc_type>::_S_do_it(_M_get_Tp_allocator(),
- __x._M_get_Tp_allocator());
- }
- void
- clear()
- { _M_erase_at_end(begin()); }
- protected:
- template<typename _Integer>
- void
- _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
- {
- _M_initialize_map(static_cast<size_type>(__n));
- _M_fill_initialize(__x);
- }
- template<typename _InputIterator>
- void
- _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
- __false_type)
- {
- typedef typename std::iterator_traits<_InputIterator>::
- iterator_category _IterCategory;
- _M_range_initialize(__first, __last, _IterCategory());
- }
- template<typename _InputIterator>
- void
- _M_range_initialize(_InputIterator __first, _InputIterator __last,
- std::input_iterator_tag);
- template<typename _ForwardIterator>
- void
- _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
- std::forward_iterator_tag);
- void
- _M_fill_initialize(const value_type& __value);
- template<typename _Integer>
- void
- _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
- { _M_fill_assign(__n, __val); }
- template<typename _InputIterator>
- void
- _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
- __false_type)
- {
- typedef typename std::iterator_traits<_InputIterator>::
- iterator_category _IterCategory;
- _M_assign_aux(__first, __last, _IterCategory());
- }
- template<typename _InputIterator>
- void
- _M_assign_aux(_InputIterator __first, _InputIterator __last,
- std::input_iterator_tag);
- template<typename _ForwardIterator>
- void
- _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
- std::forward_iterator_tag)
- {
- const size_type __len = std::distance(__first, __last);
- if (__len > size())
- {
- _ForwardIterator __mid = __first;
- std::advance(__mid, size());
- std::copy(__first, __mid, begin());
- insert(end(), __mid, __last);
- }
- else
- _M_erase_at_end(std::copy(__first, __last, begin()));
- }
- void
- _M_fill_assign(size_type __n, const value_type& __val)
- {
- if (__n > size())
- {
- std::fill(begin(), end(), __val);
- insert(end(), __n - size(), __val);
- }
- else
- {
- _M_erase_at_end(begin() + difference_type(__n));
- std::fill(begin(), end(), __val);
- }
- }
- void _M_push_back_aux(const value_type&);
- void _M_push_front_aux(const value_type&);
- void _M_pop_back_aux();
- void _M_pop_front_aux();
- template<typename _Integer>
- void
- _M_insert_dispatch(iterator __pos,
- _Integer __n, _Integer __x, __true_type)
- { _M_fill_insert(__pos, __n, __x); }
- template<typename _InputIterator>
- void
- _M_insert_dispatch(iterator __pos,
- _InputIterator __first, _InputIterator __last,
- __false_type)
- {
- typedef typename std::iterator_traits<_InputIterator>::
- iterator_category _IterCategory;
- _M_range_insert_aux(__pos, __first, __last, _IterCategory());
- }
- template<typename _InputIterator>
- void
- _M_range_insert_aux(iterator __pos, _InputIterator __first,
- _InputIterator __last, std::input_iterator_tag);
- template<typename _ForwardIterator>
- void
- _M_range_insert_aux(iterator __pos, _ForwardIterator __first,
- _ForwardIterator __last, std::forward_iterator_tag);
- void
- _M_fill_insert(iterator __pos, size_type __n, const value_type& __x);
- iterator
- _M_insert_aux(iterator __pos, const value_type& __x);
- void
- _M_insert_aux(iterator __pos, size_type __n, const value_type& __x);
- template<typename _ForwardIterator>
- void
- _M_insert_aux(iterator __pos,
- _ForwardIterator __first, _ForwardIterator __last,
- size_type __n);
- void
- _M_destroy_data_aux(iterator __first, iterator __last);
- template<typename _Alloc1>
- void
- _M_destroy_data(iterator __first, iterator __last, const _Alloc1&)
- { _M_destroy_data_aux(__first, __last); }
- void
- _M_destroy_data(iterator __first, iterator __last,
- const std::allocator<_Tp>&)
- {
- if (!__has_trivial_destructor(value_type))
- _M_destroy_data_aux(__first, __last);
- }
- void
- _M_erase_at_begin(iterator __pos)
- {
- _M_destroy_data(begin(), __pos, _M_get_Tp_allocator());
- _M_destroy_nodes(this->_M_impl._M_start._M_node, __pos._M_node);
- this->_M_impl._M_start = __pos;
- }
- void
- _M_erase_at_end(iterator __pos)
- {
- _M_destroy_data(__pos, end(), _M_get_Tp_allocator());
- _M_destroy_nodes(__pos._M_node + 1,
- this->_M_impl._M_finish._M_node + 1);
- this->_M_impl._M_finish = __pos;
- }
- iterator
- _M_reserve_elements_at_front(size_type __n)
- {
- const size_type __vacancies = this->_M_impl._M_start._M_cur
- - this->_M_impl._M_start._M_first;
- if (__n > __vacancies)
- _M_new_elements_at_front(__n - __vacancies);
- return this->_M_impl._M_start - difference_type(__n);
- }
- iterator
- _M_reserve_elements_at_back(size_type __n)
- {
- const size_type __vacancies = (this->_M_impl._M_finish._M_last
- - this->_M_impl._M_finish._M_cur) - 1;
- if (__n > __vacancies)
- _M_new_elements_at_back(__n - __vacancies);
- return this->_M_impl._M_finish + difference_type(__n);
- }
- void
- _M_new_elements_at_front(size_type __new_elements);
- void
- _M_new_elements_at_back(size_type __new_elements);
- void
- _M_reserve_map_at_back(size_type __nodes_to_add = 1)
- {
- if (__nodes_to_add + 1 > this->_M_impl._M_map_size
- - (this->_M_impl._M_finish._M_node - this->_M_impl._M_map))
- _M_reallocate_map(__nodes_to_add, false);
- }
- void
- _M_reserve_map_at_front(size_type __nodes_to_add = 1)
- {
- if (__nodes_to_add > size_type(this->_M_impl._M_start._M_node
- - this->_M_impl._M_map))
- _M_reallocate_map(__nodes_to_add, true);
- }
- void
- _M_reallocate_map(size_type __nodes_to_add, bool __add_at_front);
- };
- template<typename _Tp, typename _Alloc>
- inline bool
- operator==(const deque<_Tp, _Alloc>& __x,
- const deque<_Tp, _Alloc>& __y)
- { return __x.size() == __y.size()
- && std::equal(__x.begin(), __x.end(), __y.begin()); }
- template<typename _Tp, typename _Alloc>
- inline bool
- operator<(const deque<_Tp, _Alloc>& __x,
- const deque<_Tp, _Alloc>& __y)
- { return std::lexicographical_compare(__x.begin(), __x.end(),
- __y.begin(), __y.end()); }
- template<typename _Tp, typename _Alloc>
- inline bool
- operator!=(const deque<_Tp, _Alloc>& __x,
- const deque<_Tp, _Alloc>& __y)
- { return !(__x == __y); }
- template<typename _Tp, typename _Alloc>
- inline bool
- operator>(const deque<_Tp, _Alloc>& __x,
- const deque<_Tp, _Alloc>& __y)
- { return __y < __x; }
- template<typename _Tp, typename _Alloc>
- inline bool
- operator<=(const deque<_Tp, _Alloc>& __x,
- const deque<_Tp, _Alloc>& __y)
- { return !(__y < __x); }
- template<typename _Tp, typename _Alloc>
- inline bool
- operator>=(const deque<_Tp, _Alloc>& __x,
- const deque<_Tp, _Alloc>& __y)
- { return !(__x < __y); }
- template<typename _Tp, typename _Alloc>
- inline void
- swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y)
- { __x.swap(__y); }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template <typename _Tp, typename _Alloc>
- deque<_Tp, _Alloc>&
- deque<_Tp, _Alloc>::
- operator=(const deque& __x)
- {
- const size_type __len = size();
- if (&__x != this)
- {
- if (__len >= __x.size())
- _M_erase_at_end(std::copy(__x.begin(), __x.end(),
- this->_M_impl._M_start));
- else
- {
- const_iterator __mid = __x.begin() + difference_type(__len);
- std::copy(__x.begin(), __mid, this->_M_impl._M_start);
- insert(this->_M_impl._M_finish, __mid, __x.end());
- }
- }
- return *this;
- }
- template <typename _Tp, typename _Alloc>
- typename deque<_Tp, _Alloc>::iterator
- deque<_Tp, _Alloc>::
- insert(iterator __position, const value_type& __x)
- {
- if (__position._M_cur == this->_M_impl._M_start._M_cur)
- {
- push_front(__x);
- return this->_M_impl._M_start;
- }
- else if (__position._M_cur == this->_M_impl._M_finish._M_cur)
- {
- push_back(__x);
- iterator __tmp = this->_M_impl._M_finish;
- --__tmp;
- return __tmp;
- }
- else
- return _M_insert_aux(__position, __x);
- }
- template <typename _Tp, typename _Alloc>
- typename deque<_Tp, _Alloc>::iterator
- deque<_Tp, _Alloc>::
- erase(iterator __position)
- {
- iterator __next = __position;
- ++__next;
- const difference_type __index = __position - begin();
- if (static_cast<size_type>(__index) < (size() >> 1))
- {
- if (__position != begin())
- std::copy_backward(begin(), __position, __next);
- pop_front();
- }
- else
- {
- if (__next != end())
- std::copy(__next, end(), __position);
- pop_back();
- }
- return begin() + __index;
- }
- template <typename _Tp, typename _Alloc>
- typename deque<_Tp, _Alloc>::iterator
- deque<_Tp, _Alloc>::
- erase(iterator __first, iterator __last)
- {
- if (__first == begin() && __last == end())
- {
- clear();
- return end();
- }
- else
- {
- const difference_type __n = __last - __first;
- const difference_type __elems_before = __first - begin();
- if (static_cast<size_type>(__elems_before) <= (size() - __n) / 2)
- {
- if (__first != begin())
- std::copy_backward(begin(), __first, __last);
- _M_erase_at_begin(begin() + __n);
- }
- else
- {
- if (__last != end())
- std::copy(__last, end(), __first);
- _M_erase_at_end(end() - __n);
- }
- return begin() + __elems_before;
- }
- }
- template <typename _Tp, class _Alloc>
- template <typename _InputIterator>
- void
- deque<_Tp, _Alloc>::
- _M_assign_aux(_InputIterator __first, _InputIterator __last,
- std::input_iterator_tag)
- {
- iterator __cur = begin();
- for (; __first != __last && __cur != end(); ++__cur, ++__first)
- *__cur = *__first;
- if (__first == __last)
- _M_erase_at_end(__cur);
- else
- insert(end(), __first, __last);
- }
- template <typename _Tp, typename _Alloc>
- void
- deque<_Tp, _Alloc>::
- _M_fill_insert(iterator __pos, size_type __n, const value_type& __x)
- {
- if (__pos._M_cur == this->_M_impl._M_start._M_cur)
- {
- iterator __new_start = _M_reserve_elements_at_front(__n);
- try
- {
- std::__uninitialized_fill_a(__new_start, this->_M_impl._M_start,
- __x, _M_get_Tp_allocator());
- this->_M_impl._M_start = __new_start;
- }
- catch(...)
- {
- _M_destroy_nodes(__new_start._M_node,
- this->_M_impl._M_start._M_node);
- throw;
- }
- }
- else if (__pos._M_cur == this->_M_impl._M_finish._M_cur)
- {
- iterator __new_finish = _M_reserve_elements_at_back(__n);
- try
- {
- std::__uninitialized_fill_a(this->_M_impl._M_finish,
- __new_finish, __x,
- _M_get_Tp_allocator());
- this->_M_impl._M_finish = __new_finish;
- }
- catch(...)
- {
- _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1,
- __new_finish._M_node + 1);
- throw;
- }
- }
- else
- _M_insert_aux(__pos, __n, __x);
- }
- template <typename _Tp, typename _Alloc>
- void
- deque<_Tp, _Alloc>::
- _M_fill_initialize(const value_type& __value)
- {
- _Map_pointer __cur;
- try
- {
- for (__cur = this->_M_impl._M_start._M_node;
- __cur < this->_M_impl._M_finish._M_node;
- ++__cur)
- std::__uninitialized_fill_a(*__cur, *__cur + _S_buffer_size(),
- __value, _M_get_Tp_allocator());
- std::__uninitialized_fill_a(this->_M_impl._M_finish._M_first,
- this->_M_impl._M_finish._M_cur,
- __value, _M_get_Tp_allocator());
- }
- catch(...)
- {
- std::_Destroy(this->_M_impl._M_start, iterator(*__cur, __cur),
- _M_get_Tp_allocator());
- throw;
- }
- }
- template <typename _Tp, typename _Alloc>
- template <typename _InputIterator>
- void
- deque<_Tp, _Alloc>::
- _M_range_initialize(_InputIterator __first, _InputIterator __last,
- std::input_iterator_tag)
- {
- this->_M_initialize_map(0);
- try
- {
- for (; __first != __last; ++__first)
- push_back(*__first);
- }
- catch(...)
- {
- clear();
- throw;
- }
- }
- template <typename _Tp, typename _Alloc>
- template <typename _ForwardIterator>
- void
- deque<_Tp, _Alloc>::
- _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
- std::forward_iterator_tag)
- {
- const size_type __n = std::distance(__first, __last);
- this->_M_initialize_map(__n);
- _Map_pointer __cur_node;
- try
- {
- for (__cur_node = this->_M_impl._M_start._M_node;
- __cur_node < this->_M_impl._M_finish._M_node;
- ++__cur_node)
- {
- _ForwardIterator __mid = __first;
- std::advance(__mid, _S_buffer_size());
- std::__uninitialized_copy_a(__first, __mid, *__cur_node,
- _M_get_Tp_allocator());
- __first = __mid;
- }
- std::__uninitialized_copy_a(__first, __last,
- this->_M_impl._M_finish._M_first,
- _M_get_Tp_allocator());
- }
- catch(...)
- {
- std::_Destroy(this->_M_impl._M_start,
- iterator(*__cur_node, __cur_node),
- _M_get_Tp_allocator());
- throw;
- }
- }
- template<typename _Tp, typename _Alloc>
- void
- deque<_Tp, _Alloc>::
- _M_push_back_aux(const value_type& __t)
- {
- _M_reserve_map_at_back();
- *(this->_M_impl._M_finish._M_node + 1) = this->_M_allocate_node();
- try
- {
- this->_M_impl.construct(this->_M_impl._M_finish._M_cur, __t);
- this->_M_impl._M_finish._M_set_node(this->_M_impl._M_finish._M_node
- + 1);
- this->_M_impl._M_finish._M_cur = this->_M_impl._M_finish._M_first;
- }
- catch(...)
- {
- _M_deallocate_node(*(this->_M_impl._M_finish._M_node + 1));
- throw;
- }
- }
- template<typename _Tp, typename _Alloc>
- void
- deque<_Tp, _Alloc>::
- _M_push_front_aux(const value_type& __t)
- {
- _M_reserve_map_at_front();
- *(this->_M_impl._M_start._M_node - 1) = this->_M_allocate_node();
- try
- {
- this->_M_impl._M_start._M_set_node(this->_M_impl._M_start._M_node
- - 1);
- this->_M_impl._M_start._M_cur = this->_M_impl._M_start._M_last - 1;
- this->_M_impl.construct(this->_M_impl._M_start._M_cur, __t);
- }
- catch(...)
- {
- ++this->_M_impl._M_start;
- _M_deallocate_node(*(this->_M_impl._M_start._M_node - 1));
- throw;
- }
- }
- template <typename _Tp, typename _Alloc>
- void deque<_Tp, _Alloc>::
- _M_pop_back_aux()
- {
- _M_deallocate_node(this->_M_impl._M_finish._M_first);
- this->_M_impl._M_finish._M_set_node(this->_M_impl._M_finish._M_node - 1);
- this->_M_impl._M_finish._M_cur = this->_M_impl._M_finish._M_last - 1;
- this->_M_impl.destroy(this->_M_impl._M_finish._M_cur);
- }
- template <typename _Tp, typename _Alloc>
- void deque<_Tp, _Alloc>::
- _M_pop_front_aux()
- {
- this->_M_impl.destroy(this->_M_impl._M_start._M_cur);
- _M_deallocate_node(this->_M_impl._M_start._M_first);
- this->_M_impl._M_start._M_set_node(this->_M_impl._M_start._M_node + 1);
- this->_M_impl._M_start._M_cur = this->_M_impl._M_start._M_first;
- }
- template <typename _Tp, typename _Alloc>
- template <typename _InputIterator>
- void
- deque<_Tp, _Alloc>::
- _M_range_insert_aux(iterator __pos,
- _InputIterator __first, _InputIterator __last,
- std::input_iterator_tag)
- { std::copy(__first, __last, std::inserter(*this, __pos)); }
- template <typename _Tp, typename _Alloc>
- template <typename _ForwardIterator>
- void
- deque<_Tp, _Alloc>::
- _M_range_insert_aux(iterator __pos,
- _ForwardIterator __first, _ForwardIterator __last,
- std::forward_iterator_tag)
- {
- const size_type __n = std::distance(__first, __last);
- if (__pos._M_cur == this->_M_impl._M_start._M_cur)
- {
- iterator __new_start = _M_reserve_elements_at_front(__n);
- try
- {
- std::__uninitialized_copy_a(__first, __last, __new_start,
- _M_get_Tp_allocator());
- this->_M_impl._M_start = __new_start;
- }
- catch(...)
- {
- _M_destroy_nodes(__new_start._M_node,
- this->_M_impl._M_start._M_node);
- throw;
- }
- }
- else if (__pos._M_cur == this->_M_impl._M_finish._M_cur)
- {
- iterator __new_finish = _M_reserve_elements_at_back(__n);
- try
- {
- std::__uninitialized_copy_a(__first, __last,
- this->_M_impl._M_finish,
- _M_get_Tp_allocator());
- this->_M_impl._M_finish = __new_finish;
- }
- catch(...)
- {
- _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1,
- __new_finish._M_node + 1);
- throw;
- }
- }
- else
- _M_insert_aux(__pos, __first, __last, __n);
- }
- template<typename _Tp, typename _Alloc>
- typename deque<_Tp, _Alloc>::iterator
- deque<_Tp, _Alloc>::
- _M_insert_aux(iterator __pos, const value_type& __x)
- {
- value_type __x_copy = __x;
- difference_type __index = __pos - this->_M_impl._M_start;
- if (static_cast<size_type>(__index) < size() / 2)
- {
- push_front((front()));
- iterator __front1 = this->_M_impl._M_start;
- ++__front1;
- iterator __front2 = __front1;
- ++__front2;
- __pos = this->_M_impl._M_start + __index;
- iterator __pos1 = __pos;
- ++__pos1;
- std::copy(__front2, __pos1, __front1);
- }
- else
- {
- push_back((back()));
- iterator __back1 = this->_M_impl._M_finish;
- --__back1;
- iterator __back2 = __back1;
- --__back2;
- __pos = this->_M_impl._M_start + __index;
- std::copy_backward(__pos, __back2, __back1);
- }
- *__pos = (__x_copy);
- return __pos;
- }
- template <typename _Tp, typename _Alloc>
- void
- deque<_Tp, _Alloc>::
- _M_insert_aux(iterator __pos, size_type __n, const value_type& __x)
- {
- const difference_type __elems_before = __pos - this->_M_impl._M_start;
- const size_type __length = this->size();
- value_type __x_copy = __x;
- if (__elems_before < difference_type(__length / 2))
- {
- iterator __new_start = _M_reserve_elements_at_front(__n);
- iterator __old_start = this->_M_impl._M_start;
- __pos = this->_M_impl._M_start + __elems_before;
- try
- {
- if (__elems_before >= difference_type(__n))
- {
- iterator __start_n = (this->_M_impl._M_start
- + difference_type(__n));
- std::__uninitialized_move_a(this->_M_impl._M_start,
- __start_n, __new_start,
- _M_get_Tp_allocator());
- this->_M_impl._M_start = __new_start;
- std::copy(__start_n, __pos, __old_start);
- std::fill(__pos - difference_type(__n), __pos, __x_copy);
- }
- else
- {
- std::__uninitialized_move_fill(this->_M_impl._M_start,
- __pos, __new_start,
- this->_M_impl._M_start,
- __x_copy,
- _M_get_Tp_allocator());
- this->_M_impl._M_start = __new_start;
- std::fill(__old_start, __pos, __x_copy);
- }
- }
- catch(...)
- {
- _M_destroy_nodes(__new_start._M_node,
- this->_M_impl._M_start._M_node);
- throw;
- }
- }
- else
- {
- iterator __new_finish = _M_reserve_elements_at_back(__n);
- iterator __old_finish = this->_M_impl._M_finish;
- const difference_type __elems_after =
- difference_type(__length) - __elems_before;
- __pos = this->_M_impl._M_finish - __elems_after;
- try
- {
- if (__elems_after > difference_type(__n))
- {
- iterator __finish_n = (this->_M_impl._M_finish
- - difference_type(__n));
- std::__uninitialized_move_a(__finish_n,
- this->_M_impl._M_finish,
- this->_M_impl._M_finish,
- _M_get_Tp_allocator());
- this->_M_impl._M_finish = __new_finish;
- std::copy_backward(__pos, __finish_n, __old_finish);
- std::fill(__pos, __pos + difference_type(__n), __x_copy);
- }
- else
- {
- std::__uninitialized_fill_move(this->_M_impl._M_finish,
- __pos + difference_type(__n),
- __x_copy, __pos,
- this->_M_impl._M_finish,
- _M_get_Tp_allocator());
- this->_M_impl._M_finish = __new_finish;
- std::fill(__pos, __old_finish, __x_copy);
- }
- }
- catch(...)
- {
- _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1,
- __new_finish._M_node + 1);
- throw;
- }
- }
- }
- template <typename _Tp, typename _Alloc>
- template <typename _ForwardIterator>
- void
- deque<_Tp, _Alloc>::
- _M_insert_aux(iterator __pos,
- _ForwardIterator __first, _ForwardIterator __last,
- size_type __n)
- {
- const difference_type __elemsbefore = __pos - this->_M_impl._M_start;
- const size_type __length = size();
- if (static_cast<size_type>(__elemsbefore) < __length / 2)
- {
- iterator __new_start = _M_reserve_elements_at_front(__n);
- iterator __old_start = this->_M_impl._M_start;
- __pos = this->_M_impl._M_start + __elemsbefore;
- try
- {
- if (__elemsbefore >= difference_type(__n))
- {
- iterator __start_n = (this->_M_impl._M_start
- + difference_type(__n));
- std::__uninitialized_move_a(this->_M_impl._M_start,
- __start_n, __new_start,
- _M_get_Tp_allocator());
- this->_M_impl._M_start = __new_start;
- std::copy(__start_n, __pos, __old_start);
- std::copy(__first, __last, __pos - difference_type(__n));
- }
- else
- {
- _ForwardIterator __mid = __first;
- std::advance(__mid, difference_type(__n) - __elemsbefore);
- std::__uninitialized_move_copy(this->_M_impl._M_start,
- __pos, __first, __mid,
- __new_start,
- _M_get_Tp_allocator());
- this->_M_impl._M_start = __new_start;
- std::copy(__mid, __last, __old_start);
- }
- }
- catch(...)
- {
- _M_destroy_nodes(__new_start._M_node,
- this->_M_impl._M_start._M_node);
- throw;
- }
- }
- else
- {
- iterator __new_finish = _M_reserve_elements_at_back(__n);
- iterator __old_finish = this->_M_impl._M_finish;
- const difference_type __elemsafter =
- difference_type(__length) - __elemsbefore;
- __pos = this->_M_impl._M_finish - __elemsafter;
- try
- {
- if (__elemsafter > difference_type(__n))
- {
- iterator __finish_n = (this->_M_impl._M_finish
- - difference_type(__n));
- std::__uninitialized_move_a(__finish_n,
- this->_M_impl._M_finish,
- this->_M_impl._M_finish,
- _M_get_Tp_allocator());
- this->_M_impl._M_finish = __new_finish;
- std::copy_backward(__pos, __finish_n, __old_finish);
- std::copy(__first, __last, __pos);
- }
- else
- {
- _ForwardIterator __mid = __first;
- std::advance(__mid, __elemsafter);
- std::__uninitialized_copy_move(__mid, __last, __pos,
- this->_M_impl._M_finish,
- this->_M_impl._M_finish,
- _M_get_Tp_allocator());
- this->_M_impl._M_finish = __new_finish;
- std::copy(__first, __mid, __pos);
- }
- }
- catch(...)
- {
- _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1,
- __new_finish._M_node + 1);
- throw;
- }
- }
- }
- template<typename _Tp, typename _Alloc>
- void
- deque<_Tp, _Alloc>::
- _M_destroy_data_aux(iterator __first, iterator __last)
- {
- for (_Map_pointer __node = __first._M_node + 1;
- __node < __last._M_node; ++__node)
- std::_Destroy(*__node, *__node + _S_buffer_size(),
- _M_get_Tp_allocator());
- if (__first._M_node != __last._M_node)
- {
- std::_Destroy(__first._M_cur, __first._M_last,
- _M_get_Tp_allocator());
- std::_Destroy(__last._M_first, __last._M_cur,
- _M_get_Tp_allocator());
- }
- else
- std::_Destroy(__first._M_cur, __last._M_cur,
- _M_get_Tp_allocator());
- }
- template <typename _Tp, typename _Alloc>
- void
- deque<_Tp, _Alloc>::
- _M_new_elements_at_front(size_type __new_elems)
- {
- if (this->max_size() - this->size() < __new_elems)
- __throw_length_error(("deque::_M_new_elements_at_front"));
- const size_type __new_nodes = ((__new_elems + _S_buffer_size() - 1)
- / _S_buffer_size());
- _M_reserve_map_at_front(__new_nodes);
- size_type __i;
- try
- {
- for (__i = 1; __i <= __new_nodes; ++__i)
- *(this->_M_impl._M_start._M_node - __i) = this->_M_allocate_node();
- }
- catch(...)
- {
- for (size_type __j = 1; __j < __i; ++__j)
- _M_deallocate_node(*(this->_M_impl._M_start._M_node - __j));
- throw;
- }
- }
- template <typename _Tp, typename _Alloc>
- void
- deque<_Tp, _Alloc>::
- _M_new_elements_at_back(size_type __new_elems)
- {
- if (this->max_size() - this->size() < __new_elems)
- __throw_length_error(("deque::_M_new_elements_at_back"));
- const size_type __new_nodes = ((__new_elems + _S_buffer_size() - 1)
- / _S_buffer_size());
- _M_reserve_map_at_back(__new_nodes);
- size_type __i;
- try
- {
- for (__i = 1; __i <= __new_nodes; ++__i)
- *(this->_M_impl._M_finish._M_node + __i) = this->_M_allocate_node();
- }
- catch(...)
- {
- for (size_type __j = 1; __j < __i; ++__j)
- _M_deallocate_node(*(this->_M_impl._M_finish._M_node + __j));
- throw;
- }
- }
- template <typename _Tp, typename _Alloc>
- void
- deque<_Tp, _Alloc>::
- _M_reallocate_map(size_type __nodes_to_add, bool __add_at_front)
- {
- const size_type __old_num_nodes
- = this->_M_impl._M_finish._M_node - this->_M_impl._M_start._M_node + 1;
- const size_type __new_num_nodes = __old_num_nodes + __nodes_to_add;
- _Map_pointer __new_nstart;
- if (this->_M_impl._M_map_size > 2 * __new_num_nodes)
- {
- __new_nstart = this->_M_impl._M_map + (this->_M_impl._M_map_size
- - __new_num_nodes) / 2
- + (__add_at_front ? __nodes_to_add : 0);
- if (__new_nstart < this->_M_impl._M_start._M_node)
- std::copy(this->_M_impl._M_start._M_node,
- this->_M_impl._M_finish._M_node + 1,
- __new_nstart);
- else
- std::copy_backward(this->_M_impl._M_start._M_node,
- this->_M_impl._M_finish._M_node + 1,
- __new_nstart + __old_num_nodes);
- }
- else
- {
- size_type __new_map_size = this->_M_impl._M_map_size
- + std::max(this->_M_impl._M_map_size,
- __nodes_to_add) + 2;
- _Map_pointer __new_map = this->_M_allocate_map(__new_map_size);
- __new_nstart = __new_map + (__new_map_size - __new_num_nodes) / 2
- + (__add_at_front ? __nodes_to_add : 0);
- std::copy(this->_M_impl._M_start._M_node,
- this->_M_impl._M_finish._M_node + 1,
- __new_nstart);
- _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size);
- this->_M_impl._M_map = __new_map;
- this->_M_impl._M_map_size = __new_map_size;
- }
- this->_M_impl._M_start._M_set_node(__new_nstart);
- this->_M_impl._M_finish._M_set_node(__new_nstart + __old_num_nodes - 1);
- }
- template<typename _Tp>
- void
- fill(const _Deque_iterator<_Tp, _Tp&, _Tp*>& __first,
- const _Deque_iterator<_Tp, _Tp&, _Tp*>& __last, const _Tp& __value)
- {
- typedef typename _Deque_iterator<_Tp, _Tp&, _Tp*>::_Self _Self;
- for (typename _Self::_Map_pointer __node = __first._M_node + 1;
- __node < __last._M_node; ++__node)
- std::fill(*__node, *__node + _Self::_S_buffer_size(), __value);
- if (__first._M_node != __last._M_node)
- {
- std::fill(__first._M_cur, __first._M_last, __value);
- std::fill(__last._M_first, __last._M_cur, __value);
- }
- else
- std::fill(__first._M_cur, __last._M_cur, __value);
- }
- template<typename _Tp>
- _Deque_iterator<_Tp, _Tp&, _Tp*>
- copy(_Deque_iterator<_Tp, const _Tp&, const _Tp*> __first,
- _Deque_iterator<_Tp, const _Tp&, const _Tp*> __last,
- _Deque_iterator<_Tp, _Tp&, _Tp*> __result)
- {
- typedef typename _Deque_iterator<_Tp, _Tp&, _Tp*>::_Self _Self;
- typedef typename _Self::difference_type difference_type;
- difference_type __len = __last - __first;
- while (__len > 0)
- {
- const difference_type __clen
- = std::min(__len, std::min(__first._M_last - __first._M_cur,
- __result._M_last - __result._M_cur));
- std::copy(__first._M_cur, __first._M_cur + __clen, __result._M_cur);
- __first += __clen;
- __result += __clen;
- __len -= __clen;
- }
- return __result;
- }
- template<typename _Tp>
- _Deque_iterator<_Tp, _Tp&, _Tp*>
- copy_backward(_Deque_iterator<_Tp, const _Tp&, const _Tp*> __first,
- _Deque_iterator<_Tp, const _Tp&, const _Tp*> __last,
- _Deque_iterator<_Tp, _Tp&, _Tp*> __result)
- {
- typedef typename _Deque_iterator<_Tp, _Tp&, _Tp*>::_Self _Self;
- typedef typename _Self::difference_type difference_type;
- difference_type __len = __last - __first;
- while (__len > 0)
- {
- difference_type __llen = __last._M_cur - __last._M_first;
- _Tp* __lend = __last._M_cur;
- difference_type __rlen = __result._M_cur - __result._M_first;
- _Tp* __rend = __result._M_cur;
- if (!__llen)
- {
- __llen = _Self::_S_buffer_size();
- __lend = *(__last._M_node - 1) + __llen;
- }
- if (!__rlen)
- {
- __rlen = _Self::_S_buffer_size();
- __rend = *(__result._M_node - 1) + __rlen;
- }
- const difference_type __clen = std::min(__len,
- std::min(__llen, __rlen));
- std::copy_backward(__lend - __clen, __lend, __rend);
- __last -= __clen;
- __result -= __clen;
- __len -= __clen;
- }
- return __result;
- }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- namespace __detail
- {
- struct _List_node_base
- {
- _List_node_base* _M_next;
- _List_node_base* _M_prev;
- static void
- swap(_List_node_base& __x, _List_node_base& __y) throw ();
- void
- _M_transfer(_List_node_base* const __first,
- _List_node_base* const __last) throw ();
- void
- _M_reverse() throw ();
- void
- _M_hook(_List_node_base* const __position) throw ();
- void
- _M_unhook() throw ();
- };
- }
- template<typename _Tp>
- struct _List_node : public __detail::_List_node_base
- {
- _Tp _M_data;
- };
- template<typename _Tp>
- struct _List_iterator
- {
- typedef _List_iterator<_Tp> _Self;
- typedef _List_node<_Tp> _Node;
- typedef ptrdiff_t difference_type;
- typedef std::bidirectional_iterator_tag iterator_category;
- typedef _Tp value_type;
- typedef _Tp* pointer;
- typedef _Tp& reference;
- _List_iterator()
- : _M_node() { }
- explicit
- _List_iterator(__detail::_List_node_base* __x)
- : _M_node(__x) { }
- reference
- operator*() const
- { return static_cast<_Node*>(_M_node)->_M_data; }
- pointer
- operator->() const
- { return std::__addressof(static_cast<_Node*>(_M_node)->_M_data); }
- _Self&
- operator++()
- {
- _M_node = _M_node->_M_next;
- return *this;
- }
- _Self
- operator++(int)
- {
- _Self __tmp = *this;
- _M_node = _M_node->_M_next;
- return __tmp;
- }
- _Self&
- operator--()
- {
- _M_node = _M_node->_M_prev;
- return *this;
- }
- _Self
- operator--(int)
- {
- _Self __tmp = *this;
- _M_node = _M_node->_M_prev;
- return __tmp;
- }
- bool
- operator==(const _Self& __x) const
- { return _M_node == __x._M_node; }
- bool
- operator!=(const _Self& __x) const
- { return _M_node != __x._M_node; }
- __detail::_List_node_base* _M_node;
- };
- template<typename _Tp>
- struct _List_const_iterator
- {
- typedef _List_const_iterator<_Tp> _Self;
- typedef const _List_node<_Tp> _Node;
- typedef _List_iterator<_Tp> iterator;
- typedef ptrdiff_t difference_type;
- typedef std::bidirectional_iterator_tag iterator_category;
- typedef _Tp value_type;
- typedef const _Tp* pointer;
- typedef const _Tp& reference;
- _List_const_iterator()
- : _M_node() { }
- explicit
- _List_const_iterator(const __detail::_List_node_base* __x)
- : _M_node(__x) { }
- _List_const_iterator(const iterator& __x)
- : _M_node(__x._M_node) { }
- reference
- operator*() const
- { return static_cast<_Node*>(_M_node)->_M_data; }
- pointer
- operator->() const
- { return std::__addressof(static_cast<_Node*>(_M_node)->_M_data); }
- _Self&
- operator++()
- {
- _M_node = _M_node->_M_next;
- return *this;
- }
- _Self
- operator++(int)
- {
- _Self __tmp = *this;
- _M_node = _M_node->_M_next;
- return __tmp;
- }
- _Self&
- operator--()
- {
- _M_node = _M_node->_M_prev;
- return *this;
- }
- _Self
- operator--(int)
- {
- _Self __tmp = *this;
- _M_node = _M_node->_M_prev;
- return __tmp;
- }
- bool
- operator==(const _Self& __x) const
- { return _M_node == __x._M_node; }
- bool
- operator!=(const _Self& __x) const
- { return _M_node != __x._M_node; }
- const __detail::_List_node_base* _M_node;
- };
- template<typename _Val>
- inline bool
- operator==(const _List_iterator<_Val>& __x,
- const _List_const_iterator<_Val>& __y)
- { return __x._M_node == __y._M_node; }
- template<typename _Val>
- inline bool
- operator!=(const _List_iterator<_Val>& __x,
- const _List_const_iterator<_Val>& __y)
- { return __x._M_node != __y._M_node; }
- template<typename _Tp, typename _Alloc>
- class _List_base
- {
- protected:
- typedef typename _Alloc::template rebind<_List_node<_Tp> >::other
- _Node_alloc_type;
- typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type;
- struct _List_impl
- : public _Node_alloc_type
- {
- __detail::_List_node_base _M_node;
- _List_impl()
- : _Node_alloc_type(), _M_node()
- { }
- _List_impl(const _Node_alloc_type& __a)
- : _Node_alloc_type(__a), _M_node()
- { }
- };
- _List_impl _M_impl;
- _List_node<_Tp>*
- _M_get_node()
- { return _M_impl._Node_alloc_type::allocate(1); }
- void
- _M_put_node(_List_node<_Tp>* __p)
- { _M_impl._Node_alloc_type::deallocate(__p, 1); }
- public:
- typedef _Alloc allocator_type;
- _Node_alloc_type&
- _M_get_Node_allocator()
- { return *static_cast<_Node_alloc_type*>(&this->_M_impl); }
- const _Node_alloc_type&
- _M_get_Node_allocator() const
- { return *static_cast<const _Node_alloc_type*>(&this->_M_impl); }
- _Tp_alloc_type
- _M_get_Tp_allocator() const
- { return _Tp_alloc_type(_M_get_Node_allocator()); }
- allocator_type
- get_allocator() const
- { return allocator_type(_M_get_Node_allocator()); }
- _List_base()
- : _M_impl()
- { _M_init(); }
- _List_base(const allocator_type& __a)
- : _M_impl(__a)
- { _M_init(); }
- ~_List_base()
- { _M_clear(); }
- void
- _M_clear();
- void
- _M_init()
- {
- this->_M_impl._M_node._M_next = &this->_M_impl._M_node;
- this->_M_impl._M_node._M_prev = &this->_M_impl._M_node;
- }
- };
- template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
- class list : protected _List_base<_Tp, _Alloc>
- {
- typedef typename _Alloc::value_type _Alloc_value_type;
- typedef _List_base<_Tp, _Alloc> _Base;
- typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
- public:
- typedef _Tp value_type;
- typedef typename _Tp_alloc_type::pointer pointer;
- typedef typename _Tp_alloc_type::const_pointer const_pointer;
- typedef typename _Tp_alloc_type::reference reference;
- typedef typename _Tp_alloc_type::const_reference const_reference;
- typedef _List_iterator<_Tp> iterator;
- typedef _List_const_iterator<_Tp> const_iterator;
- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
- typedef std::reverse_iterator<iterator> reverse_iterator;
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
- typedef _Alloc allocator_type;
- protected:
- typedef _List_node<_Tp> _Node;
- using _Base::_M_impl;
- using _Base::_M_put_node;
- using _Base::_M_get_node;
- using _Base::_M_get_Tp_allocator;
- using _Base::_M_get_Node_allocator;
- _Node*
- _M_create_node(const value_type& __x)
- {
- _Node* __p = this->_M_get_node();
- try
- {
- _M_get_Tp_allocator().construct
- (std::__addressof(__p->_M_data), __x);
- }
- catch(...)
- {
- _M_put_node(__p);
- throw;
- }
- return __p;
- }
- public:
- list()
- : _Base() { }
- explicit
- list(const allocator_type& __a)
- : _Base(__a) { }
- explicit
- list(size_type __n, const value_type& __value = value_type(),
- const allocator_type& __a = allocator_type())
- : _Base(__a)
- { _M_fill_initialize(__n, __value); }
- list(const list& __x)
- : _Base(__x._M_get_Node_allocator())
- { _M_initialize_dispatch(__x.begin(), __x.end(), __false_type()); }
- template<typename _InputIterator>
- list(_InputIterator __first, _InputIterator __last,
- const allocator_type& __a = allocator_type())
- : _Base(__a)
- {
- typedef typename std::__is_integer<_InputIterator>::__type _Integral;
- _M_initialize_dispatch(__first, __last, _Integral());
- }
- list&
- operator=(const list& __x);
- void
- assign(size_type __n, const value_type& __val)
- { _M_fill_assign(__n, __val); }
- template<typename _InputIterator>
- void
- assign(_InputIterator __first, _InputIterator __last)
- {
- typedef typename std::__is_integer<_InputIterator>::__type _Integral;
- _M_assign_dispatch(__first, __last, _Integral());
- }
- allocator_type
- get_allocator() const
- { return _Base::get_allocator(); }
- iterator
- begin()
- { return iterator(this->_M_impl._M_node._M_next); }
- const_iterator
- begin() const
- { return const_iterator(this->_M_impl._M_node._M_next); }
- iterator
- end()
- { return iterator(&this->_M_impl._M_node); }
- const_iterator
- end() const
- { return const_iterator(&this->_M_impl._M_node); }
- 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()); }
- bool
- empty() const
- { return this->_M_impl._M_node._M_next == &this->_M_impl._M_node; }
- size_type
- size() const
- { return std::distance(begin(), end()); }
- size_type
- max_size() const
- { return _M_get_Node_allocator().max_size(); }
- void
- resize(size_type __new_size, value_type __x = value_type());
- reference
- front()
- { return *begin(); }
- const_reference
- front() const
- { return *begin(); }
- reference
- back()
- {
- iterator __tmp = end();
- --__tmp;
- return *__tmp;
- }
- const_reference
- back() const
- {
- const_iterator __tmp = end();
- --__tmp;
- return *__tmp;
- }
- void
- push_front(const value_type& __x)
- { this->_M_insert(begin(), __x); }
- void
- pop_front()
- { this->_M_erase(begin()); }
- void
- push_back(const value_type& __x)
- { this->_M_insert(end(), __x); }
- void
- pop_back()
- { this->_M_erase(iterator(this->_M_impl._M_node._M_prev)); }
- iterator
- insert(iterator __position, const value_type& __x);
- void
- insert(iterator __position, size_type __n, const value_type& __x)
- {
- list __tmp(__n, __x, _M_get_Node_allocator());
- splice(__position, __tmp);
- }
- template<typename _InputIterator>
- void
- insert(iterator __position, _InputIterator __first,
- _InputIterator __last)
- {
- list __tmp(__first, __last, _M_get_Node_allocator());
- splice(__position, __tmp);
- }
- iterator
- erase(iterator __position);
- iterator
- erase(iterator __first, iterator __last)
- {
- while (__first != __last)
- __first = erase(__first);
- return __last;
- }
- void
- swap(list& __x)
- {
- __detail::_List_node_base::swap(this->_M_impl._M_node,
- __x._M_impl._M_node);
- std::__alloc_swap<typename _Base::_Node_alloc_type>::
- _S_do_it(_M_get_Node_allocator(), __x._M_get_Node_allocator());
- }
- void
- clear()
- {
- _Base::_M_clear();
- _Base::_M_init();
- }
- void
- splice(iterator __position, list& __x)
- {
- if (!__x.empty())
- {
- _M_check_equal_allocators(__x);
- this->_M_transfer(__position, __x.begin(), __x.end());
- }
- }
- void
- splice(iterator __position, list& __x, iterator __i)
- {
- iterator __j = __i;
- ++__j;
- if (__position == __i || __position == __j)
- return;
- if (this != &__x)
- _M_check_equal_allocators(__x);
- this->_M_transfer(__position, __i, __j);
- }
- void
- splice(iterator __position, list& __x, iterator __first,
- iterator __last)
- {
- if (__first != __last)
- {
- if (this != &__x)
- _M_check_equal_allocators(__x);
- this->_M_transfer(__position, __first, __last);
- }
- }
- void
- remove(const _Tp& __value);
- template<typename _Predicate>
- void
- remove_if(_Predicate);
- void
- unique();
- template<typename _BinaryPredicate>
- void
- unique(_BinaryPredicate);
- void
- merge(list& __x);
- template<typename _StrictWeakOrdering>
- void
- merge(list&, _StrictWeakOrdering);
- void
- reverse()
- { this->_M_impl._M_node._M_reverse(); }
- void
- sort();
- template<typename _StrictWeakOrdering>
- void
- sort(_StrictWeakOrdering);
- protected:
- template<typename _Integer>
- void
- _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
- { _M_fill_initialize(static_cast<size_type>(__n), __x); }
- template<typename _InputIterator>
- void
- _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
- __false_type)
- {
- for (; __first != __last; ++__first)
- push_back(*__first);
- }
- void
- _M_fill_initialize(size_type __n, const value_type& __x)
- {
- for (; __n; --__n)
- push_back(__x);
- }
- template<typename _Integer>
- void
- _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
- { _M_fill_assign(__n, __val); }
- template<typename _InputIterator>
- void
- _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
- __false_type);
- void
- _M_fill_assign(size_type __n, const value_type& __val);
- void
- _M_transfer(iterator __position, iterator __first, iterator __last)
- { __position._M_node->_M_transfer(__first._M_node, __last._M_node); }
- void
- _M_insert(iterator __position, const value_type& __x)
- {
- _Node* __tmp = _M_create_node(__x);
- __tmp->_M_hook(__position._M_node);
- }
- void
- _M_erase(iterator __position)
- {
- __position._M_node->_M_unhook();
- _Node* __n = static_cast<_Node*>(__position._M_node);
- _M_get_Tp_allocator().destroy(std::__addressof(__n->_M_data));
- _M_put_node(__n);
- }
- void
- _M_check_equal_allocators(list& __x)
- {
- if (std::__alloc_neq<typename _Base::_Node_alloc_type>::
- _S_do_it(_M_get_Node_allocator(), __x._M_get_Node_allocator()))
- __throw_runtime_error(("list::_M_check_equal_allocators"));
- }
- };
- template<typename _Tp, typename _Alloc>
- inline bool
- operator==(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
- {
- typedef typename list<_Tp, _Alloc>::const_iterator const_iterator;
- const_iterator __end1 = __x.end();
- const_iterator __end2 = __y.end();
- const_iterator __i1 = __x.begin();
- const_iterator __i2 = __y.begin();
- while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2)
- {
- ++__i1;
- ++__i2;
- }
- return __i1 == __end1 && __i2 == __end2;
- }
- template<typename _Tp, typename _Alloc>
- inline bool
- operator<(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
- { return std::lexicographical_compare(__x.begin(), __x.end(),
- __y.begin(), __y.end()); }
- template<typename _Tp, typename _Alloc>
- inline bool
- operator!=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
- { return !(__x == __y); }
- template<typename _Tp, typename _Alloc>
- inline bool
- operator>(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
- { return __y < __x; }
- template<typename _Tp, typename _Alloc>
- inline bool
- operator<=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
- { return !(__y < __x); }
- template<typename _Tp, typename _Alloc>
- inline bool
- operator>=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
- { return !(__x < __y); }
- template<typename _Tp, typename _Alloc>
- inline void
- swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y)
- { __x.swap(__y); }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _Tp, typename _Alloc>
- void
- _List_base<_Tp, _Alloc>::
- _M_clear()
- {
- typedef _List_node<_Tp> _Node;
- _Node* __cur = static_cast<_Node*>(this->_M_impl._M_node._M_next);
- while (__cur != &this->_M_impl._M_node)
- {
- _Node* __tmp = __cur;
- __cur = static_cast<_Node*>(__cur->_M_next);
- _M_get_Tp_allocator().destroy(std::__addressof(__tmp->_M_data));
- _M_put_node(__tmp);
- }
- }
- template<typename _Tp, typename _Alloc>
- typename list<_Tp, _Alloc>::iterator
- list<_Tp, _Alloc>::
- insert(iterator __position, const value_type& __x)
- {
- _Node* __tmp = _M_create_node(__x);
- __tmp->_M_hook(__position._M_node);
- return iterator(__tmp);
- }
- template<typename _Tp, typename _Alloc>
- typename list<_Tp, _Alloc>::iterator
- list<_Tp, _Alloc>::
- erase(iterator __position)
- {
- iterator __ret = iterator(__position._M_node->_M_next);
- _M_erase(__position);
- return __ret;
- }
- template<typename _Tp, typename _Alloc>
- void
- list<_Tp, _Alloc>::
- resize(size_type __new_size, value_type __x)
- {
- iterator __i = begin();
- size_type __len = 0;
- for (; __i != end() && __len < __new_size; ++__i, ++__len)
- ;
- if (__len == __new_size)
- erase(__i, end());
- else
- insert(end(), __new_size - __len, __x);
- }
- template<typename _Tp, typename _Alloc>
- list<_Tp, _Alloc>&
- list<_Tp, _Alloc>::
- operator=(const list& __x)
- {
- if (this != &__x)
- {
- iterator __first1 = begin();
- iterator __last1 = end();
- const_iterator __first2 = __x.begin();
- const_iterator __last2 = __x.end();
- for (; __first1 != __last1 && __first2 != __last2;
- ++__first1, ++__first2)
- *__first1 = *__first2;
- if (__first2 == __last2)
- erase(__first1, __last1);
- else
- insert(__last1, __first2, __last2);
- }
- return *this;
- }
- template<typename _Tp, typename _Alloc>
- void
- list<_Tp, _Alloc>::
- _M_fill_assign(size_type __n, const value_type& __val)
- {
- iterator __i = begin();
- for (; __i != end() && __n > 0; ++__i, --__n)
- *__i = __val;
- if (__n > 0)
- insert(end(), __n, __val);
- else
- erase(__i, end());
- }
- template<typename _Tp, typename _Alloc>
- template <typename _InputIterator>
- void
- list<_Tp, _Alloc>::
- _M_assign_dispatch(_InputIterator __first2, _InputIterator __last2,
- __false_type)
- {
- iterator __first1 = begin();
- iterator __last1 = end();
- for (; __first1 != __last1 && __first2 != __last2;
- ++__first1, ++__first2)
- *__first1 = *__first2;
- if (__first2 == __last2)
- erase(__first1, __last1);
- else
- insert(__last1, __first2, __last2);
- }
- template<typename _Tp, typename _Alloc>
- void
- list<_Tp, _Alloc>::
- remove(const value_type& __value)
- {
- iterator __first = begin();
- iterator __last = end();
- iterator __extra = __last;
- while (__first != __last)
- {
- iterator __next = __first;
- ++__next;
- if (*__first == __value)
- {
- if (std::__addressof(*__first) != std::__addressof(__value))
- _M_erase(__first);
- else
- __extra = __first;
- }
- __first = __next;
- }
- if (__extra != __last)
- _M_erase(__extra);
- }
- template<typename _Tp, typename _Alloc>
- void
- list<_Tp, _Alloc>::
- unique()
- {
- iterator __first = begin();
- iterator __last = end();
- if (__first == __last)
- return;
- iterator __next = __first;
- while (++__next != __last)
- {
- if (*__first == *__next)
- _M_erase(__next);
- else
- __first = __next;
- __next = __first;
- }
- }
- template<typename _Tp, typename _Alloc>
- void
- list<_Tp, _Alloc>::
- merge(list& __x)
- {
- if (this != &__x)
- {
- _M_check_equal_allocators(__x);
- iterator __first1 = begin();
- iterator __last1 = end();
- iterator __first2 = __x.begin();
- iterator __last2 = __x.end();
- while (__first1 != __last1 && __first2 != __last2)
- if (*__first2 < *__first1)
- {
- iterator __next = __first2;
- _M_transfer(__first1, __first2, ++__next);
- __first2 = __next;
- }
- else
- ++__first1;
- if (__first2 != __last2)
- _M_transfer(__last1, __first2, __last2);
- }
- }
- template<typename _Tp, typename _Alloc>
- template <typename _StrictWeakOrdering>
- void
- list<_Tp, _Alloc>::
- merge(list& __x, _StrictWeakOrdering __comp)
- {
- if (this != &__x)
- {
- _M_check_equal_allocators(__x);
- iterator __first1 = begin();
- iterator __last1 = end();
- iterator __first2 = __x.begin();
- iterator __last2 = __x.end();
- while (__first1 != __last1 && __first2 != __last2)
- if (__comp(*__first2, *__first1))
- {
- iterator __next = __first2;
- _M_transfer(__first1, __first2, ++__next);
- __first2 = __next;
- }
- else
- ++__first1;
- if (__first2 != __last2)
- _M_transfer(__last1, __first2, __last2);
- }
- }
- template<typename _Tp, typename _Alloc>
- void
- list<_Tp, _Alloc>::
- sort()
- {
- if (this->_M_impl._M_node._M_next != &this->_M_impl._M_node
- && this->_M_impl._M_node._M_next->_M_next != &this->_M_impl._M_node)
- {
- list __carry;
- list __tmp[64];
- list * __fill = &__tmp[0];
- list * __counter;
- do
- {
- __carry.splice(__carry.begin(), *this, begin());
- for(__counter = &__tmp[0];
- __counter != __fill && !__counter->empty();
- ++__counter)
- {
- __counter->merge(__carry);
- __carry.swap(*__counter);
- }
- __carry.swap(*__counter);
- if (__counter == __fill)
- ++__fill;
- }
- while ( !empty() );
- for (__counter = &__tmp[1]; __counter != __fill; ++__counter)
- __counter->merge(*(__counter - 1));
- swap( *(__fill - 1) );
- }
- }
- template<typename _Tp, typename _Alloc>
- template <typename _Predicate>
- void
- list<_Tp, _Alloc>::
- remove_if(_Predicate __pred)
- {
- iterator __first = begin();
- iterator __last = end();
- while (__first != __last)
- {
- iterator __next = __first;
- ++__next;
- if (__pred(*__first))
- _M_erase(__first);
- __first = __next;
- }
- }
- template<typename _Tp, typename _Alloc>
- template <typename _BinaryPredicate>
- void
- list<_Tp, _Alloc>::
- unique(_BinaryPredicate __binary_pred)
- {
- iterator __first = begin();
- iterator __last = end();
- if (__first == __last)
- return;
- iterator __next = __first;
- while (++__next != __last)
- {
- if (__binary_pred(*__first, *__next))
- _M_erase(__next);
- else
- __first = __next;
- __next = __first;
- }
- }
- template<typename _Tp, typename _Alloc>
- template <typename _StrictWeakOrdering>
- void
- list<_Tp, _Alloc>::
- sort(_StrictWeakOrdering __comp)
- {
- if (this->_M_impl._M_node._M_next != &this->_M_impl._M_node
- && this->_M_impl._M_node._M_next->_M_next != &this->_M_impl._M_node)
- {
- list __carry;
- list __tmp[64];
- list * __fill = &__tmp[0];
- list * __counter;
- do
- {
- __carry.splice(__carry.begin(), *this, begin());
- for(__counter = &__tmp[0];
- __counter != __fill && !__counter->empty();
- ++__counter)
- {
- __counter->merge(__carry, __comp);
- __carry.swap(*__counter);
- }
- __carry.swap(*__counter);
- if (__counter == __fill)
- ++__fill;
- }
- while ( !empty() );
- for (__counter = &__tmp[1]; __counter != __fill; ++__counter)
- __counter->merge(*(__counter - 1), __comp);
- swap(*(__fill - 1));
- }
- }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _Tp, typename _Alloc>
- struct _Vector_base
- {
- typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type;
- struct _Vector_impl
- : public _Tp_alloc_type
- {
- typename _Tp_alloc_type::pointer _M_start;
- typename _Tp_alloc_type::pointer _M_finish;
- typename _Tp_alloc_type::pointer _M_end_of_storage;
- _Vector_impl()
- : _Tp_alloc_type(), _M_start(0), _M_finish(0), _M_end_of_storage(0)
- { }
- _Vector_impl(_Tp_alloc_type const& __a)
- : _Tp_alloc_type(__a), _M_start(0), _M_finish(0), _M_end_of_storage(0)
- { }
- };
- public:
- typedef _Alloc allocator_type;
- _Tp_alloc_type&
- _M_get_Tp_allocator()
- { return *static_cast<_Tp_alloc_type*>(&this->_M_impl); }
- const _Tp_alloc_type&
- _M_get_Tp_allocator() const
- { return *static_cast<const _Tp_alloc_type*>(&this->_M_impl); }
- allocator_type
- get_allocator() const
- { return allocator_type(_M_get_Tp_allocator()); }
- _Vector_base()
- : _M_impl() { }
- _Vector_base(const allocator_type& __a)
- : _M_impl(__a) { }
- _Vector_base(size_t __n)
- : _M_impl()
- {
- this->_M_impl._M_start = this->_M_allocate(__n);
- this->_M_impl._M_finish = this->_M_impl._M_start;
- this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
- }
- _Vector_base(size_t __n, const allocator_type& __a)
- : _M_impl(__a)
- {
- this->_M_impl._M_start = this->_M_allocate(__n);
- this->_M_impl._M_finish = this->_M_impl._M_start;
- this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
- }
- ~_Vector_base()
- { _M_deallocate(this->_M_impl._M_start, this->_M_impl._M_end_of_storage
- - this->_M_impl._M_start); }
- public:
- _Vector_impl _M_impl;
- typename _Tp_alloc_type::pointer
- _M_allocate(size_t __n)
- { return __n != 0 ? _M_impl.allocate(__n) : 0; }
- void
- _M_deallocate(typename _Tp_alloc_type::pointer __p, size_t __n)
- {
- if (__p)
- _M_impl.deallocate(__p, __n);
- }
- };
- template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
- class vector : protected _Vector_base<_Tp, _Alloc>
- {
- typedef typename _Alloc::value_type _Alloc_value_type;
- typedef _Vector_base<_Tp, _Alloc> _Base;
- typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
- public:
- typedef _Tp value_type;
- typedef typename _Tp_alloc_type::pointer pointer;
- typedef typename _Tp_alloc_type::const_pointer const_pointer;
- typedef typename _Tp_alloc_type::reference reference;
- typedef typename _Tp_alloc_type::const_reference const_reference;
- typedef __gnu_cxx::__normal_iterator<pointer, vector> iterator;
- typedef __gnu_cxx::__normal_iterator<const_pointer, vector>
- const_iterator;
- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
- typedef std::reverse_iterator<iterator> reverse_iterator;
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
- typedef _Alloc allocator_type;
- protected:
- using _Base::_M_allocate;
- using _Base::_M_deallocate;
- using _Base::_M_impl;
- using _Base::_M_get_Tp_allocator;
- public:
- vector()
- : _Base() { }
- explicit
- vector(const allocator_type& __a)
- : _Base(__a) { }
- explicit
- vector(size_type __n, const value_type& __value = value_type(),
- const allocator_type& __a = allocator_type())
- : _Base(__n, __a)
- { _M_fill_initialize(__n, __value); }
- vector(const vector& __x)
- : _Base(__x.size(), __x._M_get_Tp_allocator())
- { this->_M_impl._M_finish =
- std::__uninitialized_copy_a(__x.begin(), __x.end(),
- this->_M_impl._M_start,
- _M_get_Tp_allocator());
- }
- template<typename _InputIterator>
- vector(_InputIterator __first, _InputIterator __last,
- const allocator_type& __a = allocator_type())
- : _Base(__a)
- {
- typedef typename std::__is_integer<_InputIterator>::__type _Integral;
- _M_initialize_dispatch(__first, __last, _Integral());
- }
- ~vector()
- { std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
- _M_get_Tp_allocator()); }
- vector&
- operator=(const vector& __x);
- void
- assign(size_type __n, const value_type& __val)
- { _M_fill_assign(__n, __val); }
- template<typename _InputIterator>
- void
- assign(_InputIterator __first, _InputIterator __last)
- {
- typedef typename std::__is_integer<_InputIterator>::__type _Integral;
- _M_assign_dispatch(__first, __last, _Integral());
- }
- using _Base::get_allocator;
- iterator
- begin()
- { return iterator(this->_M_impl._M_start); }
- const_iterator
- begin() const
- { return const_iterator(this->_M_impl._M_start); }
- iterator
- end()
- { return iterator(this->_M_impl._M_finish); }
- const_iterator
- end() const
- { return const_iterator(this->_M_impl._M_finish); }
- 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()); }
- size_type
- size() const
- { return size_type(this->_M_impl._M_finish - this->_M_impl._M_start); }
- size_type
- max_size() const
- { return _M_get_Tp_allocator().max_size(); }
- void
- resize(size_type __new_size, value_type __x = value_type())
- {
- if (__new_size > size())
- insert(end(), __new_size - size(), __x);
- else if (__new_size < size())
- _M_erase_at_end(this->_M_impl._M_start + __new_size);
- }
- size_type
- capacity() const
- { return size_type(this->_M_impl._M_end_of_storage
- - this->_M_impl._M_start); }
- bool
- empty() const
- { return begin() == end(); }
- void
- reserve(size_type __n);
- reference
- operator[](size_type __n)
- { return *(this->_M_impl._M_start + __n); }
- const_reference
- operator[](size_type __n) const
- { return *(this->_M_impl._M_start + __n); }
- protected:
- void
- _M_range_check(size_type __n) const
- {
- if (__n >= this->size())
- __throw_out_of_range(("vector::_M_range_check"));
- }
- public:
- reference
- at(size_type __n)
- {
- _M_range_check(__n);
- return (*this)[__n];
- }
- const_reference
- at(size_type __n) const
- {
- _M_range_check(__n);
- return (*this)[__n];
- }
- reference
- front()
- { return *begin(); }
- const_reference
- front() const
- { return *begin(); }
- reference
- back()
- { return *(end() - 1); }
- const_reference
- back() const
- { return *(end() - 1); }
- pointer
- data()
- { return std::__addressof(front()); }
- const_pointer
- data() const
- { return std::__addressof(front()); }
- void
- push_back(const value_type& __x)
- {
- if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
- {
- this->_M_impl.construct(this->_M_impl._M_finish, __x);
- ++this->_M_impl._M_finish;
- }
- else
- _M_insert_aux(end(), __x);
- }
- void
- pop_back()
- {
- --this->_M_impl._M_finish;
- this->_M_impl.destroy(this->_M_impl._M_finish);
- }
- iterator
- insert(iterator __position, const value_type& __x);
- void
- insert(iterator __position, size_type __n, const value_type& __x)
- { _M_fill_insert(__position, __n, __x); }
- template<typename _InputIterator>
- void
- insert(iterator __position, _InputIterator __first,
- _InputIterator __last)
- {
- typedef typename std::__is_integer<_InputIterator>::__type _Integral;
- _M_insert_dispatch(__position, __first, __last, _Integral());
- }
- iterator
- erase(iterator __position);
- iterator
- erase(iterator __first, iterator __last);
- void
- swap(vector& __x)
- {
- std::swap(this->_M_impl._M_start, __x._M_impl._M_start);
- std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish);
- std::swap(this->_M_impl._M_end_of_storage,
- __x._M_impl._M_end_of_storage);
- std::__alloc_swap<_Tp_alloc_type>::_S_do_it(_M_get_Tp_allocator(),
- __x._M_get_Tp_allocator());
- }
- void
- clear()
- { _M_erase_at_end(this->_M_impl._M_start); }
- protected:
- template<typename _ForwardIterator>
- pointer
- _M_allocate_and_copy(size_type __n,
- _ForwardIterator __first, _ForwardIterator __last)
- {
- pointer __result = this->_M_allocate(__n);
- try
- {
- std::__uninitialized_copy_a(__first, __last, __result,
- _M_get_Tp_allocator());
- return __result;
- }
- catch(...)
- {
- _M_deallocate(__result, __n);
- throw;
- }
- }
- template<typename _Integer>
- void
- _M_initialize_dispatch(_Integer __n, _Integer __value, __true_type)
- {
- this->_M_impl._M_start = _M_allocate(static_cast<size_type>(__n));
- this->_M_impl._M_end_of_storage =
- this->_M_impl._M_start + static_cast<size_type>(__n);
- _M_fill_initialize(static_cast<size_type>(__n), __value);
- }
- template<typename _InputIterator>
- void
- _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
- __false_type)
- {
- typedef typename std::iterator_traits<_InputIterator>::
- iterator_category _IterCategory;
- _M_range_initialize(__first, __last, _IterCategory());
- }
- template<typename _InputIterator>
- void
- _M_range_initialize(_InputIterator __first,
- _InputIterator __last, std::input_iterator_tag)
- {
- for (; __first != __last; ++__first)
- push_back(*__first);
- }
- template<typename _ForwardIterator>
- void
- _M_range_initialize(_ForwardIterator __first,
- _ForwardIterator __last, std::forward_iterator_tag)
- {
- const size_type __n = std::distance(__first, __last);
- this->_M_impl._M_start = this->_M_allocate(__n);
- this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
- this->_M_impl._M_finish =
- std::__uninitialized_copy_a(__first, __last,
- this->_M_impl._M_start,
- _M_get_Tp_allocator());
- }
- void
- _M_fill_initialize(size_type __n, const value_type& __value)
- {
- std::__uninitialized_fill_n_a(this->_M_impl._M_start, __n, __value,
- _M_get_Tp_allocator());
- this->_M_impl._M_finish = this->_M_impl._M_end_of_storage;
- }
- template<typename _Integer>
- void
- _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
- { _M_fill_assign(__n, __val); }
- template<typename _InputIterator>
- void
- _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
- __false_type)
- {
- typedef typename std::iterator_traits<_InputIterator>::
- iterator_category _IterCategory;
- _M_assign_aux(__first, __last, _IterCategory());
- }
- template<typename _InputIterator>
- void
- _M_assign_aux(_InputIterator __first, _InputIterator __last,
- std::input_iterator_tag);
- template<typename _ForwardIterator>
- void
- _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
- std::forward_iterator_tag);
- void
- _M_fill_assign(size_type __n, const value_type& __val);
- template<typename _Integer>
- void
- _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,
- __true_type)
- { _M_fill_insert(__pos, __n, __val); }
- template<typename _InputIterator>
- void
- _M_insert_dispatch(iterator __pos, _InputIterator __first,
- _InputIterator __last, __false_type)
- {
- typedef typename std::iterator_traits<_InputIterator>::
- iterator_category _IterCategory;
- _M_range_insert(__pos, __first, __last, _IterCategory());
- }
- template<typename _InputIterator>
- void
- _M_range_insert(iterator __pos, _InputIterator __first,
- _InputIterator __last, std::input_iterator_tag);
- template<typename _ForwardIterator>
- void
- _M_range_insert(iterator __pos, _ForwardIterator __first,
- _ForwardIterator __last, std::forward_iterator_tag);
- void
- _M_fill_insert(iterator __pos, size_type __n, const value_type& __x);
- void
- _M_insert_aux(iterator __position, const value_type& __x);
- size_type
- _M_check_len(size_type __n, const char* __s) const
- {
- if (max_size() - size() < __n)
- __throw_length_error((__s));
- const size_type __len = size() + std::max(size(), __n);
- return (__len < size() || __len > max_size()) ? max_size() : __len;
- }
- void
- _M_erase_at_end(pointer __pos)
- {
- std::_Destroy(__pos, this->_M_impl._M_finish, _M_get_Tp_allocator());
- this->_M_impl._M_finish = __pos;
- }
- };
- template<typename _Tp, typename _Alloc>
- inline bool
- operator==(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
- { return (__x.size() == __y.size()
- && std::equal(__x.begin(), __x.end(), __y.begin())); }
- template<typename _Tp, typename _Alloc>
- inline bool
- operator<(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
- { return std::lexicographical_compare(__x.begin(), __x.end(),
- __y.begin(), __y.end()); }
- template<typename _Tp, typename _Alloc>
- inline bool
- operator!=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
- { return !(__x == __y); }
- template<typename _Tp, typename _Alloc>
- inline bool
- operator>(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
- { return __y < __x; }
- template<typename _Tp, typename _Alloc>
- inline bool
- operator<=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
- { return !(__y < __x); }
- template<typename _Tp, typename _Alloc>
- inline bool
- operator>=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
- { return !(__x < __y); }
- template<typename _Tp, typename _Alloc>
- inline void
- swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y)
- { __x.swap(__y); }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- typedef unsigned long _Bit_type;
- enum { _S_word_bit = int(8 * sizeof(_Bit_type)) };
- struct _Bit_reference
- {
- _Bit_type * _M_p;
- _Bit_type _M_mask;
- _Bit_reference(_Bit_type * __x, _Bit_type __y)
- : _M_p(__x), _M_mask(__y) { }
- _Bit_reference() : _M_p(0), _M_mask(0) { }
- operator bool() const
- { return !!(*_M_p & _M_mask); }
- _Bit_reference&
- operator=(bool __x)
- {
- if (__x)
- *_M_p |= _M_mask;
- else
- *_M_p &= ~_M_mask;
- return *this;
- }
- _Bit_reference&
- operator=(const _Bit_reference& __x)
- { return *this = bool(__x); }
- bool
- operator==(const _Bit_reference& __x) const
- { return bool(*this) == bool(__x); }
- bool
- operator<(const _Bit_reference& __x) const
- { return !bool(*this) && bool(__x); }
- void
- flip()
- { *_M_p ^= _M_mask; }
- };
- struct _Bit_iterator_base
- : public std::iterator<std::random_access_iterator_tag, bool>
- {
- _Bit_type * _M_p;
- unsigned int _M_offset;
- _Bit_iterator_base(_Bit_type * __x, unsigned int __y)
- : _M_p(__x), _M_offset(__y) { }
- void
- _M_bump_up()
- {
- if (_M_offset++ == int(_S_word_bit) - 1)
- {
- _M_offset = 0;
- ++_M_p;
- }
- }
- void
- _M_bump_down()
- {
- if (_M_offset-- == 0)
- {
- _M_offset = int(_S_word_bit) - 1;
- --_M_p;
- }
- }
- void
- _M_incr(ptrdiff_t __i)
- {
- difference_type __n = __i + _M_offset;
- _M_p += __n / int(_S_word_bit);
- __n = __n % int(_S_word_bit);
- if (__n < 0)
- {
- __n += int(_S_word_bit);
- --_M_p;
- }
- _M_offset = static_cast<unsigned int>(__n);
- }
- bool
- operator==(const _Bit_iterator_base& __i) const
- { return _M_p == __i._M_p && _M_offset == __i._M_offset; }
- bool
- operator<(const _Bit_iterator_base& __i) const
- {
- return _M_p < __i._M_p
- || (_M_p == __i._M_p && _M_offset < __i._M_offset);
- }
- bool
- operator!=(const _Bit_iterator_base& __i) const
- { return !(*this == __i); }
- bool
- operator>(const _Bit_iterator_base& __i) const
- { return __i < *this; }
- bool
- operator<=(const _Bit_iterator_base& __i) const
- { return !(__i < *this); }
- bool
- operator>=(const _Bit_iterator_base& __i) const
- { return !(*this < __i); }
- };
- inline ptrdiff_t
- operator-(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y)
- {
- return (int(_S_word_bit) * (__x._M_p - __y._M_p)
- + __x._M_offset - __y._M_offset);
- }
- struct _Bit_iterator : public _Bit_iterator_base
- {
- typedef _Bit_reference reference;
- typedef _Bit_reference* pointer;
- typedef _Bit_iterator iterator;
- _Bit_iterator() : _Bit_iterator_base(0, 0) { }
- _Bit_iterator(_Bit_type * __x, unsigned int __y)
- : _Bit_iterator_base(__x, __y) { }
- reference
- operator*() const
- { return reference(_M_p, 1UL << _M_offset); }
- iterator&
- operator++()
- {
- _M_bump_up();
- return *this;
- }
- iterator
- operator++(int)
- {
- iterator __tmp = *this;
- _M_bump_up();
- return __tmp;
- }
- iterator&
- operator--()
- {
- _M_bump_down();
- return *this;
- }
- iterator
- operator--(int)
- {
- iterator __tmp = *this;
- _M_bump_down();
- return __tmp;
- }
- iterator&
- operator+=(difference_type __i)
- {
- _M_incr(__i);
- return *this;
- }
- iterator&
- operator-=(difference_type __i)
- {
- *this += -__i;
- return *this;
- }
- iterator
- operator+(difference_type __i) const
- {
- iterator __tmp = *this;
- return __tmp += __i;
- }
- iterator
- operator-(difference_type __i) const
- {
- iterator __tmp = *this;
- return __tmp -= __i;
- }
- reference
- operator[](difference_type __i) const
- { return *(*this + __i); }
- };
- inline _Bit_iterator
- operator+(ptrdiff_t __n, const _Bit_iterator& __x)
- { return __x + __n; }
- struct _Bit_const_iterator : public _Bit_iterator_base
- {
- typedef bool reference;
- typedef bool const_reference;
- typedef const bool* pointer;
- typedef _Bit_const_iterator const_iterator;
- _Bit_const_iterator() : _Bit_iterator_base(0, 0) { }
- _Bit_const_iterator(_Bit_type * __x, unsigned int __y)
- : _Bit_iterator_base(__x, __y) { }
- _Bit_const_iterator(const _Bit_iterator& __x)
- : _Bit_iterator_base(__x._M_p, __x._M_offset) { }
- const_reference
- operator*() const
- { return _Bit_reference(_M_p, 1UL << _M_offset); }
- const_iterator&
- operator++()
- {
- _M_bump_up();
- return *this;
- }
- const_iterator
- operator++(int)
- {
- const_iterator __tmp = *this;
- _M_bump_up();
- return __tmp;
- }
- const_iterator&
- operator--()
- {
- _M_bump_down();
- return *this;
- }
- const_iterator
- operator--(int)
- {
- const_iterator __tmp = *this;
- _M_bump_down();
- return __tmp;
- }
- const_iterator&
- operator+=(difference_type __i)
- {
- _M_incr(__i);
- return *this;
- }
- const_iterator&
- operator-=(difference_type __i)
- {
- *this += -__i;
- return *this;
- }
- const_iterator
- operator+(difference_type __i) const
- {
- const_iterator __tmp = *this;
- return __tmp += __i;
- }
- const_iterator
- operator-(difference_type __i) const
- {
- const_iterator __tmp = *this;
- return __tmp -= __i;
- }
- const_reference
- operator[](difference_type __i) const
- { return *(*this + __i); }
- };
- inline _Bit_const_iterator
- operator+(ptrdiff_t __n, const _Bit_const_iterator& __x)
- { return __x + __n; }
- inline void
- __fill_bvector(_Bit_iterator __first, _Bit_iterator __last, bool __x)
- {
- for (; __first != __last; ++__first)
- *__first = __x;
- }
- inline void
- fill(_Bit_iterator __first, _Bit_iterator __last, const bool& __x)
- {
- if (__first._M_p != __last._M_p)
- {
- std::fill(__first._M_p + 1, __last._M_p, __x ? ~0 : 0);
- __fill_bvector(__first, _Bit_iterator(__first._M_p + 1, 0), __x);
- __fill_bvector(_Bit_iterator(__last._M_p, 0), __last, __x);
- }
- else
- __fill_bvector(__first, __last, __x);
- }
- template<typename _Alloc>
- struct _Bvector_base
- {
- typedef typename _Alloc::template rebind<_Bit_type>::other
- _Bit_alloc_type;
- struct _Bvector_impl
- : public _Bit_alloc_type
- {
- _Bit_iterator _M_start;
- _Bit_iterator _M_finish;
- _Bit_type* _M_end_of_storage;
- _Bvector_impl()
- : _Bit_alloc_type(), _M_start(), _M_finish(), _M_end_of_storage(0)
- { }
- _Bvector_impl(const _Bit_alloc_type& __a)
- : _Bit_alloc_type(__a), _M_start(), _M_finish(), _M_end_of_storage(0)
- { }
- };
- public:
- typedef _Alloc allocator_type;
- _Bit_alloc_type&
- _M_get_Bit_allocator()
- { return *static_cast<_Bit_alloc_type*>(&this->_M_impl); }
- const _Bit_alloc_type&
- _M_get_Bit_allocator() const
- { return *static_cast<const _Bit_alloc_type*>(&this->_M_impl); }
- allocator_type
- get_allocator() const
- { return allocator_type(_M_get_Bit_allocator()); }
- _Bvector_base()
- : _M_impl() { }
- _Bvector_base(const allocator_type& __a)
- : _M_impl(__a) { }
- ~_Bvector_base()
- { this->_M_deallocate(); }
- protected:
- _Bvector_impl _M_impl;
- _Bit_type*
- _M_allocate(size_t __n)
- { return _M_impl.allocate((__n + int(_S_word_bit) - 1)
- / int(_S_word_bit)); }
- void
- _M_deallocate()
- {
- if (_M_impl._M_start._M_p)
- _M_impl.deallocate(_M_impl._M_start._M_p,
- _M_impl._M_end_of_storage - _M_impl._M_start._M_p);
- }
- };
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
-template<typename _Alloc>
- class vector<bool, _Alloc> : protected _Bvector_base<_Alloc>
- {
- typedef _Bvector_base<_Alloc> _Base;
- public:
- typedef bool value_type;
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
- typedef _Bit_reference reference;
- typedef bool const_reference;
- typedef _Bit_reference* pointer;
- typedef const bool* const_pointer;
- typedef _Bit_iterator iterator;
- typedef _Bit_const_iterator const_iterator;
- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
- typedef std::reverse_iterator<iterator> reverse_iterator;
- typedef _Alloc allocator_type;
- allocator_type get_allocator() const
- { return _Base::get_allocator(); }
- protected:
- using _Base::_M_allocate;
- using _Base::_M_deallocate;
- using _Base::_M_get_Bit_allocator;
- public:
- vector()
- : _Base() { }
- explicit
- vector(const allocator_type& __a)
- : _Base(__a) { }
- explicit
- vector(size_type __n, const bool& __value = bool(),
- const allocator_type& __a = allocator_type())
- : _Base(__a)
- {
- _M_initialize(__n);
- std::fill(this->_M_impl._M_start._M_p, this->_M_impl._M_end_of_storage,
- __value ? ~0 : 0);
- }
- vector(const vector& __x)
- : _Base(__x._M_get_Bit_allocator())
- {
- _M_initialize(__x.size());
- _M_copy_aligned(__x.begin(), __x.end(), this->_M_impl._M_start);
- }
- template<typename _InputIterator>
- vector(_InputIterator __first, _InputIterator __last,
- const allocator_type& __a = allocator_type())
- : _Base(__a)
- {
- typedef typename std::__is_integer<_InputIterator>::__type _Integral;
- _M_initialize_dispatch(__first, __last, _Integral());
- }
- ~vector() { }
- vector&
- operator=(const vector& __x)
- {
- if (&__x == this)
- return *this;
- if (__x.size() > capacity())
- {
- this->_M_deallocate();
- _M_initialize(__x.size());
- }
- this->_M_impl._M_finish = _M_copy_aligned(__x.begin(), __x.end(),
- begin());
- return *this;
- }
- void
- assign(size_type __n, const bool& __x)
- { _M_fill_assign(__n, __x); }
- template<typename _InputIterator>
- void
- assign(_InputIterator __first, _InputIterator __last)
- {
- typedef typename std::__is_integer<_InputIterator>::__type _Integral;
- _M_assign_dispatch(__first, __last, _Integral());
- }
- iterator
- begin()
- { return this->_M_impl._M_start; }
- const_iterator
- begin() const
- { return this->_M_impl._M_start; }
- iterator
- end()
- { return this->_M_impl._M_finish; }
- const_iterator
- end() const
- { return this->_M_impl._M_finish; }
- 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()); }
- size_type
- size() const
- { return size_type(end() - begin()); }
- size_type
- max_size() const
- {
- const size_type __isize =
- __gnu_cxx::__numeric_traits<difference_type>::__max
- - int(_S_word_bit) + 1;
- const size_type __asize = _M_get_Bit_allocator().max_size();
- return (__asize <= __isize / int(_S_word_bit)
- ? __asize * int(_S_word_bit) : __isize);
- }
- size_type
- capacity() const
- { return size_type(const_iterator(this->_M_impl._M_end_of_storage, 0)
- - begin()); }
- bool
- empty() const
- { return begin() == end(); }
- reference
- operator[](size_type __n)
- {
- return *iterator(this->_M_impl._M_start._M_p
- + __n / int(_S_word_bit), __n % int(_S_word_bit));
- }
- const_reference
- operator[](size_type __n) const
- {
- return *const_iterator(this->_M_impl._M_start._M_p
- + __n / int(_S_word_bit), __n % int(_S_word_bit));
- }
- protected:
- void
- _M_range_check(size_type __n) const
- {
- if (__n >= this->size())
- __throw_out_of_range(("vector<bool>::_M_range_check"));
- }
- public:
- reference
- at(size_type __n)
- { _M_range_check(__n); return (*this)[__n]; }
- const_reference
- at(size_type __n) const
- { _M_range_check(__n); return (*this)[__n]; }
- void
- reserve(size_type __n);
- reference
- front()
- { return *begin(); }
- const_reference
- front() const
- { return *begin(); }
- reference
- back()
- { return *(end() - 1); }
- const_reference
- back() const
- { return *(end() - 1); }
- void
- data() { }
- void
- push_back(bool __x)
- {
- if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_of_storage)
- *this->_M_impl._M_finish++ = __x;
- else
- _M_insert_aux(end(), __x);
- }
- void
- swap(vector& __x)
- {
- std::swap(this->_M_impl._M_start, __x._M_impl._M_start);
- std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish);
- std::swap(this->_M_impl._M_end_of_storage,
- __x._M_impl._M_end_of_storage);
- std::__alloc_swap<typename _Base::_Bit_alloc_type>::
- _S_do_it(_M_get_Bit_allocator(), __x._M_get_Bit_allocator());
- }
- static void
- swap(reference __x, reference __y)
- {
- bool __tmp = __x;
- __x = __y;
- __y = __tmp;
- }
- iterator
- insert(iterator __position, const bool& __x = bool())
- {
- const difference_type __n = __position - begin();
- if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_of_storage
- && __position == end())
- *this->_M_impl._M_finish++ = __x;
- else
- _M_insert_aux(__position, __x);
- return begin() + __n;
- }
- template<typename _InputIterator>
- void
- insert(iterator __position,
- _InputIterator __first, _InputIterator __last)
- {
- typedef typename std::__is_integer<_InputIterator>::__type _Integral;
- _M_insert_dispatch(__position, __first, __last, _Integral());
- }
- void
- insert(iterator __position, size_type __n, const bool& __x)
- { _M_fill_insert(__position, __n, __x); }
- void
- pop_back()
- { --this->_M_impl._M_finish; }
- iterator
- erase(iterator __position)
- {
- if (__position + 1 != end())
- std::copy(__position + 1, end(), __position);
- --this->_M_impl._M_finish;
- return __position;
- }
- iterator
- erase(iterator __first, iterator __last)
- {
- _M_erase_at_end(std::copy(__last, end(), __first));
- return __first;
- }
- void
- resize(size_type __new_size, bool __x = bool())
- {
- if (__new_size < size())
- _M_erase_at_end(begin() + difference_type(__new_size));
- else
- insert(end(), __new_size - size(), __x);
- }
- void
- flip()
- {
- for (_Bit_type * __p = this->_M_impl._M_start._M_p;
- __p != this->_M_impl._M_end_of_storage; ++__p)
- *__p = ~*__p;
- }
- void
- clear()
- { _M_erase_at_end(begin()); }
- protected:
- iterator
- _M_copy_aligned(const_iterator __first, const_iterator __last,
- iterator __result)
- {
- _Bit_type* __q = std::copy(__first._M_p, __last._M_p, __result._M_p);
- return std::copy(const_iterator(__last._M_p, 0), __last,
- iterator(__q, 0));
- }
- void
- _M_initialize(size_type __n)
- {
- _Bit_type* __q = this->_M_allocate(__n);
- this->_M_impl._M_end_of_storage = (__q
- + ((__n + int(_S_word_bit) - 1)
- / int(_S_word_bit)));
- this->_M_impl._M_start = iterator(__q, 0);
- this->_M_impl._M_finish = this->_M_impl._M_start + difference_type(__n);
- }
- template<typename _Integer>
- void
- _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
- {
- _M_initialize(static_cast<size_type>(__n));
- std::fill(this->_M_impl._M_start._M_p,
- this->_M_impl._M_end_of_storage, __x ? ~0 : 0);
- }
- template<typename _InputIterator>
- void
- _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
- __false_type)
- { _M_initialize_range(__first, __last,
- std::__iterator_category(__first)); }
- template<typename _InputIterator>
- void
- _M_initialize_range(_InputIterator __first, _InputIterator __last,
- std::input_iterator_tag)
- {
- for (; __first != __last; ++__first)
- push_back(*__first);
- }
- template<typename _ForwardIterator>
- void
- _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last,
- std::forward_iterator_tag)
- {
- const size_type __n = std::distance(__first, __last);
- _M_initialize(__n);
- std::copy(__first, __last, this->_M_impl._M_start);
- }
- template<typename _Integer>
- void
- _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
- { _M_fill_assign(__n, __val); }
- template<class _InputIterator>
- void
- _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
- __false_type)
- { _M_assign_aux(__first, __last, std::__iterator_category(__first)); }
- void
- _M_fill_assign(size_t __n, bool __x)
- {
- if (__n > size())
- {
- std::fill(this->_M_impl._M_start._M_p,
- this->_M_impl._M_end_of_storage, __x ? ~0 : 0);
- insert(end(), __n - size(), __x);
- }
- else
- {
- _M_erase_at_end(begin() + __n);
- std::fill(this->_M_impl._M_start._M_p,
- this->_M_impl._M_end_of_storage, __x ? ~0 : 0);
- }
- }
- template<typename _InputIterator>
- void
- _M_assign_aux(_InputIterator __first, _InputIterator __last,
- std::input_iterator_tag)
- {
- iterator __cur = begin();
- for (; __first != __last && __cur != end(); ++__cur, ++__first)
- *__cur = *__first;
- if (__first == __last)
- _M_erase_at_end(__cur);
- else
- insert(end(), __first, __last);
- }
- template<typename _ForwardIterator>
- void
- _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
- std::forward_iterator_tag)
- {
- const size_type __len = std::distance(__first, __last);
- if (__len < size())
- _M_erase_at_end(std::copy(__first, __last, begin()));
- else
- {
- _ForwardIterator __mid = __first;
- std::advance(__mid, size());
- std::copy(__first, __mid, begin());
- insert(end(), __mid, __last);
- }
- }
- template<typename _Integer>
- void
- _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x,
- __true_type)
- { _M_fill_insert(__pos, __n, __x); }
- template<typename _InputIterator>
- void
- _M_insert_dispatch(iterator __pos,
- _InputIterator __first, _InputIterator __last,
- __false_type)
- { _M_insert_range(__pos, __first, __last,
- std::__iterator_category(__first)); }
- void
- _M_fill_insert(iterator __position, size_type __n, bool __x);
- template<typename _InputIterator>
- void
- _M_insert_range(iterator __pos, _InputIterator __first,
- _InputIterator __last, std::input_iterator_tag)
- {
- for (; __first != __last; ++__first)
- {
- __pos = insert(__pos, *__first);
- ++__pos;
- }
- }
- template<typename _ForwardIterator>
- void
- _M_insert_range(iterator __position, _ForwardIterator __first,
- _ForwardIterator __last, std::forward_iterator_tag);
- void
- _M_insert_aux(iterator __position, bool __x);
- size_type
- _M_check_len(size_type __n, const char* __s) const
- {
- if (max_size() - size() < __n)
- __throw_length_error((__s));
- const size_type __len = size() + std::max(size(), __n);
- return (__len < size() || __len > max_size()) ? max_size() : __len;
- }
- void
- _M_erase_at_end(iterator __pos)
- { this->_M_impl._M_finish = __pos; }
- };
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _Tp, typename _Alloc>
- void
- vector<_Tp, _Alloc>::
- reserve(size_type __n)
- {
- if (__n > this->max_size())
- __throw_length_error(("vector::reserve"));
- if (this->capacity() < __n)
- {
- const size_type __old_size = size();
- pointer __tmp = _M_allocate_and_copy(__n,
- (this->_M_impl._M_start),
- (this->_M_impl._M_finish));
- std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
- _M_get_Tp_allocator());
- _M_deallocate(this->_M_impl._M_start,
- this->_M_impl._M_end_of_storage
- - this->_M_impl._M_start);
- this->_M_impl._M_start = __tmp;
- this->_M_impl._M_finish = __tmp + __old_size;
- this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
- }
- }
- template<typename _Tp, typename _Alloc>
- typename vector<_Tp, _Alloc>::iterator
- vector<_Tp, _Alloc>::
- insert(iterator __position, const value_type& __x)
- {
- const size_type __n = __position - begin();
- if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage
- && __position == end())
- {
- this->_M_impl.construct(this->_M_impl._M_finish, __x);
- ++this->_M_impl._M_finish;
- }
- else
- {
- _M_insert_aux(__position, __x);
- }
- return iterator(this->_M_impl._M_start + __n);
- }
- template<typename _Tp, typename _Alloc>
- typename vector<_Tp, _Alloc>::iterator
- vector<_Tp, _Alloc>::
- erase(iterator __position)
- {
- if (__position + 1 != end())
- std::copy(__position + 1, end(), __position);
- --this->_M_impl._M_finish;
- this->_M_impl.destroy(this->_M_impl._M_finish);
- return __position;
- }
- template<typename _Tp, typename _Alloc>
- typename vector<_Tp, _Alloc>::iterator
- vector<_Tp, _Alloc>::
- erase(iterator __first, iterator __last)
- {
- if (__last != end())
- std::copy(__last, end(), __first);
- _M_erase_at_end(__first.base() + (end() - __last));
- return __first;
- }
- template<typename _Tp, typename _Alloc>
- vector<_Tp, _Alloc>&
- vector<_Tp, _Alloc>::
- operator=(const vector<_Tp, _Alloc>& __x)
- {
- if (&__x != this)
- {
- const size_type __xlen = __x.size();
- if (__xlen > capacity())
- {
- pointer __tmp = _M_allocate_and_copy(__xlen, __x.begin(),
- __x.end());
- std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
- _M_get_Tp_allocator());
- _M_deallocate(this->_M_impl._M_start,
- this->_M_impl._M_end_of_storage
- - this->_M_impl._M_start);
- this->_M_impl._M_start = __tmp;
- this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __xlen;
- }
- else if (size() >= __xlen)
- {
- std::_Destroy(std::copy(__x.begin(), __x.end(), begin()),
- end(), _M_get_Tp_allocator());
- }
- else
- {
- std::copy(__x._M_impl._M_start, __x._M_impl._M_start + size(),
- this->_M_impl._M_start);
- std::__uninitialized_copy_a(__x._M_impl._M_start + size(),
- __x._M_impl._M_finish,
- this->_M_impl._M_finish,
- _M_get_Tp_allocator());
- }
- this->_M_impl._M_finish = this->_M_impl._M_start + __xlen;
- }
- return *this;
- }
- template<typename _Tp, typename _Alloc>
- void
- vector<_Tp, _Alloc>::
- _M_fill_assign(size_t __n, const value_type& __val)
- {
- if (__n > capacity())
- {
- vector __tmp(__n, __val, _M_get_Tp_allocator());
- __tmp.swap(*this);
- }
- else if (__n > size())
- {
- std::fill(begin(), end(), __val);
- std::__uninitialized_fill_n_a(this->_M_impl._M_finish,
- __n - size(), __val,
- _M_get_Tp_allocator());
- this->_M_impl._M_finish += __n - size();
- }
- else
- _M_erase_at_end(std::fill_n(this->_M_impl._M_start, __n, __val));
- }
- template<typename _Tp, typename _Alloc>
- template<typename _InputIterator>
- void
- vector<_Tp, _Alloc>::
- _M_assign_aux(_InputIterator __first, _InputIterator __last,
- std::input_iterator_tag)
- {
- pointer __cur(this->_M_impl._M_start);
- for (; __first != __last && __cur != this->_M_impl._M_finish;
- ++__cur, ++__first)
- *__cur = *__first;
- if (__first == __last)
- _M_erase_at_end(__cur);
- else
- insert(end(), __first, __last);
- }
- template<typename _Tp, typename _Alloc>
- template<typename _ForwardIterator>
- void
- vector<_Tp, _Alloc>::
- _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
- std::forward_iterator_tag)
- {
- const size_type __len = std::distance(__first, __last);
- if (__len > capacity())
- {
- pointer __tmp(_M_allocate_and_copy(__len, __first, __last));
- std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
- _M_get_Tp_allocator());
- _M_deallocate(this->_M_impl._M_start,
- this->_M_impl._M_end_of_storage
- - this->_M_impl._M_start);
- this->_M_impl._M_start = __tmp;
- this->_M_impl._M_finish = this->_M_impl._M_start + __len;
- this->_M_impl._M_end_of_storage = this->_M_impl._M_finish;
- }
- else if (size() >= __len)
- _M_erase_at_end(std::copy(__first, __last, this->_M_impl._M_start));
- else
- {
- _ForwardIterator __mid = __first;
- std::advance(__mid, size());
- std::copy(__first, __mid, this->_M_impl._M_start);
- this->_M_impl._M_finish =
- std::__uninitialized_copy_a(__mid, __last,
- this->_M_impl._M_finish,
- _M_get_Tp_allocator());
- }
- }
- template<typename _Tp, typename _Alloc>
- void
- vector<_Tp, _Alloc>::
- _M_insert_aux(iterator __position, const _Tp& __x)
- {
- if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
- {
- this->_M_impl.construct(this->_M_impl._M_finish,
- (*(this->_M_impl._M_finish - 1))
- );
- ++this->_M_impl._M_finish;
- _Tp __x_copy = __x;
- std::copy_backward(__position.base(), this->_M_impl._M_finish - 2, this->_M_impl._M_finish - 1)
- ;
- *__position = __x_copy;
- }
- else
- {
- const size_type __len =
- _M_check_len(size_type(1), "vector::_M_insert_aux");
- const size_type __elems_before = __position - begin();
- pointer __new_start(this->_M_allocate(__len));
- pointer __new_finish(__new_start);
- try
- {
- this->_M_impl.construct(__new_start + __elems_before,
- __x);
- __new_finish = 0;
- __new_finish =
- std::__uninitialized_move_a(this->_M_impl._M_start,
- __position.base(), __new_start,
- _M_get_Tp_allocator());
- ++__new_finish;
- __new_finish =
- std::__uninitialized_move_a(__position.base(),
- this->_M_impl._M_finish,
- __new_finish,
- _M_get_Tp_allocator());
- }
- catch(...)
- {
- if (!__new_finish)
- this->_M_impl.destroy(__new_start + __elems_before);
- else
- std::_Destroy(__new_start, __new_finish, _M_get_Tp_allocator());
- _M_deallocate(__new_start, __len);
- throw;
- }
- std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
- _M_get_Tp_allocator());
- _M_deallocate(this->_M_impl._M_start,
- this->_M_impl._M_end_of_storage
- - this->_M_impl._M_start);
- this->_M_impl._M_start = __new_start;
- this->_M_impl._M_finish = __new_finish;
- this->_M_impl._M_end_of_storage = __new_start + __len;
- }
- }
- template<typename _Tp, typename _Alloc>
- void
- vector<_Tp, _Alloc>::
- _M_fill_insert(iterator __position, size_type __n, const value_type& __x)
- {
- if (__n != 0)
- {
- if (size_type(this->_M_impl._M_end_of_storage
- - this->_M_impl._M_finish) >= __n)
- {
- value_type __x_copy = __x;
- const size_type __elems_after = end() - __position;
- pointer __old_finish(this->_M_impl._M_finish);
- if (__elems_after > __n)
- {
- std::__uninitialized_move_a(this->_M_impl._M_finish - __n,
- this->_M_impl._M_finish,
- this->_M_impl._M_finish,
- _M_get_Tp_allocator());
- this->_M_impl._M_finish += __n;
- std::copy_backward(__position.base(), __old_finish - __n, __old_finish)
- ;
- std::fill(__position.base(), __position.base() + __n,
- __x_copy);
- }
- else
- {
- std::__uninitialized_fill_n_a(this->_M_impl._M_finish,
- __n - __elems_after,
- __x_copy,
- _M_get_Tp_allocator());
- this->_M_impl._M_finish += __n - __elems_after;
- std::__uninitialized_move_a(__position.base(), __old_finish,
- this->_M_impl._M_finish,
- _M_get_Tp_allocator());
- this->_M_impl._M_finish += __elems_after;
- std::fill(__position.base(), __old_finish, __x_copy);
- }
- }
- else
- {
- const size_type __len =
- _M_check_len(__n, "vector::_M_fill_insert");
- const size_type __elems_before = __position - begin();
- pointer __new_start(this->_M_allocate(__len));
- pointer __new_finish(__new_start);
- try
- {
- std::__uninitialized_fill_n_a(__new_start + __elems_before,
- __n, __x,
- _M_get_Tp_allocator());
- __new_finish = 0;
- __new_finish =
- std::__uninitialized_move_a(this->_M_impl._M_start,
- __position.base(),
- __new_start,
- _M_get_Tp_allocator());
- __new_finish += __n;
- __new_finish =
- std::__uninitialized_move_a(__position.base(),
- this->_M_impl._M_finish,
- __new_finish,
- _M_get_Tp_allocator());
- }
- catch(...)
- {
- if (!__new_finish)
- std::_Destroy(__new_start + __elems_before,
- __new_start + __elems_before + __n,
- _M_get_Tp_allocator());
- else
- std::_Destroy(__new_start, __new_finish,
- _M_get_Tp_allocator());
- _M_deallocate(__new_start, __len);
- throw;
- }
- std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
- _M_get_Tp_allocator());
- _M_deallocate(this->_M_impl._M_start,
- this->_M_impl._M_end_of_storage
- - this->_M_impl._M_start);
- this->_M_impl._M_start = __new_start;
- this->_M_impl._M_finish = __new_finish;
- this->_M_impl._M_end_of_storage = __new_start + __len;
- }
- }
- }
- template<typename _Tp, typename _Alloc>
- template<typename _InputIterator>
- void
- vector<_Tp, _Alloc>::
- _M_range_insert(iterator __pos, _InputIterator __first,
- _InputIterator __last, std::input_iterator_tag)
- {
- for (; __first != __last; ++__first)
- {
- __pos = insert(__pos, *__first);
- ++__pos;
- }
- }
- template<typename _Tp, typename _Alloc>
- template<typename _ForwardIterator>
- void
- vector<_Tp, _Alloc>::
- _M_range_insert(iterator __position, _ForwardIterator __first,
- _ForwardIterator __last, std::forward_iterator_tag)
- {
- if (__first != __last)
- {
- const size_type __n = std::distance(__first, __last);
- if (size_type(this->_M_impl._M_end_of_storage
- - this->_M_impl._M_finish) >= __n)
- {
- const size_type __elems_after = end() - __position;
- pointer __old_finish(this->_M_impl._M_finish);
- if (__elems_after > __n)
- {
- std::__uninitialized_move_a(this->_M_impl._M_finish - __n,
- this->_M_impl._M_finish,
- this->_M_impl._M_finish,
- _M_get_Tp_allocator());
- this->_M_impl._M_finish += __n;
- std::copy_backward(__position.base(), __old_finish - __n, __old_finish)
- ;
- std::copy(__first, __last, __position);
- }
- else
- {
- _ForwardIterator __mid = __first;
- std::advance(__mid, __elems_after);
- std::__uninitialized_copy_a(__mid, __last,
- this->_M_impl._M_finish,
- _M_get_Tp_allocator());
- this->_M_impl._M_finish += __n - __elems_after;
- std::__uninitialized_move_a(__position.base(),
- __old_finish,
- this->_M_impl._M_finish,
- _M_get_Tp_allocator());
- this->_M_impl._M_finish += __elems_after;
- std::copy(__first, __mid, __position);
- }
- }
- else
- {
- const size_type __len =
- _M_check_len(__n, "vector::_M_range_insert");
- pointer __new_start(this->_M_allocate(__len));
- pointer __new_finish(__new_start);
- try
- {
- __new_finish =
- std::__uninitialized_move_a(this->_M_impl._M_start,
- __position.base(),
- __new_start,
- _M_get_Tp_allocator());
- __new_finish =
- std::__uninitialized_copy_a(__first, __last,
- __new_finish,
- _M_get_Tp_allocator());
- __new_finish =
- std::__uninitialized_move_a(__position.base(),
- this->_M_impl._M_finish,
- __new_finish,
- _M_get_Tp_allocator());
- }
- catch(...)
- {
- std::_Destroy(__new_start, __new_finish,
- _M_get_Tp_allocator());
- _M_deallocate(__new_start, __len);
- throw;
- }
- std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
- _M_get_Tp_allocator());
- _M_deallocate(this->_M_impl._M_start,
- this->_M_impl._M_end_of_storage
- - this->_M_impl._M_start);
- this->_M_impl._M_start = __new_start;
- this->_M_impl._M_finish = __new_finish;
- this->_M_impl._M_end_of_storage = __new_start + __len;
- }
- }
- }
- template<typename _Alloc>
- void
- vector<bool, _Alloc>::
- reserve(size_type __n)
- {
- if (__n > this->max_size())
- __throw_length_error(("vector::reserve"));
- if (this->capacity() < __n)
- {
- _Bit_type* __q = this->_M_allocate(__n);
- this->_M_impl._M_finish = _M_copy_aligned(begin(), end(),
- iterator(__q, 0));
- this->_M_deallocate();
- this->_M_impl._M_start = iterator(__q, 0);
- this->_M_impl._M_end_of_storage = (__q + (__n + int(_S_word_bit) - 1)
- / int(_S_word_bit));
- }
- }
- template<typename _Alloc>
- void
- vector<bool, _Alloc>::
- _M_fill_insert(iterator __position, size_type __n, bool __x)
- {
- if (__n == 0)
- return;
- if (capacity() - size() >= __n)
- {
- std::copy_backward(__position, end(),
- this->_M_impl._M_finish + difference_type(__n));
- std::fill(__position, __position + difference_type(__n), __x);
- this->_M_impl._M_finish += difference_type(__n);
- }
- else
- {
- const size_type __len =
- _M_check_len(__n, "vector<bool>::_M_fill_insert");
- _Bit_type * __q = this->_M_allocate(__len);
- iterator __i = _M_copy_aligned(begin(), __position,
- iterator(__q, 0));
- std::fill(__i, __i + difference_type(__n), __x);
- this->_M_impl._M_finish = std::copy(__position, end(),
- __i + difference_type(__n));
- this->_M_deallocate();
- this->_M_impl._M_end_of_storage = (__q + ((__len
- + int(_S_word_bit) - 1)
- / int(_S_word_bit)));
- this->_M_impl._M_start = iterator(__q, 0);
- }
- }
- template<typename _Alloc>
- template<typename _ForwardIterator>
- void
- vector<bool, _Alloc>::
- _M_insert_range(iterator __position, _ForwardIterator __first,
- _ForwardIterator __last, std::forward_iterator_tag)
- {
- if (__first != __last)
- {
- size_type __n = std::distance(__first, __last);
- if (capacity() - size() >= __n)
- {
- std::copy_backward(__position, end(),
- this->_M_impl._M_finish
- + difference_type(__n));
- std::copy(__first, __last, __position);
- this->_M_impl._M_finish += difference_type(__n);
- }
- else
- {
- const size_type __len =
- _M_check_len(__n, "vector<bool>::_M_insert_range");
- _Bit_type * __q = this->_M_allocate(__len);
- iterator __i = _M_copy_aligned(begin(), __position,
- iterator(__q, 0));
- __i = std::copy(__first, __last, __i);
- this->_M_impl._M_finish = std::copy(__position, end(), __i);
- this->_M_deallocate();
- this->_M_impl._M_end_of_storage = (__q
- + ((__len
- + int(_S_word_bit) - 1)
- / int(_S_word_bit)));
- this->_M_impl._M_start = iterator(__q, 0);
- }
- }
- }
- template<typename _Alloc>
- void
- vector<bool, _Alloc>::
- _M_insert_aux(iterator __position, bool __x)
- {
- if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_of_storage)
- {
- std::copy_backward(__position, this->_M_impl._M_finish,
- this->_M_impl._M_finish + 1);
- *__position = __x;
- ++this->_M_impl._M_finish;
- }
- else
- {
- const size_type __len =
- _M_check_len(size_type(1), "vector<bool>::_M_insert_aux");
- _Bit_type * __q = this->_M_allocate(__len);
- iterator __i = _M_copy_aligned(begin(), __position,
- iterator(__q, 0));
- *__i++ = __x;
- this->_M_impl._M_finish = std::copy(__position, end(), __i);
- this->_M_deallocate();
- this->_M_impl._M_end_of_storage = (__q + ((__len
- + int(_S_word_bit) - 1)
- / int(_S_word_bit)));
- this->_M_impl._M_start = iterator(__q, 0);
- }
- }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _RandomAccessIterator, typename _Distance>
- _Distance
- __is_heap_until(_RandomAccessIterator __first, _Distance __n)
- {
- _Distance __parent = 0;
- for (_Distance __child = 1; __child < __n; ++__child)
- {
- if (__first[__parent] < __first[__child])
- return __child;
- if ((__child & 1) == 0)
- ++__parent;
- }
- return __n;
- }
- template<typename _RandomAccessIterator, typename _Distance,
- typename _Compare>
- _Distance
- __is_heap_until(_RandomAccessIterator __first, _Distance __n,
- _Compare __comp)
- {
- _Distance __parent = 0;
- for (_Distance __child = 1; __child < __n; ++__child)
- {
- if (__comp(__first[__parent], __first[__child]))
- return __child;
- if ((__child & 1) == 0)
- ++__parent;
- }
- return __n;
- }
- template<typename _RandomAccessIterator, typename _Distance>
- inline bool
- __is_heap(_RandomAccessIterator __first, _Distance __n)
- { return std::__is_heap_until(__first, __n) == __n; }
- template<typename _RandomAccessIterator, typename _Compare,
- typename _Distance>
- inline bool
- __is_heap(_RandomAccessIterator __first, _Compare __comp, _Distance __n)
- { return std::__is_heap_until(__first, __n, __comp) == __n; }
- template<typename _RandomAccessIterator>
- inline bool
- __is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
- { return std::__is_heap(__first, std::distance(__first, __last)); }
- template<typename _RandomAccessIterator, typename _Compare>
- inline bool
- __is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
- _Compare __comp)
- { return std::__is_heap(__first, __comp, std::distance(__first, __last)); }
- template<typename _RandomAccessIterator, typename _Distance, typename _Tp>
- void
- __push_heap(_RandomAccessIterator __first,
- _Distance __holeIndex, _Distance __topIndex, _Tp __value)
- {
- _Distance __parent = (__holeIndex - 1) / 2;
- while (__holeIndex > __topIndex && *(__first + __parent) < __value)
- {
- *(__first + __holeIndex) = (*(__first + __parent));
- __holeIndex = __parent;
- __parent = (__holeIndex - 1) / 2;
- }
- *(__first + __holeIndex) = (__value);
- }
- template<typename _RandomAccessIterator>
- inline void
- push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
- {
- typedef typename iterator_traits<_RandomAccessIterator>::value_type
- _ValueType;
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type
- _DistanceType;
- ;
- ;
- _ValueType __value = (*(__last - 1));
- std::__push_heap(__first, _DistanceType((__last - __first) - 1),
- _DistanceType(0), (__value));
- }
- template<typename _RandomAccessIterator, typename _Distance, typename _Tp,
- typename _Compare>
- void
- __push_heap(_RandomAccessIterator __first, _Distance __holeIndex,
- _Distance __topIndex, _Tp __value, _Compare __comp)
- {
- _Distance __parent = (__holeIndex - 1) / 2;
- while (__holeIndex > __topIndex
- && __comp(*(__first + __parent), __value))
- {
- *(__first + __holeIndex) = (*(__first + __parent));
- __holeIndex = __parent;
- __parent = (__holeIndex - 1) / 2;
- }
- *(__first + __holeIndex) = (__value);
- }
- template<typename _RandomAccessIterator, typename _Compare>
- inline void
- push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
- _Compare __comp)
- {
- typedef typename iterator_traits<_RandomAccessIterator>::value_type
- _ValueType;
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type
- _DistanceType;
- ;
- ;
- _ValueType __value = (*(__last - 1));
- std::__push_heap(__first, _DistanceType((__last - __first) - 1),
- _DistanceType(0), (__value), __comp);
- }
- template<typename _RandomAccessIterator, typename _Distance, typename _Tp>
- void
- __adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
- _Distance __len, _Tp __value)
- {
- const _Distance __topIndex = __holeIndex;
- _Distance __secondChild = __holeIndex;
- while (__secondChild < (__len - 1) / 2)
- {
- __secondChild = 2 * (__secondChild + 1);
- if (*(__first + __secondChild) < *(__first + (__secondChild - 1)))
- __secondChild--;
- *(__first + __holeIndex) = (*(__first + __secondChild));
- __holeIndex = __secondChild;
- }
- if ((__len & 1) == 0 && __secondChild == (__len - 2) / 2)
- {
- __secondChild = 2 * (__secondChild + 1);
- *(__first + __holeIndex) = (*(__first + (__secondChild - 1)))
- ;
- __holeIndex = __secondChild - 1;
- }
- std::__push_heap(__first, __holeIndex, __topIndex,
- (__value));
- }
- template<typename _RandomAccessIterator>
- inline void
- __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
- _RandomAccessIterator __result)
- {
- typedef typename iterator_traits<_RandomAccessIterator>::value_type
- _ValueType;
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type
- _DistanceType;
- _ValueType __value = (*__result);
- *__result = (*__first);
- std::__adjust_heap(__first, _DistanceType(0),
- _DistanceType(__last - __first),
- (__value));
- }
- template<typename _RandomAccessIterator>
- inline void
- pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
- {
- typedef typename iterator_traits<_RandomAccessIterator>::value_type
- _ValueType;
- ;
- ;
- --__last;
- std::__pop_heap(__first, __last, __last);
- }
- template<typename _RandomAccessIterator, typename _Distance,
- typename _Tp, typename _Compare>
- void
- __adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
- _Distance __len, _Tp __value, _Compare __comp)
- {
- const _Distance __topIndex = __holeIndex;
- _Distance __secondChild = __holeIndex;
- while (__secondChild < (__len - 1) / 2)
- {
- __secondChild = 2 * (__secondChild + 1);
- if (__comp(*(__first + __secondChild),
- *(__first + (__secondChild - 1))))
- __secondChild--;
- *(__first + __holeIndex) = (*(__first + __secondChild));
- __holeIndex = __secondChild;
- }
- if ((__len & 1) == 0 && __secondChild == (__len - 2) / 2)
- {
- __secondChild = 2 * (__secondChild + 1);
- *(__first + __holeIndex) = (*(__first + (__secondChild - 1)))
- ;
- __holeIndex = __secondChild - 1;
- }
- std::__push_heap(__first, __holeIndex, __topIndex,
- (__value), __comp);
- }
- template<typename _RandomAccessIterator, typename _Compare>
- inline void
- __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
- _RandomAccessIterator __result, _Compare __comp)
- {
- typedef typename iterator_traits<_RandomAccessIterator>::value_type
- _ValueType;
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type
- _DistanceType;
- _ValueType __value = (*__result);
- *__result = (*__first);
- std::__adjust_heap(__first, _DistanceType(0),
- _DistanceType(__last - __first),
- (__value), __comp);
- }
- template<typename _RandomAccessIterator, typename _Compare>
- inline void
- pop_heap(_RandomAccessIterator __first,
- _RandomAccessIterator __last, _Compare __comp)
- {
- ;
- ;
- --__last;
- std::__pop_heap(__first, __last, __last, __comp);
- }
- template<typename _RandomAccessIterator>
- void
- make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
- {
- typedef typename iterator_traits<_RandomAccessIterator>::value_type
- _ValueType;
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type
- _DistanceType;
- ;
- if (__last - __first < 2)
- return;
- const _DistanceType __len = __last - __first;
- _DistanceType __parent = (__len - 2) / 2;
- while (true)
- {
- _ValueType __value = (*(__first + __parent));
- std::__adjust_heap(__first, __parent, __len, (__value));
- if (__parent == 0)
- return;
- __parent--;
- }
- }
- template<typename _RandomAccessIterator, typename _Compare>
- void
- make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
- _Compare __comp)
- {
- typedef typename iterator_traits<_RandomAccessIterator>::value_type
- _ValueType;
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type
- _DistanceType;
- ;
- if (__last - __first < 2)
- return;
- const _DistanceType __len = __last - __first;
- _DistanceType __parent = (__len - 2) / 2;
- while (true)
- {
- _ValueType __value = (*(__first + __parent));
- std::__adjust_heap(__first, __parent, __len, (__value),
- __comp);
- if (__parent == 0)
- return;
- __parent--;
- }
- }
- template<typename _RandomAccessIterator>
- void
- sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
- {
- ;
- ;
- while (__last - __first > 1)
- {
- --__last;
- std::__pop_heap(__first, __last, __last);
- }
- }
- template<typename _RandomAccessIterator, typename _Compare>
- void
- sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
- _Compare __comp)
- {
- ;
- ;
- while (__last - __first > 1)
- {
- --__last;
- std::__pop_heap(__first, __last, __last, __comp);
- }
- }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _Tp, typename _Sequence = deque<_Tp> >
- class queue
- {
- typedef typename _Sequence::value_type _Sequence_value_type;
- template<typename _Tp1, typename _Seq1>
- friend bool
- operator==(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&);
- template<typename _Tp1, typename _Seq1>
- friend bool
- operator<(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&);
- public:
- typedef typename _Sequence::value_type value_type;
- typedef typename _Sequence::reference reference;
- typedef typename _Sequence::const_reference const_reference;
- typedef typename _Sequence::size_type size_type;
- typedef _Sequence container_type;
- protected:
- _Sequence c;
- public:
- explicit
- queue(const _Sequence& __c = _Sequence())
- : c(__c) { }
- bool
- empty() const
- { return c.empty(); }
- size_type
- size() const
- { return c.size(); }
- reference
- front()
- {
- ;
- return c.front();
- }
- const_reference
- front() const
- {
- ;
- return c.front();
- }
- reference
- back()
- {
- ;
- return c.back();
- }
- const_reference
- back() const
- {
- ;
- return c.back();
- }
- void
- push(const value_type& __x)
- { c.push_back(__x); }
- void
- pop()
- {
- ;
- c.pop_front();
- }
- };
- template<typename _Tp, typename _Seq>
- inline bool
- operator==(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
- { return __x.c == __y.c; }
- template<typename _Tp, typename _Seq>
- inline bool
- operator<(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
- { return __x.c < __y.c; }
- template<typename _Tp, typename _Seq>
- inline bool
- operator!=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
- { return !(__x == __y); }
- template<typename _Tp, typename _Seq>
- inline bool
- operator>(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
- { return __y < __x; }
- template<typename _Tp, typename _Seq>
- inline bool
- operator<=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
- { return !(__y < __x); }
- template<typename _Tp, typename _Seq>
- inline bool
- operator>=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
- { return !(__x < __y); }
- template<typename _Tp, typename _Sequence = vector<_Tp>,
- typename _Compare = less<typename _Sequence::value_type> >
- class priority_queue
- {
- typedef typename _Sequence::value_type _Sequence_value_type;
- public:
- typedef typename _Sequence::value_type value_type;
- typedef typename _Sequence::reference reference;
- typedef typename _Sequence::const_reference const_reference;
- typedef typename _Sequence::size_type size_type;
- typedef _Sequence container_type;
- protected:
- _Sequence c;
- _Compare comp;
- public:
- explicit
- priority_queue(const _Compare& __x = _Compare(),
- const _Sequence& __s = _Sequence())
- : c(__s), comp(__x)
- { std::make_heap(c.begin(), c.end(), comp); }
- template<typename _InputIterator>
- priority_queue(_InputIterator __first, _InputIterator __last,
- const _Compare& __x = _Compare(),
- const _Sequence& __s = _Sequence())
- : c(__s), comp(__x)
- {
- ;
- c.insert(c.end(), __first, __last);
- std::make_heap(c.begin(), c.end(), comp);
- }
- bool
- empty() const
- { return c.empty(); }
- size_type
- size() const
- { return c.size(); }
- const_reference
- top() const
- {
- ;
- return c.front();
- }
- void
- push(const value_type& __x)
- {
- c.push_back(__x);
- std::push_heap(c.begin(), c.end(), comp);
- }
- void
- pop()
- {
- ;
- std::pop_heap(c.begin(), c.end(), comp);
- c.pop_back();
- }
- };
-}
-extern "C" {
-union wait
- {
- int w_status;
- struct
- {
- unsigned int __w_termsig:7;
- unsigned int __w_coredump:1;
- unsigned int __w_retcode:8;
- unsigned int:16;
- } __wait_terminated;
- struct
- {
- unsigned int __w_stopval:8;
- unsigned int __w_stopsig:8;
- unsigned int:16;
- } __wait_stopped;
- };
-typedef struct
- {
- int quot;
- int rem;
- } div_t;
-typedef struct
- {
- long int quot;
- long int rem;
- } ldiv_t;
-__extension__ typedef struct
- {
- long long int quot;
- long long int rem;
- } lldiv_t;
-extern size_t __ctype_get_mb_cur_max (void) throw () ;
-extern double atof (__const char *__nptr)
- throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;
-extern int atoi (__const char *__nptr)
- throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;
-extern long int atol (__const char *__nptr)
- throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;
-__extension__ extern long long int atoll (__const char *__nptr)
- throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;
-extern double strtod (__const char *__restrict __nptr,
- char **__restrict __endptr)
- throw () __attribute__ ((__nonnull__ (1))) ;
-extern float strtof (__const char *__restrict __nptr,
- char **__restrict __endptr) throw () __attribute__ ((__nonnull__ (1))) ;
-extern long double strtold (__const char *__restrict __nptr,
- char **__restrict __endptr)
- throw () __attribute__ ((__nonnull__ (1))) ;
-extern long int strtol (__const char *__restrict __nptr,
- char **__restrict __endptr, int __base)
- throw () __attribute__ ((__nonnull__ (1))) ;
-extern unsigned long int strtoul (__const char *__restrict __nptr,
- char **__restrict __endptr, int __base)
- throw () __attribute__ ((__nonnull__ (1))) ;
-__extension__
-extern long long int strtoq (__const char *__restrict __nptr,
- char **__restrict __endptr, int __base)
- throw () __attribute__ ((__nonnull__ (1))) ;
-__extension__
-extern unsigned long long int strtouq (__const char *__restrict __nptr,
- char **__restrict __endptr, int __base)
- throw () __attribute__ ((__nonnull__ (1))) ;
-__extension__
-extern long long int strtoll (__const char *__restrict __nptr,
- char **__restrict __endptr, int __base)
- throw () __attribute__ ((__nonnull__ (1))) ;
-__extension__
-extern unsigned long long int strtoull (__const char *__restrict __nptr,
- char **__restrict __endptr, int __base)
- throw () __attribute__ ((__nonnull__ (1))) ;
-extern long int strtol_l (__const char *__restrict __nptr,
- char **__restrict __endptr, int __base,
- __locale_t __loc) throw () __attribute__ ((__nonnull__ (1, 4))) ;
-extern unsigned long int strtoul_l (__const char *__restrict __nptr,
- char **__restrict __endptr,
- int __base, __locale_t __loc)
- throw () __attribute__ ((__nonnull__ (1, 4))) ;
-__extension__
-extern long long int strtoll_l (__const char *__restrict __nptr,
- char **__restrict __endptr, int __base,
- __locale_t __loc)
- throw () __attribute__ ((__nonnull__ (1, 4))) ;
-__extension__
-extern unsigned long long int strtoull_l (__const char *__restrict __nptr,
- char **__restrict __endptr,
- int __base, __locale_t __loc)
- throw () __attribute__ ((__nonnull__ (1, 4))) ;
-extern double strtod_l (__const char *__restrict __nptr,
- char **__restrict __endptr, __locale_t __loc)
- throw () __attribute__ ((__nonnull__ (1, 3))) ;
-extern float strtof_l (__const char *__restrict __nptr,
- char **__restrict __endptr, __locale_t __loc)
- throw () __attribute__ ((__nonnull__ (1, 3))) ;
-extern long double strtold_l (__const char *__restrict __nptr,
- char **__restrict __endptr,
- __locale_t __loc)
- throw () __attribute__ ((__nonnull__ (1, 3))) ;
-extern __inline __attribute__ ((__gnu_inline__)) double
-atof (__const char *__nptr) throw ()
-{
- return strtod (__nptr, (char **) __null);
-}
-extern __inline __attribute__ ((__gnu_inline__)) int
-atoi (__const char *__nptr) throw ()
-{
- return (int) strtol (__nptr, (char **) __null, 10);
-}
-extern __inline __attribute__ ((__gnu_inline__)) long int
-atol (__const char *__nptr) throw ()
-{
- return strtol (__nptr, (char **) __null, 10);
-}
-__extension__ extern __inline __attribute__ ((__gnu_inline__)) long long int
-atoll (__const char *__nptr) throw ()
-{
- return strtoll (__nptr, (char **) __null, 10);
-}
-extern char *l64a (long int __n) throw () ;
-extern long int a64l (__const char *__s)
- throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;
-extern "C" {
-typedef __u_char u_char;
-typedef __u_short u_short;
-typedef __u_int u_int;
-typedef __u_long u_long;
-typedef __quad_t quad_t;
-typedef __u_quad_t u_quad_t;
-typedef __fsid_t fsid_t;
-typedef __loff_t loff_t;
-typedef __ino_t ino_t;
-typedef __ino64_t ino64_t;
-typedef __dev_t dev_t;
-typedef __mode_t mode_t;
-typedef __nlink_t nlink_t;
-typedef __id_t id_t;
-typedef __daddr_t daddr_t;
-typedef __caddr_t caddr_t;
-typedef __key_t key_t;
-typedef __suseconds_t suseconds_t;
-typedef unsigned long int ulong;
-typedef unsigned short int ushort;
-typedef unsigned int uint;
-typedef int int8_t __attribute__ ((__mode__ (__QI__)));
-typedef int int16_t __attribute__ ((__mode__ (__HI__)));
-typedef int int32_t __attribute__ ((__mode__ (__SI__)));
-typedef int int64_t __attribute__ ((__mode__ (__DI__)));
-typedef unsigned int u_int8_t __attribute__ ((__mode__ (__QI__)));
-typedef unsigned int u_int16_t __attribute__ ((__mode__ (__HI__)));
-typedef unsigned int u_int32_t __attribute__ ((__mode__ (__SI__)));
-typedef unsigned int u_int64_t __attribute__ ((__mode__ (__DI__)));
-typedef int register_t __attribute__ ((__mode__ (__word__)));
-typedef int __sig_atomic_t;
-typedef struct
- {
- unsigned long int __val[(1024 / (8 * sizeof (unsigned long int)))];
- } __sigset_t;
-typedef __sigset_t sigset_t;
-struct timeval
- {
- __time_t tv_sec;
- __suseconds_t tv_usec;
- };
-typedef long int __fd_mask;
-typedef struct
- {
- __fd_mask fds_bits[1024 / (8 * (int) sizeof (__fd_mask))];
- } fd_set;
-typedef __fd_mask fd_mask;
-extern "C" {
-extern int select (int __nfds, fd_set *__restrict __readfds,
- fd_set *__restrict __writefds,
- fd_set *__restrict __exceptfds,
- struct timeval *__restrict __timeout);
-extern int pselect (int __nfds, fd_set *__restrict __readfds,
- fd_set *__restrict __writefds,
- fd_set *__restrict __exceptfds,
- const struct timespec *__restrict __timeout,
- const __sigset_t *__restrict __sigmask);
-}
-__extension__
-extern unsigned int gnu_dev_major (unsigned long long int __dev)
- throw ();
-__extension__
-extern unsigned int gnu_dev_minor (unsigned long long int __dev)
- throw ();
-__extension__
-extern unsigned long long int gnu_dev_makedev (unsigned int __major,
- unsigned int __minor)
- throw ();
-__extension__ extern __inline __attribute__ ((__gnu_inline__)) unsigned int
-gnu_dev_major (unsigned long long int __dev) throw ()
-{
- return ((__dev >> 8) & 0xfff) | ((unsigned int) (__dev >> 32) & ~0xfff);
-}
-__extension__ extern __inline __attribute__ ((__gnu_inline__)) unsigned int
-gnu_dev_minor (unsigned long long int __dev) throw ()
-{
- return (__dev & 0xff) | ((unsigned int) (__dev >> 12) & ~0xff);
-}
-__extension__ extern __inline __attribute__ ((__gnu_inline__)) unsigned long long int
-gnu_dev_makedev (unsigned int __major, unsigned int __minor) throw ()
-{
- return ((__minor & 0xff) | ((__major & 0xfff) << 8)
- | (((unsigned long long int) (__minor & ~0xff)) << 12)
- | (((unsigned long long int) (__major & ~0xfff)) << 32));
-}
-typedef __blksize_t blksize_t;
-typedef __blkcnt_t blkcnt_t;
-typedef __fsblkcnt_t fsblkcnt_t;
-typedef __fsfilcnt_t fsfilcnt_t;
-typedef __blkcnt64_t blkcnt64_t;
-typedef __fsblkcnt64_t fsblkcnt64_t;
-typedef __fsfilcnt64_t fsfilcnt64_t;
-}
-extern long int random (void) throw ();
-extern void srandom (unsigned int __seed) throw ();
-extern char *initstate (unsigned int __seed, char *__statebuf,
- size_t __statelen) throw () __attribute__ ((__nonnull__ (2)));
-extern char *setstate (char *__statebuf) throw () __attribute__ ((__nonnull__ (1)));
-struct random_data
- {
- int32_t *fptr;
- int32_t *rptr;
- int32_t *state;
- int rand_type;
- int rand_deg;
- int rand_sep;
- int32_t *end_ptr;
- };
-extern int random_r (struct random_data *__restrict __buf,
- int32_t *__restrict __result) throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int srandom_r (unsigned int __seed, struct random_data *__buf)
- throw () __attribute__ ((__nonnull__ (2)));
-extern int initstate_r (unsigned int __seed, char *__restrict __statebuf,
- size_t __statelen,
- struct random_data *__restrict __buf)
- throw () __attribute__ ((__nonnull__ (2, 4)));
-extern int setstate_r (char *__restrict __statebuf,
- struct random_data *__restrict __buf)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int rand (void) throw ();
-extern void srand (unsigned int __seed) throw ();
-extern int rand_r (unsigned int *__seed) throw ();
-extern double drand48 (void) throw ();
-extern double erand48 (unsigned short int __xsubi[3]) throw () __attribute__ ((__nonnull__ (1)));
-extern long int lrand48 (void) throw ();
-extern long int nrand48 (unsigned short int __xsubi[3])
- throw () __attribute__ ((__nonnull__ (1)));
-extern long int mrand48 (void) throw ();
-extern long int jrand48 (unsigned short int __xsubi[3])
- throw () __attribute__ ((__nonnull__ (1)));
-extern void srand48 (long int __seedval) throw ();
-extern unsigned short int *seed48 (unsigned short int __seed16v[3])
- throw () __attribute__ ((__nonnull__ (1)));
-extern void lcong48 (unsigned short int __param[7]) throw () __attribute__ ((__nonnull__ (1)));
-struct drand48_data
- {
- unsigned short int __x[3];
- unsigned short int __old_x[3];
- unsigned short int __c;
- unsigned short int __init;
- unsigned long long int __a;
- };
-extern int drand48_r (struct drand48_data *__restrict __buffer,
- double *__restrict __result) throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int erand48_r (unsigned short int __xsubi[3],
- struct drand48_data *__restrict __buffer,
- double *__restrict __result) throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int lrand48_r (struct drand48_data *__restrict __buffer,
- long int *__restrict __result)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int nrand48_r (unsigned short int __xsubi[3],
- struct drand48_data *__restrict __buffer,
- long int *__restrict __result)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int mrand48_r (struct drand48_data *__restrict __buffer,
- long int *__restrict __result)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int jrand48_r (unsigned short int __xsubi[3],
- struct drand48_data *__restrict __buffer,
- long int *__restrict __result)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int srand48_r (long int __seedval, struct drand48_data *__buffer)
- throw () __attribute__ ((__nonnull__ (2)));
-extern int seed48_r (unsigned short int __seed16v[3],
- struct drand48_data *__buffer) throw () __attribute__ ((__nonnull__ (1, 2)));
-extern int lcong48_r (unsigned short int __param[7],
- struct drand48_data *__buffer)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern void *malloc (size_t __size) throw () __attribute__ ((__malloc__)) ;
-extern void *calloc (size_t __nmemb, size_t __size)
- throw () __attribute__ ((__malloc__)) ;
-extern void *realloc (void *__ptr, size_t __size)
- throw () __attribute__ ((__warn_unused_result__));
-extern void free (void *__ptr) throw ();
-extern void cfree (void *__ptr) throw ();
-extern "C" {
-extern void *alloca (size_t __size) throw ();
-}
-extern void *valloc (size_t __size) throw () __attribute__ ((__malloc__)) ;
-extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size)
- throw () __attribute__ ((__nonnull__ (1))) ;
-extern void abort (void) throw () __attribute__ ((__noreturn__));
-extern int atexit (void (*__func) (void)) throw () __attribute__ ((__nonnull__ (1)));
-extern "C++" int at_quick_exit (void (*__func) (void))
- throw () __asm ("at_quick_exit") __attribute__ ((__nonnull__ (1)));
-extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg)
- throw () __attribute__ ((__nonnull__ (1)));
-extern void exit (int __status) throw () __attribute__ ((__noreturn__));
-extern void quick_exit (int __status) throw () __attribute__ ((__noreturn__));
-extern void _Exit (int __status) throw () __attribute__ ((__noreturn__));
-extern char *getenv (__const char *__name) throw () __attribute__ ((__nonnull__ (1))) ;
-extern char *__secure_getenv (__const char *__name)
- throw () __attribute__ ((__nonnull__ (1))) ;
-extern int putenv (char *__string) throw () __attribute__ ((__nonnull__ (1)));
-extern int setenv (__const char *__name, __const char *__value, int __replace)
- throw () __attribute__ ((__nonnull__ (2)));
-extern int unsetenv (__const char *__name) throw () __attribute__ ((__nonnull__ (1)));
-extern int clearenv (void) throw ();
-extern char *mktemp (char *__template) throw () __attribute__ ((__nonnull__ (1))) ;
-extern int mkstemp (char *__template) __attribute__ ((__nonnull__ (1))) ;
-extern int mkstemp64 (char *__template) __attribute__ ((__nonnull__ (1))) ;
-extern int mkstemps (char *__template, int __suffixlen) __attribute__ ((__nonnull__ (1))) ;
-extern int mkstemps64 (char *__template, int __suffixlen)
- __attribute__ ((__nonnull__ (1))) ;
-extern char *mkdtemp (char *__template) throw () __attribute__ ((__nonnull__ (1))) ;
-extern int mkostemp (char *__template, int __flags) __attribute__ ((__nonnull__ (1))) ;
-extern int mkostemp64 (char *__template, int __flags) __attribute__ ((__nonnull__ (1))) ;
-extern int mkostemps (char *__template, int __suffixlen, int __flags)
- __attribute__ ((__nonnull__ (1))) ;
-extern int mkostemps64 (char *__template, int __suffixlen, int __flags)
- __attribute__ ((__nonnull__ (1))) ;
-extern int system (__const char *__command) ;
-extern char *canonicalize_file_name (__const char *__name)
- throw () __attribute__ ((__nonnull__ (1))) ;
-extern char *realpath (__const char *__restrict __name,
- char *__restrict __resolved) throw () ;
-typedef int (*__compar_fn_t) (__const void *, __const void *);
-typedef __compar_fn_t comparison_fn_t;
-typedef int (*__compar_d_fn_t) (__const void *, __const void *, void *);
-extern void *bsearch (__const void *__key, __const void *__base,
- size_t __nmemb, size_t __size, __compar_fn_t __compar)
- __attribute__ ((__nonnull__ (1, 2, 5))) ;
-extern void qsort (void *__base, size_t __nmemb, size_t __size,
- __compar_fn_t __compar) __attribute__ ((__nonnull__ (1, 4)));
-extern void qsort_r (void *__base, size_t __nmemb, size_t __size,
- __compar_d_fn_t __compar, void *__arg)
- __attribute__ ((__nonnull__ (1, 4)));
-extern int abs (int __x) throw () __attribute__ ((__const__)) ;
-extern long int labs (long int __x) throw () __attribute__ ((__const__)) ;
-__extension__ extern long long int llabs (long long int __x)
- throw () __attribute__ ((__const__)) ;
-extern div_t div (int __numer, int __denom)
- throw () __attribute__ ((__const__)) ;
-extern ldiv_t ldiv (long int __numer, long int __denom)
- throw () __attribute__ ((__const__)) ;
-__extension__ extern lldiv_t lldiv (long long int __numer,
- long long int __denom)
- throw () __attribute__ ((__const__)) ;
-extern char *ecvt (double __value, int __ndigit, int *__restrict __decpt,
- int *__restrict __sign) throw () __attribute__ ((__nonnull__ (3, 4))) ;
-extern char *fcvt (double __value, int __ndigit, int *__restrict __decpt,
- int *__restrict __sign) throw () __attribute__ ((__nonnull__ (3, 4))) ;
-extern char *gcvt (double __value, int __ndigit, char *__buf)
- throw () __attribute__ ((__nonnull__ (3))) ;
-extern char *qecvt (long double __value, int __ndigit,
- int *__restrict __decpt, int *__restrict __sign)
- throw () __attribute__ ((__nonnull__ (3, 4))) ;
-extern char *qfcvt (long double __value, int __ndigit,
- int *__restrict __decpt, int *__restrict __sign)
- throw () __attribute__ ((__nonnull__ (3, 4))) ;
-extern char *qgcvt (long double __value, int __ndigit, char *__buf)
- throw () __attribute__ ((__nonnull__ (3))) ;
-extern int ecvt_r (double __value, int __ndigit, int *__restrict __decpt,
- int *__restrict __sign, char *__restrict __buf,
- size_t __len) throw () __attribute__ ((__nonnull__ (3, 4, 5)));
-extern int fcvt_r (double __value, int __ndigit, int *__restrict __decpt,
- int *__restrict __sign, char *__restrict __buf,
- size_t __len) throw () __attribute__ ((__nonnull__ (3, 4, 5)));
-extern int qecvt_r (long double __value, int __ndigit,
- int *__restrict __decpt, int *__restrict __sign,
- char *__restrict __buf, size_t __len)
- throw () __attribute__ ((__nonnull__ (3, 4, 5)));
-extern int qfcvt_r (long double __value, int __ndigit,
- int *__restrict __decpt, int *__restrict __sign,
- char *__restrict __buf, size_t __len)
- throw () __attribute__ ((__nonnull__ (3, 4, 5)));
-extern int mblen (__const char *__s, size_t __n) throw () ;
-extern int mbtowc (wchar_t *__restrict __pwc,
- __const char *__restrict __s, size_t __n) throw () ;
-extern int wctomb (char *__s, wchar_t __wchar) throw () ;
-extern size_t mbstowcs (wchar_t *__restrict __pwcs,
- __const char *__restrict __s, size_t __n) throw ();
-extern size_t wcstombs (char *__restrict __s,
- __const wchar_t *__restrict __pwcs, size_t __n)
- throw ();
-extern int rpmatch (__const char *__response) throw () __attribute__ ((__nonnull__ (1))) ;
-extern int getsubopt (char **__restrict __optionp,
- char *__const *__restrict __tokens,
- char **__restrict __valuep)
- throw () __attribute__ ((__nonnull__ (1, 2, 3))) ;
-extern void setkey (__const char *__key) throw () __attribute__ ((__nonnull__ (1)));
-extern int posix_openpt (int __oflag) ;
-extern int grantpt (int __fd) throw ();
-extern int unlockpt (int __fd) throw ();
-extern char *ptsname (int __fd) throw () ;
-extern int ptsname_r (int __fd, char *__buf, size_t __buflen)
- throw () __attribute__ ((__nonnull__ (2)));
-extern int getpt (void);
-extern int getloadavg (double __loadavg[], int __nelem)
- throw () __attribute__ ((__nonnull__ (1)));
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- using ::div_t;
- using ::ldiv_t;
- using ::abort;
- using ::abs;
- using ::atexit;
- using ::atof;
- using ::atoi;
- using ::atol;
- using ::bsearch;
- using ::calloc;
- using ::div;
- using ::exit;
- using ::free;
- using ::getenv;
- using ::labs;
- using ::ldiv;
- using ::malloc;
- using ::mblen;
- using ::mbstowcs;
- using ::mbtowc;
- using ::qsort;
- using ::rand;
- using ::realloc;
- using ::srand;
- using ::strtod;
- using ::strtol;
- using ::strtoul;
- using ::system;
- using ::wcstombs;
- using ::wctomb;
- inline long
- abs(long __i) { return labs(__i); }
- inline ldiv_t
- div(long __i, long __j) { return ldiv(__i, __j); }
-}
-namespace __gnu_cxx __attribute__ ((__visibility__ ("default")))
-{
- using ::lldiv_t;
- using ::_Exit;
- inline long long
- abs(long long __x) { return __x >= 0 ? __x : -__x; }
- using ::llabs;
- inline lldiv_t
- div(long long __n, long long __d)
- { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
- using ::lldiv;
- using ::atoll;
- using ::strtoll;
- using ::strtoull;
- using ::strtof;
- using ::strtold;
-}
-namespace std
-{
- using ::__gnu_cxx::lldiv_t;
- using ::__gnu_cxx::_Exit;
- using ::__gnu_cxx::abs;
- using ::__gnu_cxx::llabs;
- using ::__gnu_cxx::div;
- using ::__gnu_cxx::lldiv;
- using ::__gnu_cxx::atoll;
- using ::__gnu_cxx::strtof;
- using ::__gnu_cxx::strtoll;
- using ::__gnu_cxx::strtoull;
- using ::__gnu_cxx::strtold;
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- namespace rel_ops
- {
- template <class _Tp>
- inline bool
- operator!=(const _Tp& __x, const _Tp& __y)
- { return !(__x == __y); }
- template <class _Tp>
- inline bool
- operator>(const _Tp& __x, const _Tp& __y)
- { return __y < __x; }
- template <class _Tp>
- inline bool
- operator<=(const _Tp& __x, const _Tp& __y)
- { return !(__y < __x); }
- template <class _Tp>
- inline bool
- operator>=(const _Tp& __x, const _Tp& __y)
- { return !(__x < __y); }
- }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _FIter, typename _Tp>
- bool
- binary_search(_FIter, _FIter, const _Tp&);
- template<typename _FIter, typename _Tp, typename _Compare>
- bool
- binary_search(_FIter, _FIter, const _Tp&, _Compare);
- template<typename _IIter, typename _OIter>
- _OIter
- copy(_IIter, _IIter, _OIter);
- template<typename _BIter1, typename _BIter2>
- _BIter2
- copy_backward(_BIter1, _BIter1, _BIter2);
- template<typename _FIter, typename _Tp>
- pair<_FIter, _FIter>
- equal_range(_FIter, _FIter, const _Tp&);
- template<typename _FIter, typename _Tp, typename _Compare>
- pair<_FIter, _FIter>
- equal_range(_FIter, _FIter, const _Tp&, _Compare);
- template<typename _FIter, typename _Tp>
- void
- fill(_FIter, _FIter, const _Tp&);
- template<typename _OIter, typename _Size, typename _Tp>
- _OIter
- fill_n(_OIter, _Size, const _Tp&);
- template<typename _FIter1, typename _FIter2>
- _FIter1
- find_end(_FIter1, _FIter1, _FIter2, _FIter2);
- template<typename _FIter1, typename _FIter2, typename _BinaryPredicate>
- _FIter1
- find_end(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate);
- template<typename _IIter1, typename _IIter2>
- bool
- includes(_IIter1, _IIter1, _IIter2, _IIter2);
- template<typename _IIter1, typename _IIter2, typename _Compare>
- bool
- includes(_IIter1, _IIter1, _IIter2, _IIter2, _Compare);
- template<typename _BIter>
- void
- inplace_merge(_BIter, _BIter, _BIter);
- template<typename _BIter, typename _Compare>
- void
- inplace_merge(_BIter, _BIter, _BIter, _Compare);
- template<typename _FIter1, typename _FIter2>
- void
- iter_swap(_FIter1, _FIter2);
- template<typename _FIter, typename _Tp>
- _FIter
- lower_bound(_FIter, _FIter, const _Tp&);
- template<typename _FIter, typename _Tp, typename _Compare>
- _FIter
- lower_bound(_FIter, _FIter, const _Tp&, _Compare);
- template<typename _RAIter>
- void
- make_heap(_RAIter, _RAIter);
- template<typename _RAIter, typename _Compare>
- void
- make_heap(_RAIter, _RAIter, _Compare);
- template<typename _Tp>
- const _Tp&
- max(const _Tp&, const _Tp&);
- template<typename _Tp, typename _Compare>
- const _Tp&
- max(const _Tp&, const _Tp&, _Compare);
- template<typename _Tp>
- const _Tp&
- min(const _Tp&, const _Tp&);
- template<typename _Tp, typename _Compare>
- const _Tp&
- min(const _Tp&, const _Tp&, _Compare);
- template<typename _BIter>
- bool
- next_permutation(_BIter, _BIter);
- template<typename _BIter, typename _Compare>
- bool
- next_permutation(_BIter, _BIter, _Compare);
- template<typename _IIter, typename _RAIter>
- _RAIter
- partial_sort_copy(_IIter, _IIter, _RAIter, _RAIter);
- template<typename _IIter, typename _RAIter, typename _Compare>
- _RAIter
- partial_sort_copy(_IIter, _IIter, _RAIter, _RAIter, _Compare);
- template<typename _RAIter>
- void
- pop_heap(_RAIter, _RAIter);
- template<typename _RAIter, typename _Compare>
- void
- pop_heap(_RAIter, _RAIter, _Compare);
- template<typename _BIter>
- bool
- prev_permutation(_BIter, _BIter);
- template<typename _BIter, typename _Compare>
- bool
- prev_permutation(_BIter, _BIter, _Compare);
- template<typename _RAIter>
- void
- push_heap(_RAIter, _RAIter);
- template<typename _RAIter, typename _Compare>
- void
- push_heap(_RAIter, _RAIter, _Compare);
- template<typename _FIter, typename _Tp>
- _FIter
- remove(_FIter, _FIter, const _Tp&);
- template<typename _FIter, typename _Predicate>
- _FIter
- remove_if(_FIter, _FIter, _Predicate);
- template<typename _IIter, typename _OIter, typename _Tp>
- _OIter
- remove_copy(_IIter, _IIter, _OIter, const _Tp&);
- template<typename _IIter, typename _OIter, typename _Predicate>
- _OIter
- remove_copy_if(_IIter, _IIter, _OIter, _Predicate);
- template<typename _IIter, typename _OIter, typename _Tp>
- _OIter
- replace_copy(_IIter, _IIter, _OIter, const _Tp&, const _Tp&);
- template<typename _Iter, typename _OIter, typename _Predicate, typename _Tp>
- _OIter
- replace_copy_if(_Iter, _Iter, _OIter, _Predicate, const _Tp&);
- template<typename _BIter>
- void
- reverse(_BIter, _BIter);
- template<typename _BIter, typename _OIter>
- _OIter
- reverse_copy(_BIter, _BIter, _OIter);
- template<typename _FIter>
- void
- rotate(_FIter, _FIter, _FIter);
- template<typename _FIter, typename _OIter>
- _OIter
- rotate_copy(_FIter, _FIter, _FIter, _OIter);
- template<typename _RAIter>
- void
- sort_heap(_RAIter, _RAIter);
- template<typename _RAIter, typename _Compare>
- void
- sort_heap(_RAIter, _RAIter, _Compare);
- template<typename _BIter, typename _Predicate>
- _BIter
- stable_partition(_BIter, _BIter, _Predicate);
- template<typename _Tp>
- void
- swap(_Tp&, _Tp&);
- template<typename _Tp, size_t _Nm>
- void
- swap(_Tp (&)[_Nm], _Tp (&)[_Nm]);
- template<typename _FIter1, typename _FIter2>
- _FIter2
- swap_ranges(_FIter1, _FIter1, _FIter2);
- template<typename _FIter>
- _FIter
- unique(_FIter, _FIter);
- template<typename _FIter, typename _BinaryPredicate>
- _FIter
- unique(_FIter, _FIter, _BinaryPredicate);
- template<typename _FIter, typename _Tp>
- _FIter
- upper_bound(_FIter, _FIter, const _Tp&);
- template<typename _FIter, typename _Tp, typename _Compare>
- _FIter
- upper_bound(_FIter, _FIter, const _Tp&, _Compare);
- template<typename _FIter>
- _FIter
- adjacent_find(_FIter, _FIter);
- template<typename _FIter, typename _BinaryPredicate>
- _FIter
- adjacent_find(_FIter, _FIter, _BinaryPredicate);
- template<typename _IIter, typename _Tp>
- typename iterator_traits<_IIter>::difference_type
- count(_IIter, _IIter, const _Tp&);
- template<typename _IIter, typename _Predicate>
- typename iterator_traits<_IIter>::difference_type
- count_if(_IIter, _IIter, _Predicate);
- template<typename _IIter1, typename _IIter2>
- bool
- equal(_IIter1, _IIter1, _IIter2);
- template<typename _IIter1, typename _IIter2, typename _BinaryPredicate>
- bool
- equal(_IIter1, _IIter1, _IIter2, _BinaryPredicate);
- template<typename _IIter, typename _Tp>
- _IIter
- find(_IIter, _IIter, const _Tp&);
- template<typename _FIter1, typename _FIter2>
- _FIter1
- find_first_of(_FIter1, _FIter1, _FIter2, _FIter2);
- template<typename _FIter1, typename _FIter2, typename _BinaryPredicate>
- _FIter1
- find_first_of(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate);
- template<typename _IIter, typename _Predicate>
- _IIter
- find_if(_IIter, _IIter, _Predicate);
- template<typename _IIter, typename _Funct>
- _Funct
- for_each(_IIter, _IIter, _Funct);
- template<typename _FIter, typename _Generator>
- void
- generate(_FIter, _FIter, _Generator);
- template<typename _OIter, typename _Size, typename _Generator>
- _OIter
- generate_n(_OIter, _Size, _Generator);
- template<typename _IIter1, typename _IIter2>
- bool
- lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2);
- template<typename _IIter1, typename _IIter2, typename _Compare>
- bool
- lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2, _Compare);
- template<typename _FIter>
- _FIter
- max_element(_FIter, _FIter);
- template<typename _FIter, typename _Compare>
- _FIter
- max_element(_FIter, _FIter, _Compare);
- template<typename _IIter1, typename _IIter2, typename _OIter>
- _OIter
- merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter);
- template<typename _IIter1, typename _IIter2, typename _OIter,
- typename _Compare>
- _OIter
- merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare);
- template<typename _FIter>
- _FIter
- min_element(_FIter, _FIter);
- template<typename _FIter, typename _Compare>
- _FIter
- min_element(_FIter, _FIter, _Compare);
- template<typename _IIter1, typename _IIter2>
- pair<_IIter1, _IIter2>
- mismatch(_IIter1, _IIter1, _IIter2);
- template<typename _IIter1, typename _IIter2, typename _BinaryPredicate>
- pair<_IIter1, _IIter2>
- mismatch(_IIter1, _IIter1, _IIter2, _BinaryPredicate);
- template<typename _RAIter>
- void
- nth_element(_RAIter, _RAIter, _RAIter);
- template<typename _RAIter, typename _Compare>
- void
- nth_element(_RAIter, _RAIter, _RAIter, _Compare);
- template<typename _RAIter>
- void
- partial_sort(_RAIter, _RAIter, _RAIter);
- template<typename _RAIter, typename _Compare>
- void
- partial_sort(_RAIter, _RAIter, _RAIter, _Compare);
- template<typename _BIter, typename _Predicate>
- _BIter
- partition(_BIter, _BIter, _Predicate);
- template<typename _RAIter>
- void
- random_shuffle(_RAIter, _RAIter);
- template<typename _RAIter, typename _Generator>
- void
- random_shuffle(_RAIter, _RAIter,
- _Generator&);
- template<typename _FIter, typename _Tp>
- void
- replace(_FIter, _FIter, const _Tp&, const _Tp&);
- template<typename _FIter, typename _Predicate, typename _Tp>
- void
- replace_if(_FIter, _FIter, _Predicate, const _Tp&);
- template<typename _FIter1, typename _FIter2>
- _FIter1
- search(_FIter1, _FIter1, _FIter2, _FIter2);
- template<typename _FIter1, typename _FIter2, typename _BinaryPredicate>
- _FIter1
- search(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate);
- template<typename _FIter, typename _Size, typename _Tp>
- _FIter
- search_n(_FIter, _FIter, _Size, const _Tp&);
- template<typename _FIter, typename _Size, typename _Tp,
- typename _BinaryPredicate>
- _FIter
- search_n(_FIter, _FIter, _Size, const _Tp&, _BinaryPredicate);
- template<typename _IIter1, typename _IIter2, typename _OIter>
- _OIter
- set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter);
- template<typename _IIter1, typename _IIter2, typename _OIter,
- typename _Compare>
- _OIter
- set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare);
- template<typename _IIter1, typename _IIter2, typename _OIter>
- _OIter
- set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter);
- template<typename _IIter1, typename _IIter2, typename _OIter,
- typename _Compare>
- _OIter
- set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare);
- template<typename _IIter1, typename _IIter2, typename _OIter>
- _OIter
- set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter);
- template<typename _IIter1, typename _IIter2, typename _OIter,
- typename _Compare>
- _OIter
- set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2,
- _OIter, _Compare);
- template<typename _IIter1, typename _IIter2, typename _OIter>
- _OIter
- set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter);
- template<typename _IIter1, typename _IIter2, typename _OIter,
- typename _Compare>
- _OIter
- set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare);
- template<typename _RAIter>
- void
- sort(_RAIter, _RAIter);
- template<typename _RAIter, typename _Compare>
- void
- sort(_RAIter, _RAIter, _Compare);
- template<typename _RAIter>
- void
- stable_sort(_RAIter, _RAIter);
- template<typename _RAIter, typename _Compare>
- void
- stable_sort(_RAIter, _RAIter, _Compare);
- template<typename _IIter, typename _OIter, typename _UnaryOperation>
- _OIter
- transform(_IIter, _IIter, _OIter, _UnaryOperation);
- template<typename _IIter1, typename _IIter2, typename _OIter,
- typename _BinaryOperation>
- _OIter
- transform(_IIter1, _IIter1, _IIter2, _OIter, _BinaryOperation);
- template<typename _IIter, typename _OIter>
- _OIter
- unique_copy(_IIter, _IIter, _OIter);
- template<typename _IIter, typename _OIter, typename _BinaryPredicate>
- _OIter
- unique_copy(_IIter, _IIter, _OIter, _BinaryPredicate);
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _Tp>
- pair<_Tp*, ptrdiff_t>
- get_temporary_buffer(ptrdiff_t __len)
- {
- const ptrdiff_t __max =
- __gnu_cxx::__numeric_traits<ptrdiff_t>::__max / sizeof(_Tp);
- if (__len > __max)
- __len = __max;
- while (__len > 0)
- {
- _Tp* __tmp = static_cast<_Tp*>(::operator new(__len * sizeof(_Tp),
- std::nothrow));
- if (__tmp != 0)
- return std::pair<_Tp*, ptrdiff_t>(__tmp, __len);
- __len /= 2;
- }
- return std::pair<_Tp*, ptrdiff_t>(static_cast<_Tp*>(0), 0);
- }
- template<typename _Tp>
- inline void
- return_temporary_buffer(_Tp* __p)
- { ::operator delete(__p, std::nothrow); }
- template<typename _ForwardIterator, typename _Tp>
- class _Temporary_buffer
- {
- public:
- typedef _Tp value_type;
- typedef value_type* pointer;
- typedef pointer iterator;
- typedef ptrdiff_t size_type;
- protected:
- size_type _M_original_len;
- size_type _M_len;
- pointer _M_buffer;
- public:
- size_type
- size() const
- { return _M_len; }
- size_type
- requested_size() const
- { return _M_original_len; }
- iterator
- begin()
- { return _M_buffer; }
- iterator
- end()
- { return _M_buffer + _M_len; }
- _Temporary_buffer(_ForwardIterator __first, _ForwardIterator __last);
- ~_Temporary_buffer()
- {
- std::_Destroy(_M_buffer, _M_buffer + _M_len);
- std::return_temporary_buffer(_M_buffer);
- }
- private:
- _Temporary_buffer(const _Temporary_buffer&);
- void
- operator=(const _Temporary_buffer&);
- };
- template<bool>
- struct __uninitialized_construct_buf_dispatch
- {
- template<typename _ForwardIterator, typename _Tp>
- static void
- __ucr(_ForwardIterator __first, _ForwardIterator __last,
- _Tp& __value)
- {
- if(__first == __last)
- return;
- _ForwardIterator __cur = __first;
- try
- {
- std::_Construct(std::__addressof(*__first),
- (__value));
- _ForwardIterator __prev = __cur;
- ++__cur;
- for(; __cur != __last; ++__cur, ++__prev)
- std::_Construct(std::__addressof(*__cur),
- (*__prev));
- __value = (*__prev);
- }
- catch(...)
- {
- std::_Destroy(__first, __cur);
- throw;
- }
- }
- };
- template<>
- struct __uninitialized_construct_buf_dispatch<true>
- {
- template<typename _ForwardIterator, typename _Tp>
- static void
- __ucr(_ForwardIterator, _ForwardIterator, _Tp&) { }
- };
- template<typename _ForwardIterator, typename _Tp>
- inline void
- __uninitialized_construct_buf(_ForwardIterator __first,
- _ForwardIterator __last,
- _Tp& __value)
- {
- typedef typename std::iterator_traits<_ForwardIterator>::value_type
- _ValueType;
- std::__uninitialized_construct_buf_dispatch<
- __has_trivial_constructor(_ValueType)>::
- __ucr(__first, __last, __value);
- }
- template<typename _ForwardIterator, typename _Tp>
- _Temporary_buffer<_ForwardIterator, _Tp>::
- _Temporary_buffer(_ForwardIterator __first, _ForwardIterator __last)
- : _M_original_len(std::distance(__first, __last)),
- _M_len(0), _M_buffer(0)
- {
- try
- {
- std::pair<pointer, size_type> __p(std::get_temporary_buffer<
- value_type>(_M_original_len));
- _M_buffer = __p.first;
- _M_len = __p.second;
- if(_M_buffer)
- std::__uninitialized_construct_buf(_M_buffer, _M_buffer + _M_len,
- *__first);
- }
- catch(...)
- {
- std::return_temporary_buffer(_M_buffer);
- _M_buffer = 0;
- _M_len = 0;
- throw;
- }
- }
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _Iterator>
- void
- __move_median_first(_Iterator __a, _Iterator __b, _Iterator __c)
- {
- if (*__a < *__b)
- {
- if (*__b < *__c)
- std::iter_swap(__a, __b);
- else if (*__a < *__c)
- std::iter_swap(__a, __c);
- }
- else if (*__a < *__c)
- return;
- else if (*__b < *__c)
- std::iter_swap(__a, __c);
- else
- std::iter_swap(__a, __b);
- }
- template<typename _Iterator, typename _Compare>
- void
- __move_median_first(_Iterator __a, _Iterator __b, _Iterator __c,
- _Compare __comp)
- {
- if (__comp(*__a, *__b))
- {
- if (__comp(*__b, *__c))
- std::iter_swap(__a, __b);
- else if (__comp(*__a, *__c))
- std::iter_swap(__a, __c);
- }
- else if (__comp(*__a, *__c))
- return;
- else if (__comp(*__b, *__c))
- std::iter_swap(__a, __c);
- else
- std::iter_swap(__a, __b);
- }
- template<typename _InputIterator, typename _Tp>
- inline _InputIterator
- __find(_InputIterator __first, _InputIterator __last,
- const _Tp& __val, input_iterator_tag)
- {
- while (__first != __last && !(*__first == __val))
- ++__first;
- return __first;
- }
- template<typename _InputIterator, typename _Predicate>
- inline _InputIterator
- __find_if(_InputIterator __first, _InputIterator __last,
- _Predicate __pred, input_iterator_tag)
- {
- while (__first != __last && !bool(__pred(*__first)))
- ++__first;
- return __first;
- }
- template<typename _RandomAccessIterator, typename _Tp>
- _RandomAccessIterator
- __find(_RandomAccessIterator __first, _RandomAccessIterator __last,
- const _Tp& __val, random_access_iterator_tag)
- {
- typename iterator_traits<_RandomAccessIterator>::difference_type
- __trip_count = (__last - __first) >> 2;
- for (; __trip_count > 0; --__trip_count)
- {
- if (*__first == __val)
- return __first;
- ++__first;
- if (*__first == __val)
- return __first;
- ++__first;
- if (*__first == __val)
- return __first;
- ++__first;
- if (*__first == __val)
- return __first;
- ++__first;
- }
- switch (__last - __first)
- {
- case 3:
- if (*__first == __val)
- return __first;
- ++__first;
- case 2:
- if (*__first == __val)
- return __first;
- ++__first;
- case 1:
- if (*__first == __val)
- return __first;
- ++__first;
- case 0:
- default:
- return __last;
- }
- }
- template<typename _RandomAccessIterator, typename _Predicate>
- _RandomAccessIterator
- __find_if(_RandomAccessIterator __first, _RandomAccessIterator __last,
- _Predicate __pred, random_access_iterator_tag)
- {
- typename iterator_traits<_RandomAccessIterator>::difference_type
- __trip_count = (__last - __first) >> 2;
- for (; __trip_count > 0; --__trip_count)
- {
- if (__pred(*__first))
- return __first;
- ++__first;
- if (__pred(*__first))
- return __first;
- ++__first;
- if (__pred(*__first))
- return __first;
- ++__first;
- if (__pred(*__first))
- return __first;
- ++__first;
- }
- switch (__last - __first)
- {
- case 3:
- if (__pred(*__first))
- return __first;
- ++__first;
- case 2:
- if (__pred(*__first))
- return __first;
- ++__first;
- case 1:
- if (__pred(*__first))
- return __first;
- ++__first;
- case 0:
- default:
- return __last;
- }
- }
- template<typename _ForwardIterator, typename _Integer, typename _Tp>
- _ForwardIterator
- __search_n(_ForwardIterator __first, _ForwardIterator __last,
- _Integer __count, const _Tp& __val,
- std::forward_iterator_tag)
- {
- __first = std::find(__first, __last, __val);
- while (__first != __last)
- {
- typename iterator_traits<_ForwardIterator>::difference_type
- __n = __count;
- _ForwardIterator __i = __first;
- ++__i;
- while (__i != __last && __n != 1 && *__i == __val)
- {
- ++__i;
- --__n;
- }
- if (__n == 1)
- return __first;
- if (__i == __last)
- return __last;
- __first = std::find(++__i, __last, __val);
- }
- return __last;
- }
- template<typename _RandomAccessIter, typename _Integer, typename _Tp>
- _RandomAccessIter
- __search_n(_RandomAccessIter __first, _RandomAccessIter __last,
- _Integer __count, const _Tp& __val,
- std::random_access_iterator_tag)
- {
- typedef typename std::iterator_traits<_RandomAccessIter>::difference_type
- _DistanceType;
- _DistanceType __tailSize = __last - __first;
- const _DistanceType __pattSize = __count;
- if (__tailSize < __pattSize)
- return __last;
- const _DistanceType __skipOffset = __pattSize - 1;
- _RandomAccessIter __lookAhead = __first + __skipOffset;
- __tailSize -= __pattSize;
- while (1)
- {
- while (!(*__lookAhead == __val))
- {
- if (__tailSize < __pattSize)
- return __last;
- __lookAhead += __pattSize;
- __tailSize -= __pattSize;
- }
- _DistanceType __remainder = __skipOffset;
- for (_RandomAccessIter __backTrack = __lookAhead - 1;
- *__backTrack == __val; --__backTrack)
- {
- if (--__remainder == 0)
- return (__lookAhead - __skipOffset);
- }
- if (__remainder > __tailSize)
- return __last;
- __lookAhead += __remainder;
- __tailSize -= __remainder;
- }
- }
- template<typename _ForwardIterator, typename _Integer, typename _Tp,
- typename _BinaryPredicate>
- _ForwardIterator
- __search_n(_ForwardIterator __first, _ForwardIterator __last,
- _Integer __count, const _Tp& __val,
- _BinaryPredicate __binary_pred, std::forward_iterator_tag)
- {
- while (__first != __last && !bool(__binary_pred(*__first, __val)))
- ++__first;
- while (__first != __last)
- {
- typename iterator_traits<_ForwardIterator>::difference_type
- __n = __count;
- _ForwardIterator __i = __first;
- ++__i;
- while (__i != __last && __n != 1 && bool(__binary_pred(*__i, __val)))
- {
- ++__i;
- --__n;
- }
- if (__n == 1)
- return __first;
- if (__i == __last)
- return __last;
- __first = ++__i;
- while (__first != __last
- && !bool(__binary_pred(*__first, __val)))
- ++__first;
- }
- return __last;
- }
- template<typename _RandomAccessIter, typename _Integer, typename _Tp,
- typename _BinaryPredicate>
- _RandomAccessIter
- __search_n(_RandomAccessIter __first, _RandomAccessIter __last,
- _Integer __count, const _Tp& __val,
- _BinaryPredicate __binary_pred, std::random_access_iterator_tag)
- {
- typedef typename std::iterator_traits<_RandomAccessIter>::difference_type
- _DistanceType;
- _DistanceType __tailSize = __last - __first;
- const _DistanceType __pattSize = __count;
- if (__tailSize < __pattSize)
- return __last;
- const _DistanceType __skipOffset = __pattSize - 1;
- _RandomAccessIter __lookAhead = __first + __skipOffset;
- __tailSize -= __pattSize;
- while (1)
- {
- while (!bool(__binary_pred(*__lookAhead, __val)))
- {
- if (__tailSize < __pattSize)
- return __last;
- __lookAhead += __pattSize;
- __tailSize -= __pattSize;
- }
- _DistanceType __remainder = __skipOffset;
- for (_RandomAccessIter __backTrack = __lookAhead - 1;
- __binary_pred(*__backTrack, __val); --__backTrack)
- {
- if (--__remainder == 0)
- return (__lookAhead - __skipOffset);
- }
- if (__remainder > __tailSize)
- return __last;
- __lookAhead += __remainder;
- __tailSize -= __remainder;
- }
- }
- template<typename _ForwardIterator1, typename _ForwardIterator2>
- _ForwardIterator1
- __find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
- _ForwardIterator2 __first2, _ForwardIterator2 __last2,
- forward_iterator_tag, forward_iterator_tag)
- {
- if (__first2 == __last2)
- return __last1;
- else
- {
- _ForwardIterator1 __result = __last1;
- while (1)
- {
- _ForwardIterator1 __new_result
- = std::search(__first1, __last1, __first2, __last2);
- if (__new_result == __last1)
- return __result;
- else
- {
- __result = __new_result;
- __first1 = __new_result;
- ++__first1;
- }
- }
- }
- }
- template<typename _ForwardIterator1, typename _ForwardIterator2,
- typename _BinaryPredicate>
- _ForwardIterator1
- __find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
- _ForwardIterator2 __first2, _ForwardIterator2 __last2,
- forward_iterator_tag, forward_iterator_tag,
- _BinaryPredicate __comp)
- {
- if (__first2 == __last2)
- return __last1;
- else
- {
- _ForwardIterator1 __result = __last1;
- while (1)
- {
- _ForwardIterator1 __new_result
- = std::search(__first1, __last1, __first2,
- __last2, __comp);
- if (__new_result == __last1)
- return __result;
- else
- {
- __result = __new_result;
- __first1 = __new_result;
- ++__first1;
- }
- }
- }
- }
- template<typename _BidirectionalIterator1, typename _BidirectionalIterator2>
- _BidirectionalIterator1
- __find_end(_BidirectionalIterator1 __first1,
- _BidirectionalIterator1 __last1,
- _BidirectionalIterator2 __first2,
- _BidirectionalIterator2 __last2,
- bidirectional_iterator_tag, bidirectional_iterator_tag)
- {
- typedef reverse_iterator<_BidirectionalIterator1> _RevIterator1;
- typedef reverse_iterator<_BidirectionalIterator2> _RevIterator2;
- _RevIterator1 __rlast1(__first1);
- _RevIterator2 __rlast2(__first2);
- _RevIterator1 __rresult = std::search(_RevIterator1(__last1),
- __rlast1,
- _RevIterator2(__last2),
- __rlast2);
- if (__rresult == __rlast1)
- return __last1;
- else
- {
- _BidirectionalIterator1 __result = __rresult.base();
- std::advance(__result, -std::distance(__first2, __last2));
- return __result;
- }
- }
- template<typename _BidirectionalIterator1, typename _BidirectionalIterator2,
- typename _BinaryPredicate>
- _BidirectionalIterator1
- __find_end(_BidirectionalIterator1 __first1,
- _BidirectionalIterator1 __last1,
- _BidirectionalIterator2 __first2,
- _BidirectionalIterator2 __last2,
- bidirectional_iterator_tag, bidirectional_iterator_tag,
- _BinaryPredicate __comp)
- {
- typedef reverse_iterator<_BidirectionalIterator1> _RevIterator1;
- typedef reverse_iterator<_BidirectionalIterator2> _RevIterator2;
- _RevIterator1 __rlast1(__first1);
- _RevIterator2 __rlast2(__first2);
- _RevIterator1 __rresult = std::search(_RevIterator1(__last1), __rlast1,
- _RevIterator2(__last2), __rlast2,
- __comp);
- if (__rresult == __rlast1)
- return __last1;
- else
- {
- _BidirectionalIterator1 __result = __rresult.base();
- std::advance(__result, -std::distance(__first2, __last2));
- return __result;
- }
- }
- template<typename _ForwardIterator1, typename _ForwardIterator2>
- inline _ForwardIterator1
- find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
- _ForwardIterator2 __first2, _ForwardIterator2 __last2)
- {
- ;
- ;
- return std::__find_end(__first1, __last1, __first2, __last2,
- std::__iterator_category(__first1),
- std::__iterator_category(__first2));
- }
- template<typename _ForwardIterator1, typename _ForwardIterator2,
- typename _BinaryPredicate>
- inline _ForwardIterator1
- find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
- _ForwardIterator2 __first2, _ForwardIterator2 __last2,
- _BinaryPredicate __comp)
- {
- ;
- ;
- return std::__find_end(__first1, __last1, __first2, __last2,
- std::__iterator_category(__first1),
- std::__iterator_category(__first2),
- __comp);
- }
- template<typename _InputIterator, typename _OutputIterator, typename _Tp>
- _OutputIterator
- remove_copy(_InputIterator __first, _InputIterator __last,
- _OutputIterator __result, const _Tp& __value)
- {
- ;
- for (; __first != __last; ++__first)
- if (!(*__first == __value))
- {
- *__result = *__first;
- ++__result;
- }
- return __result;
- }
- template<typename _InputIterator, typename _OutputIterator,
- typename _Predicate>
- _OutputIterator
- remove_copy_if(_InputIterator __first, _InputIterator __last,
- _OutputIterator __result, _Predicate __pred)
- {
- ;
- for (; __first != __last; ++__first)
- if (!bool(__pred(*__first)))
- {
- *__result = *__first;
- ++__result;
- }
- return __result;
- }
- template<typename _ForwardIterator, typename _Tp>
- _ForwardIterator
- remove(_ForwardIterator __first, _ForwardIterator __last,
- const _Tp& __value)
- {
- ;
- __first = std::find(__first, __last, __value);
- if(__first == __last)
- return __first;
- _ForwardIterator __result = __first;
- ++__first;
- for(; __first != __last; ++__first)
- if(!(*__first == __value))
- {
- *__result = (*__first);
- ++__result;
- }
- return __result;
- }
- template<typename _ForwardIterator, typename _Predicate>
- _ForwardIterator
- remove_if(_ForwardIterator __first, _ForwardIterator __last,
- _Predicate __pred)
- {
- ;
- __first = std::find_if(__first, __last, __pred);
- if(__first == __last)
- return __first;
- _ForwardIterator __result = __first;
- ++__first;
- for(; __first != __last; ++__first)
- if(!bool(__pred(*__first)))
- {
- *__result = (*__first);
- ++__result;
- }
- return __result;
- }
- template<typename _ForwardIterator>
- _ForwardIterator
- unique(_ForwardIterator __first, _ForwardIterator __last)
- {
- ;
- __first = std::adjacent_find(__first, __last);
- if (__first == __last)
- return __last;
- _ForwardIterator __dest = __first;
- ++__first;
- while (++__first != __last)
- if (!(*__dest == *__first))
- *++__dest = (*__first);
- return ++__dest;
- }
- template<typename _ForwardIterator, typename _BinaryPredicate>
- _ForwardIterator
- unique(_ForwardIterator __first, _ForwardIterator __last,
- _BinaryPredicate __binary_pred)
- {
- ;
- __first = std::adjacent_find(__first, __last, __binary_pred);
- if (__first == __last)
- return __last;
- _ForwardIterator __dest = __first;
- ++__first;
- while (++__first != __last)
- if (!bool(__binary_pred(*__dest, *__first)))
- *++__dest = (*__first);
- return ++__dest;
- }
- template<typename _ForwardIterator, typename _OutputIterator>
- _OutputIterator
- __unique_copy(_ForwardIterator __first, _ForwardIterator __last,
- _OutputIterator __result,
- forward_iterator_tag, output_iterator_tag)
- {
- _ForwardIterator __next = __first;
- *__result = *__first;
- while (++__next != __last)
- if (!(*__first == *__next))
- {
- __first = __next;
- *++__result = *__first;
- }
- return ++__result;
- }
- template<typename _InputIterator, typename _OutputIterator>
- _OutputIterator
- __unique_copy(_InputIterator __first, _InputIterator __last,
- _OutputIterator __result,
- input_iterator_tag, output_iterator_tag)
- {
- typename iterator_traits<_InputIterator>::value_type __value = *__first;
- *__result = __value;
- while (++__first != __last)
- if (!(__value == *__first))
- {
- __value = *__first;
- *++__result = __value;
- }
- return ++__result;
- }
- template<typename _InputIterator, typename _ForwardIterator>
- _ForwardIterator
- __unique_copy(_InputIterator __first, _InputIterator __last,
- _ForwardIterator __result,
- input_iterator_tag, forward_iterator_tag)
- {
- *__result = *__first;
- while (++__first != __last)
- if (!(*__result == *__first))
- *++__result = *__first;
- return ++__result;
- }
- template<typename _ForwardIterator, typename _OutputIterator,
- typename _BinaryPredicate>
- _OutputIterator
- __unique_copy(_ForwardIterator __first, _ForwardIterator __last,
- _OutputIterator __result, _BinaryPredicate __binary_pred,
- forward_iterator_tag, output_iterator_tag)
- {
- _ForwardIterator __next = __first;
- *__result = *__first;
- while (++__next != __last)
- if (!bool(__binary_pred(*__first, *__next)))
- {
- __first = __next;
- *++__result = *__first;
- }
- return ++__result;
- }
- template<typename _InputIterator, typename _OutputIterator,
- typename _BinaryPredicate>
- _OutputIterator
- __unique_copy(_InputIterator __first, _InputIterator __last,
- _OutputIterator __result, _BinaryPredicate __binary_pred,
- input_iterator_tag, output_iterator_tag)
- {
- typename iterator_traits<_InputIterator>::value_type __value = *__first;
- *__result = __value;
- while (++__first != __last)
- if (!bool(__binary_pred(__value, *__first)))
- {
- __value = *__first;
- *++__result = __value;
- }
- return ++__result;
- }
- template<typename _InputIterator, typename _ForwardIterator,
- typename _BinaryPredicate>
- _ForwardIterator
- __unique_copy(_InputIterator __first, _InputIterator __last,
- _ForwardIterator __result, _BinaryPredicate __binary_pred,
- input_iterator_tag, forward_iterator_tag)
- {
- *__result = *__first;
- while (++__first != __last)
- if (!bool(__binary_pred(*__result, *__first)))
- *++__result = *__first;
- return ++__result;
- }
- template<typename _BidirectionalIterator>
- void
- __reverse(_BidirectionalIterator __first, _BidirectionalIterator __last,
- bidirectional_iterator_tag)
- {
- while (true)
- if (__first == __last || __first == --__last)
- return;
- else
- {
- std::iter_swap(__first, __last);
- ++__first;
- }
- }
- template<typename _RandomAccessIterator>
- void
- __reverse(_RandomAccessIterator __first, _RandomAccessIterator __last,
- random_access_iterator_tag)
- {
- if (__first == __last)
- return;
- --__last;
- while (__first < __last)
- {
- std::iter_swap(__first, __last);
- ++__first;
- --__last;
- }
- }
- template<typename _BidirectionalIterator>
- inline void
- reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)
- {
- ;
- std::__reverse(__first, __last, std::__iterator_category(__first));
- }
- template<typename _BidirectionalIterator, typename _OutputIterator>
- _OutputIterator
- reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last,
- _OutputIterator __result)
- {
- ;
- while (__first != __last)
- {
- --__last;
- *__result = *__last;
- ++__result;
- }
- return __result;
- }
- template<typename _EuclideanRingElement>
- _EuclideanRingElement
- __gcd(_EuclideanRingElement __m, _EuclideanRingElement __n)
- {
- while (__n != 0)
- {
- _EuclideanRingElement __t = __m % __n;
- __m = __n;
- __n = __t;
- }
- return __m;
- }
- template<typename _ForwardIterator>
- void
- __rotate(_ForwardIterator __first,
- _ForwardIterator __middle,
- _ForwardIterator __last,
- forward_iterator_tag)
- {
- if (__first == __middle || __last == __middle)
- return;
- _ForwardIterator __first2 = __middle;
- do
- {
- std::iter_swap(__first, __first2);
- ++__first;
- ++__first2;
- if (__first == __middle)
- __middle = __first2;
- }
- while (__first2 != __last);
- __first2 = __middle;
- while (__first2 != __last)
- {
- std::iter_swap(__first, __first2);
- ++__first;
- ++__first2;
- if (__first == __middle)
- __middle = __first2;
- else if (__first2 == __last)
- __first2 = __middle;
- }
- }
- template<typename _BidirectionalIterator>
- void
- __rotate(_BidirectionalIterator __first,
- _BidirectionalIterator __middle,
- _BidirectionalIterator __last,
- bidirectional_iterator_tag)
- {
- if (__first == __middle || __last == __middle)
- return;
- std::__reverse(__first, __middle, bidirectional_iterator_tag());
- std::__reverse(__middle, __last, bidirectional_iterator_tag());
- while (__first != __middle && __middle != __last)
- {
- std::iter_swap(__first, --__last);
- ++__first;
- }
- if (__first == __middle)
- std::__reverse(__middle, __last, bidirectional_iterator_tag());
- else
- std::__reverse(__first, __middle, bidirectional_iterator_tag());
- }
- template<typename _RandomAccessIterator>
- void
- __rotate(_RandomAccessIterator __first,
- _RandomAccessIterator __middle,
- _RandomAccessIterator __last,
- random_access_iterator_tag)
- {
- if (__first == __middle || __last == __middle)
- return;
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type
- _Distance;
- typedef typename iterator_traits<_RandomAccessIterator>::value_type
- _ValueType;
- _Distance __n = __last - __first;
- _Distance __k = __middle - __first;
- if (__k == __n - __k)
- {
- std::swap_ranges(__first, __middle, __middle);
- return;
- }
- _RandomAccessIterator __p = __first;
- for (;;)
- {
- if (__k < __n - __k)
- {
- if (__is_pod(_ValueType) && __k == 1)
- {
- _ValueType __t = (*__p);
- std::copy(__p + 1, __p + __n, __p);
- *(__p + __n - 1) = (__t);
- return;
- }
- _RandomAccessIterator __q = __p + __k;
- for (_Distance __i = 0; __i < __n - __k; ++ __i)
- {
- std::iter_swap(__p, __q);
- ++__p;
- ++__q;
- }
- __n %= __k;
- if (__n == 0)
- return;
- std::swap(__n, __k);
- __k = __n - __k;
- }
- else
- {
- __k = __n - __k;
- if (__is_pod(_ValueType) && __k == 1)
- {
- _ValueType __t = (*(__p + __n - 1));
- std::copy_backward(__p, __p + __n - 1, __p + __n);
- *__p = (__t);
- return;
- }
- _RandomAccessIterator __q = __p + __n;
- __p = __q - __k;
- for (_Distance __i = 0; __i < __n - __k; ++ __i)
- {
- --__p;
- --__q;
- std::iter_swap(__p, __q);
- }
- __n %= __k;
- if (__n == 0)
- return;
- std::swap(__n, __k);
- }
- }
- }
- template<typename _ForwardIterator>
- inline void
- rotate(_ForwardIterator __first, _ForwardIterator __middle,
- _ForwardIterator __last)
- {
- ;
- ;
- typedef typename iterator_traits<_ForwardIterator>::iterator_category
- _IterType;
- std::__rotate(__first, __middle, __last, _IterType());
- }
- template<typename _ForwardIterator, typename _OutputIterator>
- _OutputIterator
- rotate_copy(_ForwardIterator __first, _ForwardIterator __middle,
- _ForwardIterator __last, _OutputIterator __result)
- {
- ;
- ;
- return std::copy(__first, __middle,
- std::copy(__middle, __last, __result));
- }
- template<typename _ForwardIterator, typename _Predicate>
- _ForwardIterator
- __partition(_ForwardIterator __first, _ForwardIterator __last,
- _Predicate __pred, forward_iterator_tag)
- {
- if (__first == __last)
- return __first;
- while (__pred(*__first))
- if (++__first == __last)
- return __first;
- _ForwardIterator __next = __first;
- while (++__next != __last)
- if (__pred(*__next))
- {
- std::iter_swap(__first, __next);
- ++__first;
- }
- return __first;
- }
- template<typename _BidirectionalIterator, typename _Predicate>
- _BidirectionalIterator
- __partition(_BidirectionalIterator __first, _BidirectionalIterator __last,
- _Predicate __pred, bidirectional_iterator_tag)
- {
- while (true)
- {
- while (true)
- if (__first == __last)
- return __first;
- else if (__pred(*__first))
- ++__first;
- else
- break;
- --__last;
- while (true)
- if (__first == __last)
- return __first;
- else if (!bool(__pred(*__last)))
- --__last;
- else
- break;
- std::iter_swap(__first, __last);
- ++__first;
- }
- }
- template<typename _ForwardIterator, typename _Predicate, typename _Distance>
- _ForwardIterator
- __inplace_stable_partition(_ForwardIterator __first,
- _ForwardIterator __last,
- _Predicate __pred, _Distance __len)
- {
- if (__len == 1)
- return __pred(*__first) ? __last : __first;
- _ForwardIterator __middle = __first;
- std::advance(__middle, __len / 2);
- _ForwardIterator __begin = std::__inplace_stable_partition(__first,
- __middle,
- __pred,
- __len / 2);
- _ForwardIterator __end = std::__inplace_stable_partition(__middle, __last,
- __pred,
- __len
- - __len / 2);
- std::rotate(__begin, __middle, __end);
- std::advance(__begin, std::distance(__middle, __end));
- return __begin;
- }
- template<typename _ForwardIterator, typename _Pointer, typename _Predicate,
- typename _Distance>
- _ForwardIterator
- __stable_partition_adaptive(_ForwardIterator __first,
- _ForwardIterator __last,
- _Predicate __pred, _Distance __len,
- _Pointer __buffer,
- _Distance __buffer_size)
- {
- if (__len <= __buffer_size)
- {
- _ForwardIterator __result1 = __first;
- _Pointer __result2 = __buffer;
- for (; __first != __last; ++__first)
- if (__pred(*__first))
- {
- *__result1 = (*__first);
- ++__result1;
- }
- else
- {
- *__result2 = (*__first);
- ++__result2;
- }
- std::copy(__buffer, __result2, __result1);
- return __result1;
- }
- else
- {
- _ForwardIterator __middle = __first;
- std::advance(__middle, __len / 2);
- _ForwardIterator __begin =
- std::__stable_partition_adaptive(__first, __middle, __pred,
- __len / 2, __buffer,
- __buffer_size);
- _ForwardIterator __end =
- std::__stable_partition_adaptive(__middle, __last, __pred,
- __len - __len / 2,
- __buffer, __buffer_size);
- std::rotate(__begin, __middle, __end);
- std::advance(__begin, std::distance(__middle, __end));
- return __begin;
- }
- }
- template<typename _ForwardIterator, typename _Predicate>
- _ForwardIterator
- stable_partition(_ForwardIterator __first, _ForwardIterator __last,
- _Predicate __pred)
- {
- ;
- if (__first == __last)
- return __first;
- else
- {
- typedef typename iterator_traits<_ForwardIterator>::value_type
- _ValueType;
- typedef typename iterator_traits<_ForwardIterator>::difference_type
- _DistanceType;
- _Temporary_buffer<_ForwardIterator, _ValueType> __buf(__first,
- __last);
- if (__buf.size() > 0)
- return
- std::__stable_partition_adaptive(__first, __last, __pred,
- _DistanceType(__buf.requested_size()),
- __buf.begin(),
- _DistanceType(__buf.size()));
- else
- return
- std::__inplace_stable_partition(__first, __last, __pred,
- _DistanceType(__buf.requested_size()));
- }
- }
- template<typename _RandomAccessIterator>
- void
- __heap_select(_RandomAccessIterator __first,
- _RandomAccessIterator __middle,
- _RandomAccessIterator __last)
- {
- std::make_heap(__first, __middle);
- for (_RandomAccessIterator __i = __middle; __i < __last; ++__i)
- if (*__i < *__first)
- std::__pop_heap(__first, __middle, __i);
- }
- template<typename _RandomAccessIterator, typename _Compare>
- void
- __heap_select(_RandomAccessIterator __first,
- _RandomAccessIterator __middle,
- _RandomAccessIterator __last, _Compare __comp)
- {
- std::make_heap(__first, __middle, __comp);
- for (_RandomAccessIterator __i = __middle; __i < __last; ++__i)
- if (__comp(*__i, *__first))
- std::__pop_heap(__first, __middle, __i, __comp);
- }
- template<typename _InputIterator, typename _RandomAccessIterator>
- _RandomAccessIterator
- partial_sort_copy(_InputIterator __first, _InputIterator __last,
- _RandomAccessIterator __result_first,
- _RandomAccessIterator __result_last)
- {
- typedef typename iterator_traits<_InputIterator>::value_type
- _InputValueType;
- typedef typename iterator_traits<_RandomAccessIterator>::value_type
- _OutputValueType;
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type
- _DistanceType;
- ;
- ;
- if (__result_first == __result_last)
- return __result_last;
- _RandomAccessIterator __result_real_last = __result_first;
- while(__first != __last && __result_real_last != __result_last)
- {
- *__result_real_last = *__first;
- ++__result_real_last;
- ++__first;
- }
- std::make_heap(__result_first, __result_real_last);
- while (__first != __last)
- {
- if (*__first < *__result_first)
- std::__adjust_heap(__result_first, _DistanceType(0),
- _DistanceType(__result_real_last
- - __result_first),
- _InputValueType(*__first));
- ++__first;
- }
- std::sort_heap(__result_first, __result_real_last);
- return __result_real_last;
- }
- template<typename _InputIterator, typename _RandomAccessIterator, typename _Compare>
- _RandomAccessIterator
- partial_sort_copy(_InputIterator __first, _InputIterator __last,
- _RandomAccessIterator __result_first,
- _RandomAccessIterator __result_last,
- _Compare __comp)
- {
- typedef typename iterator_traits<_InputIterator>::value_type
- _InputValueType;
- typedef typename iterator_traits<_RandomAccessIterator>::value_type
- _OutputValueType;
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type
- _DistanceType;
- ;
- ;
- if (__result_first == __result_last)
- return __result_last;
- _RandomAccessIterator __result_real_last = __result_first;
- while(__first != __last && __result_real_last != __result_last)
- {
- *__result_real_last = *__first;
- ++__result_real_last;
- ++__first;
- }
- std::make_heap(__result_first, __result_real_last, __comp);
- while (__first != __last)
- {
- if (__comp(*__first, *__result_first))
- std::__adjust_heap(__result_first, _DistanceType(0),
- _DistanceType(__result_real_last
- - __result_first),
- _InputValueType(*__first),
- __comp);
- ++__first;
- }
- std::sort_heap(__result_first, __result_real_last, __comp);
- return __result_real_last;
- }
- template<typename _RandomAccessIterator>
- void
- __unguarded_linear_insert(_RandomAccessIterator __last)
- {
- typename iterator_traits<_RandomAccessIterator>::value_type
- __val = (*__last);
- _RandomAccessIterator __next = __last;
- --__next;
- while (__val < *__next)
- {
- *__last = (*__next);
- __last = __next;
- --__next;
- }
- *__last = (__val);
- }
- template<typename _RandomAccessIterator, typename _Compare>
- void
- __unguarded_linear_insert(_RandomAccessIterator __last,
- _Compare __comp)
- {
- typename iterator_traits<_RandomAccessIterator>::value_type
- __val = (*__last);
- _RandomAccessIterator __next = __last;
- --__next;
- while (__comp(__val, *__next))
- {
- *__last = (*__next);
- __last = __next;
- --__next;
- }
- *__last = (__val);
- }
- template<typename _RandomAccessIterator>
- void
- __insertion_sort(_RandomAccessIterator __first,
- _RandomAccessIterator __last)
- {
- if (__first == __last)
- return;
- for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i)
- {
- if (*__i < *__first)
- {
- typename iterator_traits<_RandomAccessIterator>::value_type
- __val = (*__i);
- std::copy_backward(__first, __i, __i + 1);
- *__first = (__val);
- }
- else
- std::__unguarded_linear_insert(__i);
- }
- }
- template<typename _RandomAccessIterator, typename _Compare>
- void
- __insertion_sort(_RandomAccessIterator __first,
- _RandomAccessIterator __last, _Compare __comp)
- {
- if (__first == __last) return;
- for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i)
- {
- if (__comp(*__i, *__first))
- {
- typename iterator_traits<_RandomAccessIterator>::value_type
- __val = (*__i);
- std::copy_backward(__first, __i, __i + 1);
- *__first = (__val);
- }
- else
- std::__unguarded_linear_insert(__i, __comp);
- }
- }
- template<typename _RandomAccessIterator>
- inline void
- __unguarded_insertion_sort(_RandomAccessIterator __first,
- _RandomAccessIterator __last)
- {
- typedef typename iterator_traits<_RandomAccessIterator>::value_type
- _ValueType;
- for (_RandomAccessIterator __i = __first; __i != __last; ++__i)
- std::__unguarded_linear_insert(__i);
- }
- template<typename _RandomAccessIterator, typename _Compare>
- inline void
- __unguarded_insertion_sort(_RandomAccessIterator __first,
- _RandomAccessIterator __last, _Compare __comp)
- {
- typedef typename iterator_traits<_RandomAccessIterator>::value_type
- _ValueType;
- for (_RandomAccessIterator __i = __first; __i != __last; ++__i)
- std::__unguarded_linear_insert(__i, __comp);
- }
- enum { _S_threshold = 16 };
- template<typename _RandomAccessIterator>
- void
- __final_insertion_sort(_RandomAccessIterator __first,
- _RandomAccessIterator __last)
- {
- if (__last - __first > int(_S_threshold))
- {
- std::__insertion_sort(__first, __first + int(_S_threshold));
- std::__unguarded_insertion_sort(__first + int(_S_threshold), __last);
- }
- else
- std::__insertion_sort(__first, __last);
- }
- template<typename _RandomAccessIterator, typename _Compare>
- void
- __final_insertion_sort(_RandomAccessIterator __first,
- _RandomAccessIterator __last, _Compare __comp)
- {
- if (__last - __first > int(_S_threshold))
- {
- std::__insertion_sort(__first, __first + int(_S_threshold), __comp);
- std::__unguarded_insertion_sort(__first + int(_S_threshold), __last,
- __comp);
- }
- else
- std::__insertion_sort(__first, __last, __comp);
- }
- template<typename _RandomAccessIterator, typename _Tp>
- _RandomAccessIterator
- __unguarded_partition(_RandomAccessIterator __first,
- _RandomAccessIterator __last, const _Tp& __pivot)
- {
- while (true)
- {
- while (*__first < __pivot)
- ++__first;
- --__last;
- while (__pivot < *__last)
- --__last;
- if (!(__first < __last))
- return __first;
- std::iter_swap(__first, __last);
- ++__first;
- }
- }
- template<typename _RandomAccessIterator, typename _Tp, typename _Compare>
- _RandomAccessIterator
- __unguarded_partition(_RandomAccessIterator __first,
- _RandomAccessIterator __last,
- const _Tp& __pivot, _Compare __comp)
- {
- while (true)
- {
- while (__comp(*__first, __pivot))
- ++__first;
- --__last;
- while (__comp(__pivot, *__last))
- --__last;
- if (!(__first < __last))
- return __first;
- std::iter_swap(__first, __last);
- ++__first;
- }
- }
- template<typename _RandomAccessIterator>
- inline _RandomAccessIterator
- __unguarded_partition_pivot(_RandomAccessIterator __first,
- _RandomAccessIterator __last)
- {
- _RandomAccessIterator __mid = __first + (__last - __first) / 2;
- std::__move_median_first(__first, __mid, (__last - 1));
- return std::__unguarded_partition(__first + 1, __last, *__first);
- }
- template<typename _RandomAccessIterator, typename _Compare>
- inline _RandomAccessIterator
- __unguarded_partition_pivot(_RandomAccessIterator __first,
- _RandomAccessIterator __last, _Compare __comp)
- {
- _RandomAccessIterator __mid = __first + (__last - __first) / 2;
- std::__move_median_first(__first, __mid, (__last - 1), __comp);
- return std::__unguarded_partition(__first + 1, __last, *__first, __comp);
- }
- template<typename _RandomAccessIterator, typename _Size>
- void
- __introsort_loop(_RandomAccessIterator __first,
- _RandomAccessIterator __last,
- _Size __depth_limit)
- {
- while (__last - __first > int(_S_threshold))
- {
- if (__depth_limit == 0)
- {
- std::partial_sort(__first, __last, __last);
- return;
- }
- --__depth_limit;
- _RandomAccessIterator __cut =
- std::__unguarded_partition_pivot(__first, __last);
- std::__introsort_loop(__cut, __last, __depth_limit);
- __last = __cut;
- }
- }
- template<typename _RandomAccessIterator, typename _Size, typename _Compare>
- void
- __introsort_loop(_RandomAccessIterator __first,
- _RandomAccessIterator __last,
- _Size __depth_limit, _Compare __comp)
- {
- while (__last - __first > int(_S_threshold))
- {
- if (__depth_limit == 0)
- {
- std::partial_sort(__first, __last, __last, __comp);
- return;
- }
- --__depth_limit;
- _RandomAccessIterator __cut =
- std::__unguarded_partition_pivot(__first, __last, __comp);
- std::__introsort_loop(__cut, __last, __depth_limit, __comp);
- __last = __cut;
- }
- }
- template<typename _RandomAccessIterator, typename _Size>
- void
- __introselect(_RandomAccessIterator __first, _RandomAccessIterator __nth,
- _RandomAccessIterator __last, _Size __depth_limit)
- {
- typedef typename iterator_traits<_RandomAccessIterator>::value_type
- _ValueType;
- while (__last - __first > 3)
- {
- if (__depth_limit == 0)
- {
- std::__heap_select(__first, __nth + 1, __last);
- std::iter_swap(__first, __nth);
- return;
- }
- --__depth_limit;
- _RandomAccessIterator __cut =
- std::__unguarded_partition_pivot(__first, __last);
- if (__cut <= __nth)
- __first = __cut;
- else
- __last = __cut;
- }
- std::__insertion_sort(__first, __last);
- }
- template<typename _RandomAccessIterator, typename _Size, typename _Compare>
- void
- __introselect(_RandomAccessIterator __first, _RandomAccessIterator __nth,
- _RandomAccessIterator __last, _Size __depth_limit,
- _Compare __comp)
- {
- typedef typename iterator_traits<_RandomAccessIterator>::value_type
- _ValueType;
- while (__last - __first > 3)
- {
- if (__depth_limit == 0)
- {
- std::__heap_select(__first, __nth + 1, __last, __comp);
- std::iter_swap(__first, __nth);
- return;
- }
- --__depth_limit;
- _RandomAccessIterator __cut =
- std::__unguarded_partition_pivot(__first, __last, __comp);
- if (__cut <= __nth)
- __first = __cut;
- else
- __last = __cut;
- }
- std::__insertion_sort(__first, __last, __comp);
- }
- template<typename _ForwardIterator, typename _Tp, typename _Compare>
- _ForwardIterator
- lower_bound(_ForwardIterator __first, _ForwardIterator __last,
- const _Tp& __val, _Compare __comp)
- {
- typedef typename iterator_traits<_ForwardIterator>::value_type
- _ValueType;
- typedef typename iterator_traits<_ForwardIterator>::difference_type
- _DistanceType;
- ;
- _DistanceType __len = std::distance(__first, __last);
- while (__len > 0)
- {
- _DistanceType __half = __len >> 1;
- _ForwardIterator __middle = __first;
- std::advance(__middle, __half);
- if (__comp(*__middle, __val))
- {
- __first = __middle;
- ++__first;
- __len = __len - __half - 1;
- }
- else
- __len = __half;
- }
- return __first;
- }
- template<typename _ForwardIterator, typename _Tp>
- _ForwardIterator
- upper_bound(_ForwardIterator __first, _ForwardIterator __last,
- const _Tp& __val)
- {
- typedef typename iterator_traits<_ForwardIterator>::value_type
- _ValueType;
- typedef typename iterator_traits<_ForwardIterator>::difference_type
- _DistanceType;
- ;
- _DistanceType __len = std::distance(__first, __last);
- while (__len > 0)
- {
- _DistanceType __half = __len >> 1;
- _ForwardIterator __middle = __first;
- std::advance(__middle, __half);
- if (__val < *__middle)
- __len = __half;
- else
- {
- __first = __middle;
- ++__first;
- __len = __len - __half - 1;
- }
- }
- return __first;
- }
- template<typename _ForwardIterator, typename _Tp, typename _Compare>
- _ForwardIterator
- upper_bound(_ForwardIterator __first, _ForwardIterator __last,
- const _Tp& __val, _Compare __comp)
- {
- typedef typename iterator_traits<_ForwardIterator>::value_type
- _ValueType;
- typedef typename iterator_traits<_ForwardIterator>::difference_type
- _DistanceType;
- ;
- _DistanceType __len = std::distance(__first, __last);
- while (__len > 0)
- {
- _DistanceType __half = __len >> 1;
- _ForwardIterator __middle = __first;
- std::advance(__middle, __half);
- if (__comp(__val, *__middle))
- __len = __half;
- else
- {
- __first = __middle;
- ++__first;
- __len = __len - __half - 1;
- }
- }
- return __first;
- }
- template<typename _ForwardIterator, typename _Tp>
- pair<_ForwardIterator, _ForwardIterator>
- equal_range(_ForwardIterator __first, _ForwardIterator __last,
- const _Tp& __val)
- {
- typedef typename iterator_traits<_ForwardIterator>::value_type
- _ValueType;
- typedef typename iterator_traits<_ForwardIterator>::difference_type
- _DistanceType;
- ;
- ;
- _DistanceType __len = std::distance(__first, __last);
- while (__len > 0)
- {
- _DistanceType __half = __len >> 1;
- _ForwardIterator __middle = __first;
- std::advance(__middle, __half);
- if (*__middle < __val)
- {
- __first = __middle;
- ++__first;
- __len = __len - __half - 1;
- }
- else if (__val < *__middle)
- __len = __half;
- else
- {
- _ForwardIterator __left = std::lower_bound(__first, __middle,
- __val);
- std::advance(__first, __len);
- _ForwardIterator __right = std::upper_bound(++__middle, __first,
- __val);
- return pair<_ForwardIterator, _ForwardIterator>(__left, __right);
- }
- }
- return pair<_ForwardIterator, _ForwardIterator>(__first, __first);
- }
- template<typename _ForwardIterator, typename _Tp, typename _Compare>
- pair<_ForwardIterator, _ForwardIterator>
- equal_range(_ForwardIterator __first, _ForwardIterator __last,
- const _Tp& __val, _Compare __comp)
- {
- typedef typename iterator_traits<_ForwardIterator>::value_type
- _ValueType;
- typedef typename iterator_traits<_ForwardIterator>::difference_type
- _DistanceType;
- ;
- ;
- _DistanceType __len = std::distance(__first, __last);
- while (__len > 0)
- {
- _DistanceType __half = __len >> 1;
- _ForwardIterator __middle = __first;
- std::advance(__middle, __half);
- if (__comp(*__middle, __val))
- {
- __first = __middle;
- ++__first;
- __len = __len - __half - 1;
- }
- else if (__comp(__val, *__middle))
- __len = __half;
- else
- {
- _ForwardIterator __left = std::lower_bound(__first, __middle,
- __val, __comp);
- std::advance(__first, __len);
- _ForwardIterator __right = std::upper_bound(++__middle, __first,
- __val, __comp);
- return pair<_ForwardIterator, _ForwardIterator>(__left, __right);
- }
- }
- return pair<_ForwardIterator, _ForwardIterator>(__first, __first);
- }
- template<typename _ForwardIterator, typename _Tp>
- bool
- binary_search(_ForwardIterator __first, _ForwardIterator __last,
- const _Tp& __val)
- {
- typedef typename iterator_traits<_ForwardIterator>::value_type
- _ValueType;
- ;
- ;
- _ForwardIterator __i = std::lower_bound(__first, __last, __val);
- return __i != __last && !(__val < *__i);
- }
- template<typename _ForwardIterator, typename _Tp, typename _Compare>
- bool
- binary_search(_ForwardIterator __first, _ForwardIterator __last,
- const _Tp& __val, _Compare __comp)
- {
- typedef typename iterator_traits<_ForwardIterator>::value_type
- _ValueType;
- ;
- ;
- _ForwardIterator __i = std::lower_bound(__first, __last, __val, __comp);
- return __i != __last && !bool(__comp(__val, *__i));
- }
- template<typename _BidirectionalIterator1, typename _BidirectionalIterator2,
- typename _BidirectionalIterator3>
- _BidirectionalIterator3
- __move_merge_backward(_BidirectionalIterator1 __first1,
- _BidirectionalIterator1 __last1,
- _BidirectionalIterator2 __first2,
- _BidirectionalIterator2 __last2,
- _BidirectionalIterator3 __result)
- {
- if (__first1 == __last1)
- return std::copy_backward(__first2, __last2, __result);
- if (__first2 == __last2)
- return std::copy_backward(__first1, __last1, __result);
- --__last1;
- --__last2;
- while (true)
- {
- if (*__last2 < *__last1)
- {
- *--__result = (*__last1);
- if (__first1 == __last1)
- return std::copy_backward(__first2, ++__last2, __result);
- --__last1;
- }
- else
- {
- *--__result = (*__last2);
- if (__first2 == __last2)
- return std::copy_backward(__first1, ++__last1, __result);
- --__last2;
- }
- }
- }
- template<typename _BidirectionalIterator1, typename _BidirectionalIterator2,
- typename _BidirectionalIterator3, typename _Compare>
- _BidirectionalIterator3
- __move_merge_backward(_BidirectionalIterator1 __first1,
- _BidirectionalIterator1 __last1,
- _BidirectionalIterator2 __first2,
- _BidirectionalIterator2 __last2,
- _BidirectionalIterator3 __result,
- _Compare __comp)
- {
- if (__first1 == __last1)
- return std::copy_backward(__first2, __last2, __result);
- if (__first2 == __last2)
- return std::copy_backward(__first1, __last1, __result);
- --__last1;
- --__last2;
- while (true)
- {
- if (__comp(*__last2, *__last1))
- {
- *--__result = (*__last1);
- if (__first1 == __last1)
- return std::copy_backward(__first2, ++__last2, __result);
- --__last1;
- }
- else
- {
- *--__result = (*__last2);
- if (__first2 == __last2)
- return std::copy_backward(__first1, ++__last1, __result);
- --__last2;
- }
- }
- }
- template<typename _InputIterator1, typename _InputIterator2,
- typename _OutputIterator>
- _OutputIterator
- __move_merge(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2,
- _OutputIterator __result)
- {
- while (__first1 != __last1 && __first2 != __last2)
- {
- if (*__first2 < *__first1)
- {
- *__result = (*__first2);
- ++__first2;
- }
- else
- {
- *__result = (*__first1);
- ++__first1;
- }
- ++__result;
- }
- return std::copy(__first2, __last2, std::copy(__first1, __last1, __result))
- ;
- }
- template<typename _InputIterator1, typename _InputIterator2,
- typename _OutputIterator, typename _Compare>
- _OutputIterator
- __move_merge(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2,
- _OutputIterator __result, _Compare __comp)
- {
- while (__first1 != __last1 && __first2 != __last2)
- {
- if (__comp(*__first2, *__first1))
- {
- *__result = (*__first2);
- ++__first2;
- }
- else
- {
- *__result = (*__first1);
- ++__first1;
- }
- ++__result;
- }
- return std::copy(__first2, __last2, std::copy(__first1, __last1, __result))
- ;
- }
- template<typename _BidirectionalIterator1, typename _BidirectionalIterator2,
- typename _Distance>
- _BidirectionalIterator1
- __rotate_adaptive(_BidirectionalIterator1 __first,
- _BidirectionalIterator1 __middle,
- _BidirectionalIterator1 __last,
- _Distance __len1, _Distance __len2,
- _BidirectionalIterator2 __buffer,
- _Distance __buffer_size)
- {
- _BidirectionalIterator2 __buffer_end;
- if (__len1 > __len2 && __len2 <= __buffer_size)
- {
- __buffer_end = std::copy(__middle, __last, __buffer);
- std::copy_backward(__first, __middle, __last);
- return std::copy(__buffer, __buffer_end, __first);
- }
- else if (__len1 <= __buffer_size)
- {
- __buffer_end = std::copy(__first, __middle, __buffer);
- std::copy(__middle, __last, __first);
- return std::copy_backward(__buffer, __buffer_end, __last);
- }
- else
- {
- std::rotate(__first, __middle, __last);
- std::advance(__first, std::distance(__middle, __last));
- return __first;
- }
- }
- template<typename _BidirectionalIterator, typename _Distance,
- typename _Pointer>
- void
- __merge_adaptive(_BidirectionalIterator __first,
- _BidirectionalIterator __middle,
- _BidirectionalIterator __last,
- _Distance __len1, _Distance __len2,
- _Pointer __buffer, _Distance __buffer_size)
- {
- if (__len1 <= __len2 && __len1 <= __buffer_size)
- {
- _Pointer __buffer_end = std::copy(__first, __middle, __buffer);
- std::__move_merge(__buffer, __buffer_end, __middle, __last, __first);
- }
- else if (__len2 <= __buffer_size)
- {
- _Pointer __buffer_end = std::copy(__middle, __last, __buffer);
- std::__move_merge_backward(__first, __middle, __buffer,
- __buffer_end, __last);
- }
- else
- {
- _BidirectionalIterator __first_cut = __first;
- _BidirectionalIterator __second_cut = __middle;
- _Distance __len11 = 0;
- _Distance __len22 = 0;
- if (__len1 > __len2)
- {
- __len11 = __len1 / 2;
- std::advance(__first_cut, __len11);
- __second_cut = std::lower_bound(__middle, __last,
- *__first_cut);
- __len22 = std::distance(__middle, __second_cut);
- }
- else
- {
- __len22 = __len2 / 2;
- std::advance(__second_cut, __len22);
- __first_cut = std::upper_bound(__first, __middle,
- *__second_cut);
- __len11 = std::distance(__first, __first_cut);
- }
- _BidirectionalIterator __new_middle =
- std::__rotate_adaptive(__first_cut, __middle, __second_cut,
- __len1 - __len11, __len22, __buffer,
- __buffer_size);
- std::__merge_adaptive(__first, __first_cut, __new_middle, __len11,
- __len22, __buffer, __buffer_size);
- std::__merge_adaptive(__new_middle, __second_cut, __last,
- __len1 - __len11,
- __len2 - __len22, __buffer, __buffer_size);
- }
- }
- template<typename _BidirectionalIterator, typename _Distance,
- typename _Pointer, typename _Compare>
- void
- __merge_adaptive(_BidirectionalIterator __first,
- _BidirectionalIterator __middle,
- _BidirectionalIterator __last,
- _Distance __len1, _Distance __len2,
- _Pointer __buffer, _Distance __buffer_size,
- _Compare __comp)
- {
- if (__len1 <= __len2 && __len1 <= __buffer_size)
- {
- _Pointer __buffer_end = std::copy(__first, __middle, __buffer);
- std::__move_merge(__buffer, __buffer_end, __middle, __last,
- __first, __comp);
- }
- else if (__len2 <= __buffer_size)
- {
- _Pointer __buffer_end = std::copy(__middle, __last, __buffer);
- std::__move_merge_backward(__first, __middle, __buffer, __buffer_end,
- __last, __comp);
- }
- else
- {
- _BidirectionalIterator __first_cut = __first;
- _BidirectionalIterator __second_cut = __middle;
- _Distance __len11 = 0;
- _Distance __len22 = 0;
- if (__len1 > __len2)
- {
- __len11 = __len1 / 2;
- std::advance(__first_cut, __len11);
- __second_cut = std::lower_bound(__middle, __last, *__first_cut,
- __comp);
- __len22 = std::distance(__middle, __second_cut);
- }
- else
- {
- __len22 = __len2 / 2;
- std::advance(__second_cut, __len22);
- __first_cut = std::upper_bound(__first, __middle, *__second_cut,
- __comp);
- __len11 = std::distance(__first, __first_cut);
- }
- _BidirectionalIterator __new_middle =
- std::__rotate_adaptive(__first_cut, __middle, __second_cut,
- __len1 - __len11, __len22, __buffer,
- __buffer_size);
- std::__merge_adaptive(__first, __first_cut, __new_middle, __len11,
- __len22, __buffer, __buffer_size, __comp);
- std::__merge_adaptive(__new_middle, __second_cut, __last,
- __len1 - __len11,
- __len2 - __len22, __buffer,
- __buffer_size, __comp);
- }
- }
- template<typename _BidirectionalIterator, typename _Distance>
- void
- __merge_without_buffer(_BidirectionalIterator __first,
- _BidirectionalIterator __middle,
- _BidirectionalIterator __last,
- _Distance __len1, _Distance __len2)
- {
- if (__len1 == 0 || __len2 == 0)
- return;
- if (__len1 + __len2 == 2)
- {
- if (*__middle < *__first)
- std::iter_swap(__first, __middle);
- return;
- }
- _BidirectionalIterator __first_cut = __first;
- _BidirectionalIterator __second_cut = __middle;
- _Distance __len11 = 0;
- _Distance __len22 = 0;
- if (__len1 > __len2)
- {
- __len11 = __len1 / 2;
- std::advance(__first_cut, __len11);
- __second_cut = std::lower_bound(__middle, __last, *__first_cut);
- __len22 = std::distance(__middle, __second_cut);
- }
- else
- {
- __len22 = __len2 / 2;
- std::advance(__second_cut, __len22);
- __first_cut = std::upper_bound(__first, __middle, *__second_cut);
- __len11 = std::distance(__first, __first_cut);
- }
- std::rotate(__first_cut, __middle, __second_cut);
- _BidirectionalIterator __new_middle = __first_cut;
- std::advance(__new_middle, std::distance(__middle, __second_cut));
- std::__merge_without_buffer(__first, __first_cut, __new_middle,
- __len11, __len22);
- std::__merge_without_buffer(__new_middle, __second_cut, __last,
- __len1 - __len11, __len2 - __len22);
- }
- template<typename _BidirectionalIterator, typename _Distance,
- typename _Compare>
- void
- __merge_without_buffer(_BidirectionalIterator __first,
- _BidirectionalIterator __middle,
- _BidirectionalIterator __last,
- _Distance __len1, _Distance __len2,
- _Compare __comp)
- {
- if (__len1 == 0 || __len2 == 0)
- return;
- if (__len1 + __len2 == 2)
- {
- if (__comp(*__middle, *__first))
- std::iter_swap(__first, __middle);
- return;
- }
- _BidirectionalIterator __first_cut = __first;
- _BidirectionalIterator __second_cut = __middle;
- _Distance __len11 = 0;
- _Distance __len22 = 0;
- if (__len1 > __len2)
- {
- __len11 = __len1 / 2;
- std::advance(__first_cut, __len11);
- __second_cut = std::lower_bound(__middle, __last, *__first_cut,
- __comp);
- __len22 = std::distance(__middle, __second_cut);
- }
- else
- {
- __len22 = __len2 / 2;
- std::advance(__second_cut, __len22);
- __first_cut = std::upper_bound(__first, __middle, *__second_cut,
- __comp);
- __len11 = std::distance(__first, __first_cut);
- }
- std::rotate(__first_cut, __middle, __second_cut);
- _BidirectionalIterator __new_middle = __first_cut;
- std::advance(__new_middle, std::distance(__middle, __second_cut));
- std::__merge_without_buffer(__first, __first_cut, __new_middle,
- __len11, __len22, __comp);
- std::__merge_without_buffer(__new_middle, __second_cut, __last,
- __len1 - __len11, __len2 - __len22, __comp);
- }
- template<typename _BidirectionalIterator>
- void
- inplace_merge(_BidirectionalIterator __first,
- _BidirectionalIterator __middle,
- _BidirectionalIterator __last)
- {
- typedef typename iterator_traits<_BidirectionalIterator>::value_type
- _ValueType;
- typedef typename iterator_traits<_BidirectionalIterator>::difference_type
- _DistanceType;
- ;
- ;
- if (__first == __middle || __middle == __last)
- return;
- _DistanceType __len1 = std::distance(__first, __middle);
- _DistanceType __len2 = std::distance(__middle, __last);
- _Temporary_buffer<_BidirectionalIterator, _ValueType> __buf(__first,
- __last);
- if (__buf.begin() == 0)
- std::__merge_without_buffer(__first, __middle, __last, __len1, __len2);
- else
- std::__merge_adaptive(__first, __middle, __last, __len1, __len2,
- __buf.begin(), _DistanceType(__buf.size()));
- }
- template<typename _BidirectionalIterator, typename _Compare>
- void
- inplace_merge(_BidirectionalIterator __first,
- _BidirectionalIterator __middle,
- _BidirectionalIterator __last,
- _Compare __comp)
- {
- typedef typename iterator_traits<_BidirectionalIterator>::value_type
- _ValueType;
- typedef typename iterator_traits<_BidirectionalIterator>::difference_type
- _DistanceType;
- ;
- ;
- if (__first == __middle || __middle == __last)
- return;
- const _DistanceType __len1 = std::distance(__first, __middle);
- const _DistanceType __len2 = std::distance(__middle, __last);
- _Temporary_buffer<_BidirectionalIterator, _ValueType> __buf(__first,
- __last);
- if (__buf.begin() == 0)
- std::__merge_without_buffer(__first, __middle, __last, __len1,
- __len2, __comp);
- else
- std::__merge_adaptive(__first, __middle, __last, __len1, __len2,
- __buf.begin(), _DistanceType(__buf.size()),
- __comp);
- }
- template<typename _RandomAccessIterator1, typename _RandomAccessIterator2,
- typename _Distance>
- void
- __merge_sort_loop(_RandomAccessIterator1 __first,
- _RandomAccessIterator1 __last,
- _RandomAccessIterator2 __result,
- _Distance __step_size)
- {
- const _Distance __two_step = 2 * __step_size;
- while (__last - __first >= __two_step)
- {
- __result = std::__move_merge(__first, __first + __step_size,
- __first + __step_size,
- __first + __two_step, __result);
- __first += __two_step;
- }
- __step_size = std::min(_Distance(__last - __first), __step_size);
- std::__move_merge(__first, __first + __step_size,
- __first + __step_size, __last, __result);
- }
- template<typename _RandomAccessIterator1, typename _RandomAccessIterator2,
- typename _Distance, typename _Compare>
- void
- __merge_sort_loop(_RandomAccessIterator1 __first,
- _RandomAccessIterator1 __last,
- _RandomAccessIterator2 __result, _Distance __step_size,
- _Compare __comp)
- {
- const _Distance __two_step = 2 * __step_size;
- while (__last - __first >= __two_step)
- {
- __result = std::__move_merge(__first, __first + __step_size,
- __first + __step_size,
- __first + __two_step,
- __result, __comp);
- __first += __two_step;
- }
- __step_size = std::min(_Distance(__last - __first), __step_size);
- std::__move_merge(__first,__first + __step_size,
- __first + __step_size, __last, __result, __comp);
- }
- template<typename _RandomAccessIterator, typename _Distance>
- void
- __chunk_insertion_sort(_RandomAccessIterator __first,
- _RandomAccessIterator __last,
- _Distance __chunk_size)
- {
- while (__last - __first >= __chunk_size)
- {
- std::__insertion_sort(__first, __first + __chunk_size);
- __first += __chunk_size;
- }
- std::__insertion_sort(__first, __last);
- }
- template<typename _RandomAccessIterator, typename _Distance,
- typename _Compare>
- void
- __chunk_insertion_sort(_RandomAccessIterator __first,
- _RandomAccessIterator __last,
- _Distance __chunk_size, _Compare __comp)
- {
- while (__last - __first >= __chunk_size)
- {
- std::__insertion_sort(__first, __first + __chunk_size, __comp);
- __first += __chunk_size;
- }
- std::__insertion_sort(__first, __last, __comp);
- }
- enum { _S_chunk_size = 7 };
- template<typename _RandomAccessIterator, typename _Pointer>
- void
- __merge_sort_with_buffer(_RandomAccessIterator __first,
- _RandomAccessIterator __last,
- _Pointer __buffer)
- {
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type
- _Distance;
- const _Distance __len = __last - __first;
- const _Pointer __buffer_last = __buffer + __len;
- _Distance __step_size = _S_chunk_size;
- std::__chunk_insertion_sort(__first, __last, __step_size);
- while (__step_size < __len)
- {
- std::__merge_sort_loop(__first, __last, __buffer, __step_size);
- __step_size *= 2;
- std::__merge_sort_loop(__buffer, __buffer_last, __first, __step_size);
- __step_size *= 2;
- }
- }
- template<typename _RandomAccessIterator, typename _Pointer, typename _Compare>
- void
- __merge_sort_with_buffer(_RandomAccessIterator __first,
- _RandomAccessIterator __last,
- _Pointer __buffer, _Compare __comp)
- {
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type
- _Distance;
- const _Distance __len = __last - __first;
- const _Pointer __buffer_last = __buffer + __len;
- _Distance __step_size = _S_chunk_size;
- std::__chunk_insertion_sort(__first, __last, __step_size, __comp);
- while (__step_size < __len)
- {
- std::__merge_sort_loop(__first, __last, __buffer,
- __step_size, __comp);
- __step_size *= 2;
- std::__merge_sort_loop(__buffer, __buffer_last, __first,
- __step_size, __comp);
- __step_size *= 2;
- }
- }
- template<typename _RandomAccessIterator, typename _Pointer,
- typename _Distance>
- void
- __stable_sort_adaptive(_RandomAccessIterator __first,
- _RandomAccessIterator __last,
- _Pointer __buffer, _Distance __buffer_size)
- {
- const _Distance __len = (__last - __first + 1) / 2;
- const _RandomAccessIterator __middle = __first + __len;
- if (__len > __buffer_size)
- {
- std::__stable_sort_adaptive(__first, __middle,
- __buffer, __buffer_size);
- std::__stable_sort_adaptive(__middle, __last,
- __buffer, __buffer_size);
- }
- else
- {
- std::__merge_sort_with_buffer(__first, __middle, __buffer);
- std::__merge_sort_with_buffer(__middle, __last, __buffer);
- }
- std::__merge_adaptive(__first, __middle, __last,
- _Distance(__middle - __first),
- _Distance(__last - __middle),
- __buffer, __buffer_size);
- }
- template<typename _RandomAccessIterator, typename _Pointer,
- typename _Distance, typename _Compare>
- void
- __stable_sort_adaptive(_RandomAccessIterator __first,
- _RandomAccessIterator __last,
- _Pointer __buffer, _Distance __buffer_size,
- _Compare __comp)
- {
- const _Distance __len = (__last - __first + 1) / 2;
- const _RandomAccessIterator __middle = __first + __len;
- if (__len > __buffer_size)
- {
- std::__stable_sort_adaptive(__first, __middle, __buffer,
- __buffer_size, __comp);
- std::__stable_sort_adaptive(__middle, __last, __buffer,
- __buffer_size, __comp);
- }
- else
- {
- std::__merge_sort_with_buffer(__first, __middle, __buffer, __comp);
- std::__merge_sort_with_buffer(__middle, __last, __buffer, __comp);
- }
- std::__merge_adaptive(__first, __middle, __last,
- _Distance(__middle - __first),
- _Distance(__last - __middle),
- __buffer, __buffer_size,
- __comp);
- }
- template<typename _RandomAccessIterator>
- void
- __inplace_stable_sort(_RandomAccessIterator __first,
- _RandomAccessIterator __last)
- {
- if (__last - __first < 15)
- {
- std::__insertion_sort(__first, __last);
- return;
- }
- _RandomAccessIterator __middle = __first + (__last - __first) / 2;
- std::__inplace_stable_sort(__first, __middle);
- std::__inplace_stable_sort(__middle, __last);
- std::__merge_without_buffer(__first, __middle, __last,
- __middle - __first,
- __last - __middle);
- }
- template<typename _RandomAccessIterator, typename _Compare>
- void
- __inplace_stable_sort(_RandomAccessIterator __first,
- _RandomAccessIterator __last, _Compare __comp)
- {
- if (__last - __first < 15)
- {
- std::__insertion_sort(__first, __last, __comp);
- return;
- }
- _RandomAccessIterator __middle = __first + (__last - __first) / 2;
- std::__inplace_stable_sort(__first, __middle, __comp);
- std::__inplace_stable_sort(__middle, __last, __comp);
- std::__merge_without_buffer(__first, __middle, __last,
- __middle - __first,
- __last - __middle,
- __comp);
- }
- template<typename _InputIterator1, typename _InputIterator2>
- bool
- includes(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2)
- {
- typedef typename iterator_traits<_InputIterator1>::value_type
- _ValueType1;
- typedef typename iterator_traits<_InputIterator2>::value_type
- _ValueType2;
- ;
- ;
- while (__first1 != __last1 && __first2 != __last2)
- if (*__first2 < *__first1)
- return false;
- else if(*__first1 < *__first2)
- ++__first1;
- else
- ++__first1, ++__first2;
- return __first2 == __last2;
- }
- template<typename _InputIterator1, typename _InputIterator2,
- typename _Compare>
- bool
- includes(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2,
- _Compare __comp)
- {
- typedef typename iterator_traits<_InputIterator1>::value_type
- _ValueType1;
- typedef typename iterator_traits<_InputIterator2>::value_type
- _ValueType2;
- ;
- ;
- while (__first1 != __last1 && __first2 != __last2)
- if (__comp(*__first2, *__first1))
- return false;
- else if(__comp(*__first1, *__first2))
- ++__first1;
- else
- ++__first1, ++__first2;
- return __first2 == __last2;
- }
- template<typename _BidirectionalIterator>
- bool
- next_permutation(_BidirectionalIterator __first,
- _BidirectionalIterator __last)
- {
- ;
- if (__first == __last)
- return false;
- _BidirectionalIterator __i = __first;
- ++__i;
- if (__i == __last)
- return false;
- __i = __last;
- --__i;
- for(;;)
- {
- _BidirectionalIterator __ii = __i;
- --__i;
- if (*__i < *__ii)
- {
- _BidirectionalIterator __j = __last;
- while (!(*__i < *--__j))
- {}
- std::iter_swap(__i, __j);
- std::reverse(__ii, __last);
- return true;
- }
- if (__i == __first)
- {
- std::reverse(__first, __last);
- return false;
- }
- }
- }
- template<typename _BidirectionalIterator, typename _Compare>
- bool
- next_permutation(_BidirectionalIterator __first,
- _BidirectionalIterator __last, _Compare __comp)
- {
- ;
- if (__first == __last)
- return false;
- _BidirectionalIterator __i = __first;
- ++__i;
- if (__i == __last)
- return false;
- __i = __last;
- --__i;
- for(;;)
- {
- _BidirectionalIterator __ii = __i;
- --__i;
- if (__comp(*__i, *__ii))
- {
- _BidirectionalIterator __j = __last;
- while (!bool(__comp(*__i, *--__j)))
- {}
- std::iter_swap(__i, __j);
- std::reverse(__ii, __last);
- return true;
- }
- if (__i == __first)
- {
- std::reverse(__first, __last);
- return false;
- }
- }
- }
- template<typename _BidirectionalIterator>
- bool
- prev_permutation(_BidirectionalIterator __first,
- _BidirectionalIterator __last)
- {
- ;
- if (__first == __last)
- return false;
- _BidirectionalIterator __i = __first;
- ++__i;
- if (__i == __last)
- return false;
- __i = __last;
- --__i;
- for(;;)
- {
- _BidirectionalIterator __ii = __i;
- --__i;
- if (*__ii < *__i)
- {
- _BidirectionalIterator __j = __last;
- while (!(*--__j < *__i))
- {}
- std::iter_swap(__i, __j);
- std::reverse(__ii, __last);
- return true;
- }
- if (__i == __first)
- {
- std::reverse(__first, __last);
- return false;
- }
- }
- }
- template<typename _BidirectionalIterator, typename _Compare>
- bool
- prev_permutation(_BidirectionalIterator __first,
- _BidirectionalIterator __last, _Compare __comp)
- {
- ;
- if (__first == __last)
- return false;
- _BidirectionalIterator __i = __first;
- ++__i;
- if (__i == __last)
- return false;
- __i = __last;
- --__i;
- for(;;)
- {
- _BidirectionalIterator __ii = __i;
- --__i;
- if (__comp(*__ii, *__i))
- {
- _BidirectionalIterator __j = __last;
- while (!bool(__comp(*--__j, *__i)))
- {}
- std::iter_swap(__i, __j);
- std::reverse(__ii, __last);
- return true;
- }
- if (__i == __first)
- {
- std::reverse(__first, __last);
- return false;
- }
- }
- }
- template<typename _InputIterator, typename _OutputIterator, typename _Tp>
- _OutputIterator
- replace_copy(_InputIterator __first, _InputIterator __last,
- _OutputIterator __result,
- const _Tp& __old_value, const _Tp& __new_value)
- {
- ;
- for (; __first != __last; ++__first, ++__result)
- if (*__first == __old_value)
- *__result = __new_value;
- else
- *__result = *__first;
- return __result;
- }
- template<typename _InputIterator, typename _OutputIterator,
- typename _Predicate, typename _Tp>
- _OutputIterator
- replace_copy_if(_InputIterator __first, _InputIterator __last,
- _OutputIterator __result,
- _Predicate __pred, const _Tp& __new_value)
- {
- ;
- for (; __first != __last; ++__first, ++__result)
- if (__pred(*__first))
- *__result = __new_value;
- else
- *__result = *__first;
- return __result;
- }
- template<typename _InputIterator, typename _Function>
- _Function
- for_each(_InputIterator __first, _InputIterator __last, _Function __f)
- {
- ;
- for (; __first != __last; ++__first)
- __f(*__first);
- return (__f);
- }
- template<typename _InputIterator, typename _Tp>
- inline _InputIterator
- find(_InputIterator __first, _InputIterator __last,
- const _Tp& __val)
- {
- ;
- return std::__find(__first, __last, __val,
- std::__iterator_category(__first));
- }
- template<typename _InputIterator, typename _Predicate>
- inline _InputIterator
- find_if(_InputIterator __first, _InputIterator __last,
- _Predicate __pred)
- {
- ;
- return std::__find_if(__first, __last, __pred,
- std::__iterator_category(__first));
- }
- template<typename _InputIterator, typename _ForwardIterator>
- _InputIterator
- find_first_of(_InputIterator __first1, _InputIterator __last1,
- _ForwardIterator __first2, _ForwardIterator __last2)
- {
- ;
- ;
- for (; __first1 != __last1; ++__first1)
- for (_ForwardIterator __iter = __first2; __iter != __last2; ++__iter)
- if (*__first1 == *__iter)
- return __first1;
- return __last1;
- }
- template<typename _InputIterator, typename _ForwardIterator,
- typename _BinaryPredicate>
- _InputIterator
- find_first_of(_InputIterator __first1, _InputIterator __last1,
- _ForwardIterator __first2, _ForwardIterator __last2,
- _BinaryPredicate __comp)
- {
- ;
- ;
- for (; __first1 != __last1; ++__first1)
- for (_ForwardIterator __iter = __first2; __iter != __last2; ++__iter)
- if (__comp(*__first1, *__iter))
- return __first1;
- return __last1;
- }
- template<typename _ForwardIterator>
- _ForwardIterator
- adjacent_find(_ForwardIterator __first, _ForwardIterator __last)
- {
- ;
- if (__first == __last)
- return __last;
- _ForwardIterator __next = __first;
- while(++__next != __last)
- {
- if (*__first == *__next)
- return __first;
- __first = __next;
- }
- return __last;
- }
- template<typename _ForwardIterator, typename _BinaryPredicate>
- _ForwardIterator
- adjacent_find(_ForwardIterator __first, _ForwardIterator __last,
- _BinaryPredicate __binary_pred)
- {
- ;
- if (__first == __last)
- return __last;
- _ForwardIterator __next = __first;
- while(++__next != __last)
- {
- if (__binary_pred(*__first, *__next))
- return __first;
- __first = __next;
- }
- return __last;
- }
- template<typename _InputIterator, typename _Tp>
- typename iterator_traits<_InputIterator>::difference_type
- count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
- {
- ;
- typename iterator_traits<_InputIterator>::difference_type __n = 0;
- for (; __first != __last; ++__first)
- if (*__first == __value)
- ++__n;
- return __n;
- }
- template<typename _InputIterator, typename _Predicate>
- typename iterator_traits<_InputIterator>::difference_type
- count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
- {
- ;
- typename iterator_traits<_InputIterator>::difference_type __n = 0;
- for (; __first != __last; ++__first)
- if (__pred(*__first))
- ++__n;
- return __n;
- }
- template<typename _ForwardIterator1, typename _ForwardIterator2>
- _ForwardIterator1
- search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
- _ForwardIterator2 __first2, _ForwardIterator2 __last2)
- {
- ;
- ;
- if (__first1 == __last1 || __first2 == __last2)
- return __first1;
- _ForwardIterator2 __p1(__first2);
- if (++__p1 == __last2)
- return std::find(__first1, __last1, *__first2);
- _ForwardIterator2 __p;
- _ForwardIterator1 __current = __first1;
- for (;;)
- {
- __first1 = std::find(__first1, __last1, *__first2);
- if (__first1 == __last1)
- return __last1;
- __p = __p1;
- __current = __first1;
- if (++__current == __last1)
- return __last1;
- while (*__current == *__p)
- {
- if (++__p == __last2)
- return __first1;
- if (++__current == __last1)
- return __last1;
- }
- ++__first1;
- }
- return __first1;
- }
- template<typename _ForwardIterator1, typename _ForwardIterator2,
- typename _BinaryPredicate>
- _ForwardIterator1
- search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
- _ForwardIterator2 __first2, _ForwardIterator2 __last2,
- _BinaryPredicate __predicate)
- {
- ;
- ;
- if (__first1 == __last1 || __first2 == __last2)
- return __first1;
- _ForwardIterator2 __p1(__first2);
- if (++__p1 == __last2)
- {
- while (__first1 != __last1
- && !bool(__predicate(*__first1, *__first2)))
- ++__first1;
- return __first1;
- }
- _ForwardIterator2 __p;
- _ForwardIterator1 __current = __first1;
- for (;;)
- {
- while (__first1 != __last1
- && !bool(__predicate(*__first1, *__first2)))
- ++__first1;
- if (__first1 == __last1)
- return __last1;
- __p = __p1;
- __current = __first1;
- if (++__current == __last1)
- return __last1;
- while (__predicate(*__current, *__p))
- {
- if (++__p == __last2)
- return __first1;
- if (++__current == __last1)
- return __last1;
- }
- ++__first1;
- }
- return __first1;
- }
- template<typename _ForwardIterator, typename _Integer, typename _Tp>
- _ForwardIterator
- search_n(_ForwardIterator __first, _ForwardIterator __last,
- _Integer __count, const _Tp& __val)
- {
- ;
- if (__count <= 0)
- return __first;
- if (__count == 1)
- return std::find(__first, __last, __val);
- return std::__search_n(__first, __last, __count, __val,
- std::__iterator_category(__first));
- }
- template<typename _ForwardIterator, typename _Integer, typename _Tp,
- typename _BinaryPredicate>
- _ForwardIterator
- search_n(_ForwardIterator __first, _ForwardIterator __last,
- _Integer __count, const _Tp& __val,
- _BinaryPredicate __binary_pred)
- {
- ;
- if (__count <= 0)
- return __first;
- if (__count == 1)
- {
- while (__first != __last && !bool(__binary_pred(*__first, __val)))
- ++__first;
- return __first;
- }
- return std::__search_n(__first, __last, __count, __val, __binary_pred,
- std::__iterator_category(__first));
- }
- template<typename _InputIterator, typename _OutputIterator,
- typename _UnaryOperation>
- _OutputIterator
- transform(_InputIterator __first, _InputIterator __last,
- _OutputIterator __result, _UnaryOperation __unary_op)
- {
- ;
- for (; __first != __last; ++__first, ++__result)
- *__result = __unary_op(*__first);
- return __result;
- }
- template<typename _InputIterator1, typename _InputIterator2,
- typename _OutputIterator, typename _BinaryOperation>
- _OutputIterator
- transform(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _OutputIterator __result,
- _BinaryOperation __binary_op)
- {
- ;
- for (; __first1 != __last1; ++__first1, ++__first2, ++__result)
- *__result = __binary_op(*__first1, *__first2);
- return __result;
- }
- template<typename _ForwardIterator, typename _Tp>
- void
- replace(_ForwardIterator __first, _ForwardIterator __last,
- const _Tp& __old_value, const _Tp& __new_value)
- {
- ;
- for (; __first != __last; ++__first)
- if (*__first == __old_value)
- *__first = __new_value;
- }
- template<typename _ForwardIterator, typename _Predicate, typename _Tp>
- void
- replace_if(_ForwardIterator __first, _ForwardIterator __last,
- _Predicate __pred, const _Tp& __new_value)
- {
- ;
- for (; __first != __last; ++__first)
- if (__pred(*__first))
- *__first = __new_value;
- }
- template<typename _ForwardIterator, typename _Generator>
- void
- generate(_ForwardIterator __first, _ForwardIterator __last,
- _Generator __gen)
- {
- ;
- for (; __first != __last; ++__first)
- *__first = __gen();
- }
- template<typename _OutputIterator, typename _Size, typename _Generator>
- _OutputIterator
- generate_n(_OutputIterator __first, _Size __n, _Generator __gen)
- {
- for (__decltype(__n + 0) __niter = __n;
- __niter > 0; --__niter, ++__first)
- *__first = __gen();
- return __first;
- }
- template<typename _InputIterator, typename _OutputIterator>
- inline _OutputIterator
- unique_copy(_InputIterator __first, _InputIterator __last,
- _OutputIterator __result)
- {
- ;
- if (__first == __last)
- return __result;
- return std::__unique_copy(__first, __last, __result,
- std::__iterator_category(__first),
- std::__iterator_category(__result));
- }
- template<typename _InputIterator, typename _OutputIterator,
- typename _BinaryPredicate>
- inline _OutputIterator
- unique_copy(_InputIterator __first, _InputIterator __last,
- _OutputIterator __result,
- _BinaryPredicate __binary_pred)
- {
- ;
- if (__first == __last)
- return __result;
- return std::__unique_copy(__first, __last, __result, __binary_pred,
- std::__iterator_category(__first),
- std::__iterator_category(__result));
- }
- template<typename _RandomAccessIterator>
- inline void
- random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
- {
- ;
- if (__first != __last)
- for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i)
- std::iter_swap(__i, __first + (std::rand() % ((__i - __first) + 1)));
- }
- template<typename _RandomAccessIterator, typename _RandomNumberGenerator>
- void
- random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
- _RandomNumberGenerator& __rand)
- {
- ;
- if (__first == __last)
- return;
- for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i)
- std::iter_swap(__i, __first + __rand((__i - __first) + 1));
- }
- template<typename _ForwardIterator, typename _Predicate>
- inline _ForwardIterator
- partition(_ForwardIterator __first, _ForwardIterator __last,
- _Predicate __pred)
- {
- ;
- return std::__partition(__first, __last, __pred,
- std::__iterator_category(__first));
- }
- template<typename _RandomAccessIterator>
- inline void
- partial_sort(_RandomAccessIterator __first,
- _RandomAccessIterator __middle,
- _RandomAccessIterator __last)
- {
- typedef typename iterator_traits<_RandomAccessIterator>::value_type
- _ValueType;
- ;
- ;
- std::__heap_select(__first, __middle, __last);
- std::sort_heap(__first, __middle);
- }
- template<typename _RandomAccessIterator, typename _Compare>
- inline void
- partial_sort(_RandomAccessIterator __first,
- _RandomAccessIterator __middle,
- _RandomAccessIterator __last,
- _Compare __comp)
- {
- typedef typename iterator_traits<_RandomAccessIterator>::value_type
- _ValueType;
- ;
- ;
- std::__heap_select(__first, __middle, __last, __comp);
- std::sort_heap(__first, __middle, __comp);
- }
- template<typename _RandomAccessIterator>
- inline void
- nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth,
- _RandomAccessIterator __last)
- {
- typedef typename iterator_traits<_RandomAccessIterator>::value_type
- _ValueType;
- ;
- ;
- if (__first == __last || __nth == __last)
- return;
- std::__introselect(__first, __nth, __last,
- std::__lg(__last - __first) * 2);
- }
- template<typename _RandomAccessIterator, typename _Compare>
- inline void
- nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth,
- _RandomAccessIterator __last, _Compare __comp)
- {
- typedef typename iterator_traits<_RandomAccessIterator>::value_type
- _ValueType;
- ;
- ;
- if (__first == __last || __nth == __last)
- return;
- std::__introselect(__first, __nth, __last,
- std::__lg(__last - __first) * 2, __comp);
- }
- template<typename _RandomAccessIterator>
- inline void
- sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
- {
- typedef typename iterator_traits<_RandomAccessIterator>::value_type
- _ValueType;
- ;
- if (__first != __last)
- {
- std::__introsort_loop(__first, __last,
- std::__lg(__last - __first) * 2);
- std::__final_insertion_sort(__first, __last);
- }
- }
- template<typename _RandomAccessIterator, typename _Compare>
- inline void
- sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
- _Compare __comp)
- {
- typedef typename iterator_traits<_RandomAccessIterator>::value_type
- _ValueType;
- ;
- if (__first != __last)
- {
- std::__introsort_loop(__first, __last,
- std::__lg(__last - __first) * 2, __comp);
- std::__final_insertion_sort(__first, __last, __comp);
- }
- }
- template<typename _InputIterator1, typename _InputIterator2,
- typename _OutputIterator>
- _OutputIterator
- merge(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2,
- _OutputIterator __result)
- {
- typedef typename iterator_traits<_InputIterator1>::value_type
- _ValueType1;
- typedef typename iterator_traits<_InputIterator2>::value_type
- _ValueType2;
- ;
- ;
- while (__first1 != __last1 && __first2 != __last2)
- {
- if (*__first2 < *__first1)
- {
- *__result = *__first2;
- ++__first2;
- }
- else
- {
- *__result = *__first1;
- ++__first1;
- }
- ++__result;
- }
- return std::copy(__first2, __last2, std::copy(__first1, __last1,
- __result));
- }
- template<typename _InputIterator1, typename _InputIterator2,
- typename _OutputIterator, typename _Compare>
- _OutputIterator
- merge(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2,
- _OutputIterator __result, _Compare __comp)
- {
- typedef typename iterator_traits<_InputIterator1>::value_type
- _ValueType1;
- typedef typename iterator_traits<_InputIterator2>::value_type
- _ValueType2;
- ;
- ;
- while (__first1 != __last1 && __first2 != __last2)
- {
- if (__comp(*__first2, *__first1))
- {
- *__result = *__first2;
- ++__first2;
- }
- else
- {
- *__result = *__first1;
- ++__first1;
- }
- ++__result;
- }
- return std::copy(__first2, __last2, std::copy(__first1, __last1,
- __result));
- }
- template<typename _RandomAccessIterator>
- inline void
- stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
- {
- typedef typename iterator_traits<_RandomAccessIterator>::value_type
- _ValueType;
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type
- _DistanceType;
- ;
- _Temporary_buffer<_RandomAccessIterator, _ValueType> __buf(__first,
- __last);
- if (__buf.begin() == 0)
- std::__inplace_stable_sort(__first, __last);
- else
- std::__stable_sort_adaptive(__first, __last, __buf.begin(),
- _DistanceType(__buf.size()));
- }
- template<typename _RandomAccessIterator, typename _Compare>
- inline void
- stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
- _Compare __comp)
- {
- typedef typename iterator_traits<_RandomAccessIterator>::value_type
- _ValueType;
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type
- _DistanceType;
- ;
- _Temporary_buffer<_RandomAccessIterator, _ValueType> __buf(__first,
- __last);
- if (__buf.begin() == 0)
- std::__inplace_stable_sort(__first, __last, __comp);
- else
- std::__stable_sort_adaptive(__first, __last, __buf.begin(),
- _DistanceType(__buf.size()), __comp);
- }
- template<typename _InputIterator1, typename _InputIterator2,
- typename _OutputIterator>
- _OutputIterator
- set_union(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2,
- _OutputIterator __result)
- {
- typedef typename iterator_traits<_InputIterator1>::value_type
- _ValueType1;
- typedef typename iterator_traits<_InputIterator2>::value_type
- _ValueType2;
- ;
- ;
- while (__first1 != __last1 && __first2 != __last2)
- {
- if (*__first1 < *__first2)
- {
- *__result = *__first1;
- ++__first1;
- }
- else if (*__first2 < *__first1)
- {
- *__result = *__first2;
- ++__first2;
- }
- else
- {
- *__result = *__first1;
- ++__first1;
- ++__first2;
- }
- ++__result;
- }
- return std::copy(__first2, __last2, std::copy(__first1, __last1,
- __result));
- }
- template<typename _InputIterator1, typename _InputIterator2,
- typename _OutputIterator, typename _Compare>
- _OutputIterator
- set_union(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2,
- _OutputIterator __result, _Compare __comp)
- {
- typedef typename iterator_traits<_InputIterator1>::value_type
- _ValueType1;
- typedef typename iterator_traits<_InputIterator2>::value_type
- _ValueType2;
- ;
- ;
- while (__first1 != __last1 && __first2 != __last2)
- {
- if (__comp(*__first1, *__first2))
- {
- *__result = *__first1;
- ++__first1;
- }
- else if (__comp(*__first2, *__first1))
- {
- *__result = *__first2;
- ++__first2;
- }
- else
- {
- *__result = *__first1;
- ++__first1;
- ++__first2;
- }
- ++__result;
- }
- return std::copy(__first2, __last2, std::copy(__first1, __last1,
- __result));
- }
- template<typename _InputIterator1, typename _InputIterator2,
- typename _OutputIterator>
- _OutputIterator
- set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2,
- _OutputIterator __result)
- {
- typedef typename iterator_traits<_InputIterator1>::value_type
- _ValueType1;
- typedef typename iterator_traits<_InputIterator2>::value_type
- _ValueType2;
- ;
- ;
- while (__first1 != __last1 && __first2 != __last2)
- if (*__first1 < *__first2)
- ++__first1;
- else if (*__first2 < *__first1)
- ++__first2;
- else
- {
- *__result = *__first1;
- ++__first1;
- ++__first2;
- ++__result;
- }
- return __result;
- }
- template<typename _InputIterator1, typename _InputIterator2,
- typename _OutputIterator, typename _Compare>
- _OutputIterator
- set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2,
- _OutputIterator __result, _Compare __comp)
- {
- typedef typename iterator_traits<_InputIterator1>::value_type
- _ValueType1;
- typedef typename iterator_traits<_InputIterator2>::value_type
- _ValueType2;
- ;
- ;
- while (__first1 != __last1 && __first2 != __last2)
- if (__comp(*__first1, *__first2))
- ++__first1;
- else if (__comp(*__first2, *__first1))
- ++__first2;
- else
- {
- *__result = *__first1;
- ++__first1;
- ++__first2;
- ++__result;
- }
- return __result;
- }
- template<typename _InputIterator1, typename _InputIterator2,
- typename _OutputIterator>
- _OutputIterator
- set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2,
- _OutputIterator __result)
- {
- typedef typename iterator_traits<_InputIterator1>::value_type
- _ValueType1;
- typedef typename iterator_traits<_InputIterator2>::value_type
- _ValueType2;
- ;
- ;
- while (__first1 != __last1 && __first2 != __last2)
- if (*__first1 < *__first2)
- {
- *__result = *__first1;
- ++__first1;
- ++__result;
- }
- else if (*__first2 < *__first1)
- ++__first2;
- else
- {
- ++__first1;
- ++__first2;
- }
- return std::copy(__first1, __last1, __result);
- }
- template<typename _InputIterator1, typename _InputIterator2,
- typename _OutputIterator, typename _Compare>
- _OutputIterator
- set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2,
- _OutputIterator __result, _Compare __comp)
- {
- typedef typename iterator_traits<_InputIterator1>::value_type
- _ValueType1;
- typedef typename iterator_traits<_InputIterator2>::value_type
- _ValueType2;
- ;
- ;
- while (__first1 != __last1 && __first2 != __last2)
- if (__comp(*__first1, *__first2))
- {
- *__result = *__first1;
- ++__first1;
- ++__result;
- }
- else if (__comp(*__first2, *__first1))
- ++__first2;
- else
- {
- ++__first1;
- ++__first2;
- }
- return std::copy(__first1, __last1, __result);
- }
- template<typename _InputIterator1, typename _InputIterator2,
- typename _OutputIterator>
- _OutputIterator
- set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2,
- _OutputIterator __result)
- {
- typedef typename iterator_traits<_InputIterator1>::value_type
- _ValueType1;
- typedef typename iterator_traits<_InputIterator2>::value_type
- _ValueType2;
- ;
- ;
- while (__first1 != __last1 && __first2 != __last2)
- if (*__first1 < *__first2)
- {
- *__result = *__first1;
- ++__first1;
- ++__result;
- }
- else if (*__first2 < *__first1)
- {
- *__result = *__first2;
- ++__first2;
- ++__result;
- }
- else
- {
- ++__first1;
- ++__first2;
- }
- return std::copy(__first2, __last2, std::copy(__first1,
- __last1, __result));
- }
- template<typename _InputIterator1, typename _InputIterator2,
- typename _OutputIterator, typename _Compare>
- _OutputIterator
- set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2,
- _OutputIterator __result,
- _Compare __comp)
- {
- typedef typename iterator_traits<_InputIterator1>::value_type
- _ValueType1;
- typedef typename iterator_traits<_InputIterator2>::value_type
- _ValueType2;
- ;
- ;
- while (__first1 != __last1 && __first2 != __last2)
- if (__comp(*__first1, *__first2))
- {
- *__result = *__first1;
- ++__first1;
- ++__result;
- }
- else if (__comp(*__first2, *__first1))
- {
- *__result = *__first2;
- ++__first2;
- ++__result;
- }
- else
- {
- ++__first1;
- ++__first2;
- }
- return std::copy(__first2, __last2,
- std::copy(__first1, __last1, __result));
- }
- template<typename _ForwardIterator>
- _ForwardIterator
- min_element(_ForwardIterator __first, _ForwardIterator __last)
- {
- ;
- if (__first == __last)
- return __first;
- _ForwardIterator __result = __first;
- while (++__first != __last)
- if (*__first < *__result)
- __result = __first;
- return __result;
- }
- template<typename _ForwardIterator, typename _Compare>
- _ForwardIterator
- min_element(_ForwardIterator __first, _ForwardIterator __last,
- _Compare __comp)
- {
- ;
- if (__first == __last)
- return __first;
- _ForwardIterator __result = __first;
- while (++__first != __last)
- if (__comp(*__first, *__result))
- __result = __first;
- return __result;
- }
- template<typename _ForwardIterator>
- _ForwardIterator
- max_element(_ForwardIterator __first, _ForwardIterator __last)
- {
- ;
- if (__first == __last)
- return __first;
- _ForwardIterator __result = __first;
- while (++__first != __last)
- if (*__result < *__first)
- __result = __first;
- return __result;
- }
- template<typename _ForwardIterator, typename _Compare>
- _ForwardIterator
- max_element(_ForwardIterator __first, _ForwardIterator __last,
- _Compare __comp)
- {
- ;
- if (__first == __last) return __first;
- _ForwardIterator __result = __first;
- while (++__first != __last)
- if (__comp(*__result, *__first))
- __result = __first;
- return __result;
- }
-}
-extern bool showCPU;
-extern "C" {
-struct timezone
- {
- int tz_minuteswest;
- int tz_dsttime;
- };
-typedef struct timezone *__restrict __timezone_ptr_t;
-extern int gettimeofday (struct timeval *__restrict __tv,
- __timezone_ptr_t __tz) throw () __attribute__ ((__nonnull__ (1)));
-extern int settimeofday (__const struct timeval *__tv,
- __const struct timezone *__tz)
- throw () __attribute__ ((__nonnull__ (1)));
-extern int adjtime (__const struct timeval *__delta,
- struct timeval *__olddelta) throw ();
-enum __itimer_which
- {
- ITIMER_REAL = 0,
- ITIMER_VIRTUAL = 1,
- ITIMER_PROF = 2
- };
-struct itimerval
- {
- struct timeval it_interval;
- struct timeval it_value;
- };
-typedef int __itimer_which_t;
-extern int getitimer (__itimer_which_t __which,
- struct itimerval *__value) throw ();
-extern int setitimer (__itimer_which_t __which,
- __const struct itimerval *__restrict __new,
- struct itimerval *__restrict __old) throw ();
-extern int utimes (__const char *__file, __const struct timeval __tvp[2])
- throw () __attribute__ ((__nonnull__ (1)));
-extern int lutimes (__const char *__file, __const struct timeval __tvp[2])
- throw () __attribute__ ((__nonnull__ (1)));
-extern int futimes (int __fd, __const struct timeval __tvp[2]) throw ();
-extern int futimesat (int __fd, __const char *__file,
- __const struct timeval __tvp[2]) throw ();
-}
-class CodeAlloc { public:
- static size_t nb,nbt,lg, nbdl,nbpx, chunk ;
- static CodeAlloc ** mem;
- static bool cleanning;
- static void * lgmax;
- static bool sort;
- static bool isdel(int i)
- {
- return ((char *) (void *) mem[i] - (char *) 0) % 2 == 1;
- }
- static void setdel(int i)
- {
- mem[i] = (CodeAlloc *) (void *) (((char *) mem[i] - (char *) 0)+ 1);
- }
- static void resize();
- static void * Add2CleanAtEnd(void * p)
- {
- if(p) {
- if(nbt>=nbpx) resize();
- if(nbt>0) sort = sort && mem[nbt-1] < p;
- nb++;
- mem[nbt++]=(CodeAlloc*)p; }
- return p;
- }
- void *operator new(size_t ll ) {
- lg+=ll;
- return Add2CleanAtEnd(::operator new(ll));}
- static void Sort_mem();
- static void clear();
- static void ErrorDel(void *pp);
- void operator delete(void * pp);
- virtual ~CodeAlloc() {}
-};
-template<class T> class CodeAllocT: public CodeAlloc{
- T * p;
- public:
- CodeAllocT(int n): p(new T[n]) { (static_cast<void> (0));}
- static T * New(int n) { return (new CodeAllocT(n))->p;}
- ~CodeAllocT(){ delete [] p;}
-};
-inline double CPUtime(){
- return ((double) clock())/1000000l;
-}
-extern long verbosity;
-extern long searchMethod;
-extern bool withrgraphique;
-using namespace std;
-const int MeshPointStackOffset =0;
-const int ParamPtrOffset = 1;
-const int ElemMatPtrOffset = 2;
-const int ExprPtrs = 4;
-const int NbPtrs = 5;
-const int BeginOffset = 6;
-typedef void *Stack;
- const Stack NullStack=0;
-template<class T>
-T * Stack_offset (Stack stack,size_t offset)
-{
- return (T *) (void *) (((char *) stack)+offset);}
-template<class T>
-T * & Stack_Ptr (Stack stack,size_t offset)
- {return (T * &) (((void **) stack)[offset]);}
-void ShowType(ostream & f);
-struct VOIDPtrType {
- virtual ~VOIDPtrType();
-};
-template<class T>
-struct PtrType: public VOIDPtrType {
- T * p;
- PtrType(T* pp):p(pp) {}
- ~PtrType() {delete p;}
-};
-template<class T>
-struct PtrArrayType: public VOIDPtrType {
- T * p;
- PtrArrayType(T* pp):p(pp) {}
- PtrArrayType() {delete [] p;}
-};
- struct BaseNewInStack {
- virtual ~BaseNewInStack() {};
-};
- struct BaseNewInStack ;
- struct StackOfPtr2Free;
-inline StackOfPtr2Free * & WhereStackOfPtr2Free(Stack s) { return Stack_Ptr<StackOfPtr2Free>(s,ExprPtrs) ;}
-struct StackOfPtr2Free {
- typedef vector<BaseNewInStack *>::iterator iterator;
- StackOfPtr2Free ** where;
- StackOfPtr2Free *prev;
- vector<BaseNewInStack *> stackptr;
- static const int sizeofmemory4tmp=1024;
- int topmemory4tmp;
- char *memory4tmp ;
- void add(BaseNewInStack *p) {
- stackptr.push_back(p);}
-public:
- StackOfPtr2Free(Stack s):
- where(&WhereStackOfPtr2Free(s)),
- prev(*where),
- topmemory4tmp(0),
- memory4tmp(new char[sizeofmemory4tmp])
- {
- stackptr.reserve(20);
- if(prev) Add2StackOfPtr2Free(s,this);
- }
- bool clean()
- { bool ret= !stackptr.empty();
- if(ret)
- {
- topmemory4tmp=0;
- if(stackptr.size()>=20 && verbosity>2)
- cout << "\n\t\t ### big?? ptr/lg clean " << stackptr.size() << " ptr's\n ";
- for (iterator i=stackptr.end(); i != stackptr.begin();)
- {
- delete (* (--i) );
- }
- stackptr.resize(0);
- }
- return ret;
- }
- void * alloc(int lg)
- {
- int lg8=lg%8;
- if(lg8) lg += 8-lg8;
- if(topmemory4tmp + lg>= sizeofmemory4tmp) {((0) ? ( (void) 0) : throw(ErrorAssert("0","ffstack.hpp", 223)));}
- void * p=static_cast<void*> (memory4tmp+topmemory4tmp);
- topmemory4tmp+= lg;
- return p;
- }
- ~StackOfPtr2Free() {clean();delete [] memory4tmp; *where=prev;}
-private:
- StackOfPtr2Free(const StackOfPtr2Free&);
- void operator =(const StackOfPtr2Free&);
- template<class T>
- friend T * NewTmp(Stack s);
- template<class T>
- friend T * Add2StackOfPtr2Free(Stack s,T * p);
-};
-inline void * NewAllocTmp(Stack s,size_t l)
-{
- return WhereStackOfPtr2Free(s)->alloc(l);
-}
-template<class T>
-struct NewInStack: public BaseNewInStack {
- T * p;
- bool array;
- ~NewInStack() {
- if(p)
- delete p;}
-private:
- NewInStack(T * pp,bool aa=false) : p(pp),array(aa) {
- }
- template<class TT>
- friend TT * Add2StackOfPtr2FreeA(Stack s,TT * p);
- template<class TT>
- friend TT * Add2StackOfPtr2Free(Stack s,TT * p);
-};
-template<class T>
-struct NewRefCountInStack: public BaseNewInStack {
- T * p;
- bool array;
- ~NewRefCountInStack() {
- if(p) p->destroy();}
-private:
- NewRefCountInStack(T * pp,bool aa=false) : p(pp),array(aa) {
- }
- template<class TT>
- friend TT * Add2StackOfPtr2FreeRC(Stack s,TT * p);
-};
-template<class T>
-struct NewArrayInStack: public BaseNewInStack {
- T * p;
- bool array;
- ~NewArrayInStack() {
- if(p) delete [] p;
- }
-private:
- NewArrayInStack(T * pp,bool aa=false) : p(pp),array(aa) {
- }
- template<class TT>
- friend TT * Add2StackOfPtr2FreeA(Stack s,TT * p);
- template<class TT>
- friend TT * Add2StackOfPtr2Free(Stack s,TT * p);
-};
-template<class T>
-T * Add2StackOfPtr2FreeRC(Stack s,T * p)
-{
- if(p)
- WhereStackOfPtr2Free(s)->add(new NewRefCountInStack<T>(p));
- return p;
-}
-template<class T>
-T * Add2StackOfPtr2Free(Stack s,T * p)
-{
- if(p)
- WhereStackOfPtr2Free(s)->add(new NewInStack<T>(p));
- return p;
-}
-template<class T>
-T * Add2StackOfPtr2FreeA(Stack s,T * p)
-{
- if(p)
- WhereStackOfPtr2Free(s)->add(new NewArrayInStack<T>(p));
- return p;
-}
-inline Stack newStack(size_t l)
- {
- char * mps;
- Stack thestack = new char[l];
- for (size_t i = 0;i< l/sizeof(long);i++) ((long*) thestack)[i]=0;
- ((char **) thestack)[MeshPointStackOffset] = mps = new char [1000];
- for(int i=0;i<1000;++i) mps[i]=0;
- WhereStackOfPtr2Free(thestack)=new StackOfPtr2Free(thestack);
- return thestack;
-}
-inline void deleteStack(Stack s)
- {
- delete WhereStackOfPtr2Free(s);
- delete [] (((char **) s)[MeshPointStackOffset]);
- delete [] (char *) s;
- }
-class basicForEachType;
-typedef const basicForEachType * aType;
-ostream & operator<<(ostream & f,const basicForEachType & e);
-typedef unsigned char AnyData[2*(5*sizeof(void*))];
-extern map<const string,basicForEachType *> map_type;
-template <class T,bool ok>
- class CheckSize { } ;
-template <class T>
-class CheckSize<T,false> {
- CheckSize() { }
-} ;
-class AnyTypeWithCheck {
- private:
- union {
- AnyData data;
- void * p;
- double r;
- long l;
- bool b;
- };
- public:
- const basicForEachType *ktype;
- AnyTypeWithCheck(): ktype(0){}
- AnyTypeWithCheck(long ll) {l=ll;ktype=map_type[typeid(long).name()];}
- AnyTypeWithCheck(double dd) {r=dd;ktype=map_type[typeid(double).name()];}
- AnyTypeWithCheck(bool bb ) {b=bb;ktype=map_type[typeid(bool).name()];}
- void operator =(void *pp){p=pp;}
-};
-class AnyTypeWithOutCheck {
- public:
- union {
- AnyData data;
- void * p;
- double r;
- long l;
- bool b;
- };
- public:
- AnyTypeWithOutCheck(){}
- AnyTypeWithOutCheck(long ll) {l=ll;}
- AnyTypeWithOutCheck(double dd) {r=dd;}
- AnyTypeWithOutCheck(void *pp ) {p=pp;}
- AnyTypeWithOutCheck(bool bb ) {b=bb;}
- void operator =(void *pp){p=pp;}
-};
-typedef AnyTypeWithOutCheck AnyType;
-static AnyType Nothing;
- template<typename T> AnyTypeWithOutCheck inline SetAny(const T & x)
- {
- AnyTypeWithOutCheck any;
- CheckSize<T,sizeof(T)<= sizeof(AnyData) >();
- memcpy(&any,&x,sizeof(x));
- return any;
- }
-inline AnyTypeWithOutCheck PtrtoAny(void * p,aType )
- {
- return p;
- }
- template<> inline AnyTypeWithOutCheck SetAny<double>(const double & x)
- { return x;}
- template<> inline AnyTypeWithOutCheck SetAny<long>(const long & x)
- { return x;}
- template<> inline AnyTypeWithOutCheck SetAny<bool>(const bool & x)
- { return x;}
- template<typename T> inline AnyTypeWithOutCheck SetAny( T * x)
- { return reinterpret_cast<void *>( x);}
- template<typename T> inline AnyTypeWithOutCheck SetAny( const T * x)
- { return reinterpret_cast<void *>( x);}
- template<class T> inline const T& GetAny(const AnyTypeWithCheck & x);
- template<class T> inline const T& GetAny(const AnyTypeWithCheck & x)
-{
- CheckSize<T,sizeof(T)<= sizeof(AnyData) >();
- if (x.ktype!=map_type[typeid(T).name()])
- { cout<< "GetAny: PB type <";
- cout <<typeid(T).name();
- cout << "> <=" << *(x.ktype) << endl;
- throw(ErrorExec("exit",1));}
- return *static_cast<const T*>(static_cast<const void*>(&x));
-}
- template<typename T> inline const T& GetAny(const AnyTypeWithOutCheck & x)
-{
- CheckSize<T,sizeof(T)<= sizeof(AnyData) >();
- return *static_cast<const T*>(static_cast<const void*>(&x));
-}
- template<> inline const double& GetAny<double>(const AnyTypeWithOutCheck & x)
- { return x.r;}
- template<> inline const long& GetAny<long>(const AnyTypeWithOutCheck & x)
- { return x.l;}
- template<> inline const bool& GetAny<bool>(const AnyTypeWithOutCheck & x)
- { return x.b;}
- template<class T> inline T * PGetAny(const AnyTypeWithOutCheck & x)
- { return static_cast< T*>(x.p);}
-inline string * toString(const double& a)
-{
- char buf[30];
- sprintf(buf,"%g",a);
- return new string(buf);
-}
-inline string * toString(const long& a)
-{
- char buf[30];
- sprintf(buf,"%ld",a);
- return new string(buf);
-}
-inline string * toString(const bool& a)
-{
- return new string(a?"T":"F");
-}
-inline string * toString(const complex<double> & a)
-{
- char buf[60];
- sprintf(buf,"%g%+gi",a.real(),a.imag());
- return new string(buf);
-}
-inline string * toStringCconst(const char * const &a)
-{ return new string(a);
-}
-inline string * toStringC( char * const &a)
-{ return new string(a);
-}
-template<class T>
-string * PtoString(const T * a)
-{ ostringstream r;
- r << *a ;
- return new string(r.str());
-}
-template<class T>
-AnyType PtoStringA(void *, const AnyType &a)
-{
- ostringstream r;
- r << *GetAny<T*>(a) ;
- return SetAny<string *>(new string(r.str()));
-}
-template<class T>
-AnyType toStringA(void *, const AnyType &a)
-{
- ostringstream r;
- r << GetAny<T>(a) ;
- return SetAny<string *>(new string(r.str()));
-}
-class String {
- string * p;
- public:
- String() : p(new string()) { }
- void init() { p= new string();}
-void destroy() { delete p;p=0;}
- String(const String & c) : p(new string(c)) { }
- String(const string & c) : p(new string(c)) { }
- String(const char * c) : p(new string(c)) { }
- String(const long & c) : p(toString(c)){ }
- String(const double & c) : p(toString(c)){ }
- String(const bool & c) : p(toString(c)){ }
- String(const long * c) : p(PtoString(c)){ }
- String(const double * c) : p(PtoString(c)){ }
- String & operator=(const String & s){delete p;p=new string(s);return *this;}
- String operator+(const String & s)const {return String(new string(*p+*s.p));}
- ~String(){ delete p; p=0;}
- operator const string & () const {return *p;}
- operator string & () {return *p;}
- string ** getap() {return &p;}
- friend inline ostream & operator<<(ostream & f,const String & s) {( (void) 0); f << *s.p ; return f;}
- bool operator<(const String &t) const {(static_cast<void> (0));return *p<*t.p;}
- bool operator>(const String &t) const {(static_cast<void> (0));return *p>*t.p;}
-};
-template<class K,class V>
-class MyMap {
- public:
- map<K,V> *m;
- MyMap() : m(new map<K,V>) { }
- MyMap &operator=(MyMap &M){
- delete m;m=new map<K,V>(M);
- }
- V &operator[](const K & k) {
- ( (void) 0);
- typename map<K,V>::iterator i=m->find(k);
- typedef typename map<K,V>::value_type value_type;
- if (i==m->end())
- i=m->insert(value_type(k,V())).first;
- V & v= i->second ;
- return v;
-}
- ~MyMap(){delete m; m=0;}
- private:
- MyMap(const MyMap &M):m(new map<K,V>(*M.m)) {}
-};
-template<class A,class B>
-struct pairless : binary_function<pair<A,B>,const char *, bool>
- {
- typedef pair<A,B> Key;
- bool operator()(const Key& x, const Key& y) const { return x.first<y.first ? true
- : ( (x.first == y.first) ? (x.second < y.second) : false );} };
-typedef map<pair<aType,aType>,aType,pairless<aType,aType> > Map_type_of_map;
-extern Map_type_of_map map_type_of_map ;
-class basicForEachType;
-class E_F1_funcT_Type;
-class E_F0;
-class C_F0;
-class ListOfInst;
-class Polymorphic;
-class OneOperator;
-typedef E_F0 * Expression;
-class AC_F0;
-class basicAC_F0;
-typedef complex<double> Complex;
-typedef pair<aType, E_F0 *> Type_Expr ;
- int FindType(const char * name) ;
- void lgerror (const char* s) ;
- void CompileError(string msg="",aType r=0);
- void ExecError(string msg="");
-struct UnId {
- const char * id;
- aType r;
- Expression e;
- deque<UnId> * array;
- aType re;
- bool ref;
- UnId() :id(0),r(0),e(0),array(0),re(0),ref(false) {}
- UnId(const char * idd) :id(idd),r(0),e(0),array(0),re(0),ref(false) {}
- UnId(const char * idd,const C_F0 & ee,aType rr,bool reff) ;
- UnId(deque<UnId> * d) : id(0),r(0),e(0),array(d?new deque<UnId>(*d):0),re(0),ref(false) {}
- UnId(const UnId & u) :
- id(u.id),r(u.r),e(u.e),
- array(u.array?new deque<UnId>(*u.array):0),
- re(u.re),ref(u.ref) {}
- void operator= (const UnId & u) {
- id=u.id;
- r=u.r;
- e=u.e;
- re=u.re;
- ref=u.ref;
- if(array) delete array;
- array=0;
- if(u.array) array= new deque<UnId>(*u.array);
- }
- ~UnId(){ if( array) delete array;}
-};
-typedef deque<UnId> ListOfId;
-extern Polymorphic * TheOperators, * TheRightOperators;
-extern C_F0 *pOne,*pZero,*pminusOne;
-typedef AnyType (* Function1)(Stack, const AnyType &);
-typedef AnyType (* Function2)(Stack, const AnyType &,const AnyType &);
-typedef AnyType (* CFunction2)(Stack, E_F0 *, E_F0 *);
-typedef AnyType (* CFunction4)(Stack, E_F0 *, E_F0 *, E_F0 *, E_F0 *);
-Expression NewExpression(Function1,Expression);
-Expression NewExpression(Function2,Expression,Expression);
-inline Type_Expr make_Type_Expr(aType t, E_F0 * e) {return make_pair(t,e);}
-inline Type_Expr make_Type_Expr( E_F0 * e,aType t) {return make_pair(t,e);}
-struct Keyless : binary_function<const char *,const char *, bool>
- {
- typedef const char * Key;
- bool operator()(const Key& x, const Key& y) const { return strcmp(x,y)<0;} };
-class TableOfIdentifier: public CodeAlloc {
- public:
- struct Value;
- typedef const char * Key;
- typedef map<Key,Value,Keyless> maptype;
- typedef pair<const Key,Value> pKV;
- typedef maptype::iterator iterator;
- typedef maptype::const_iterator const_iterator;
- struct Value :public Type_Expr {
- pKV * next;
- bool del;
- Value(const Type_Expr & vv,pKV * n,bool dd=true) : Type_Expr(vv),next(n),del(dd) {}
- Value(aType t,E_F0 *f,pKV *n,bool dd=true): Type_Expr(t,f),next(n),del(dd) {}
- };
- pKV * listofvar;
- maptype m;
- C_F0 Find(Key) const ;
- C_F0 Find(Key,const basicAC_F0 &) const ;
- const Type_Expr & New(Key k,const Type_Expr & v,bool del=true);
- void Add(Key k,Key op,OneOperator *p0,OneOperator *p1=0,
- OneOperator *p2=0,OneOperator *p3=0,OneOperator *p4=0,
- OneOperator *p5=0,OneOperator *p6=0) ;
- void clear();
-template<class T>
- C_F0 NewVar(Key k,aType t,size_t & top,const C_F0 &i) ;
-template<class T>
- C_F0 NewVar(Key k,aType t,size_t & top,const basicAC_F0 &args) ;
-template<class T,class U>
- C_F0 NewVar(Key k,aType t,size_t & top,const basicAC_F0 &args,const U & data) ;
-template<class T>
- C_F0 NewVar(Key k,aType t,size_t & top) ;
- C_F0 NewID(aType t,Key k, C_F0 & c,size_t & top,bool del=true);
- C_F0 NewID(aType t,Key k, C_F0 & c,const ListOfId & l,size_t & top,bool del=true);
-template<class T>
- C_F0 NewFESpace(Key k,aType t,size_t & top,const basicAC_F0 &args);
- friend ostream & operator<<(ostream & f,const TableOfIdentifier & );
- C_F0 destroy();
- TableOfIdentifier() ;
- ~TableOfIdentifier();
-};
-class basicForEachType : public CodeAlloc {
- const type_info * ktype;
- public:
- const size_t size;
- typedef OneOperator * CastFunc;
- typedef map<aType,CastFunc>::const_iterator const_cast_iterator;
- typedef const char * Key;
- friend ostream & operator<<(ostream & f,const basicForEachType & e)
- { f << '<' << e.name() << '>' ;return f;}
- void Show(ostream & f) const ;
- const char * name() const { return this ? ktype->name() :"NULL" ;}
- virtual bool CastingFrom(const basicForEachType * t) const ;
- virtual bool SametypeRight(const basicForEachType * t) const {return this == t || t == un_ptr_type;}
- virtual int TYPEOFID() const {return 0;}
- virtual C_F0 CastTo(const C_F0 & e) const ;
- virtual void SetArgs(const ListOfId *lid) const ;
- aType right() const {return un_ptr_type;};
- Expression RightValueExpr(Expression f) const;
- virtual C_F0 Initialization(const Type_Expr & e) const ;
- virtual Expression Destroy(const C_F0 &) const ;
- virtual bool ExistDestroy() const {return destroy;}
- virtual Type_Expr SetParam(const C_F0 & c,const ListOfId * l,size_t & top) const;
- virtual Expression OnReturn(Expression f) const;
- protected:
- basicForEachType(const type_info & k ,const size_t ,
- const E_F1_funcT_Type * p=0,basicForEachType *rr=0,
- Function1 iv=0,Function1 id=0, Function1 dreturn=0) ;
-public:
- const basicForEachType * un_ptr_type;
- private:
- OneOperator * casting;
- const E_F1_funcT_Type * un_ptr;
- Function1 DoOnReturn;
- Function1 InitExp;
- Function1 destroy;
- TableOfIdentifier ti;
- public:
- C_F0 Find(const char * k) const;
- C_F0 Find(const char * k,const basicAC_F0 & args) const;
- void New(Key k,Type_Expr v,bool del=true){ti.New(k,v,del);}
- void Add(Key k,Key op,OneOperator *p0,OneOperator *p1=0,
- OneOperator *p2=0,OneOperator *p3=0,OneOperator *p4=0,
- OneOperator *p5=0,OneOperator *p6=0)
- {ti.Add(k,op,p0,p1,p2,p3,p4,p5,p6);}
- void AddCast(CastFunc f1,CastFunc f2=0,CastFunc f3=0,CastFunc f4=0,
- CastFunc f5=0,CastFunc f6=0,CastFunc f7=0,CastFunc f8=0);
- ostream & ShowTable(ostream & f) const { f << ti; return f;}
- virtual ~basicForEachType();
-};
-template<typename T>
-inline basicForEachType * atype() {
- map<const string,basicForEachType *>::iterator ir=map_type.find(typeid(T).name());
- if (ir == map_type.end()) { cout << "Error: aType '" << typeid(T).name() << "', doesn't exist\n";
- ShowType(cout);
- throw(ErrorExec("exit",1));}
- return ir->second;}
-class C_LF2;
-class C_LF1;
-class E_F0 :public CodeAlloc
- {
- public:
- struct kless : binary_function<Expression,Expression, bool>
- { bool operator()(const Expression& x, const Expression& y) const{
- int r1 = x->compare(y);
- return r1<0;} };
- typedef map< E_F0 *,int,kless> MapOfE_F0;
- virtual AnyType operator()(Stack) const =0;
- virtual bool Empty() const {return !this; }
- virtual size_t nbitem() const {return 1;}
- virtual bool EvaluableWithOutStack() const {return false;}
- virtual bool MeshIndependent() const {return true;}
- virtual E_F0 * right_E_F0() const { return 0;}
- virtual bool ReadOnly() const { return true;}
- virtual ~E_F0() {}
- virtual int compare (const E_F0 *t) const { int r= (t==this) ? 0 : ( ( this<t) ?-1 : 1);
- return r;}
- virtual int Optimize(deque<pair<Expression,int> > &l,MapOfE_F0 & m, size_t & n) ;
- virtual AnyType operator()(Stack stack,AnyType *) const { return operator()(stack);}
- virtual operator aType () const { (static_cast<void> (0));return 0;}
- virtual ostream & dump(ostream &f) const { f << ' ' << typeid(*this).name() << ' ' << this << ' ' ;return f; }
- int find(const MapOfE_F0 & m) ;
- int insert(Expression opt,deque<pair<Expression,int> > &l,MapOfE_F0 & m, size_t & n) ;
- virtual AnyType eval(Stack stack, bool & meshindep ) const
- { meshindep=MeshIndependent();return operator()(stack);}
- };
-inline ostream & operator<<(ostream & f,const E_F0 &e) { if(&e) e.dump(f); else f << " --0-- " ;return f;}
-class E_F0mps : public E_F0 { public:
- virtual bool MeshIndependent() const {return false;}
-};
-class E_F0info : public E_F0 { public:
- virtual bool EvaluableWithOutStack() const {return true;}
- virtual bool MeshIndependent() const {return true;}
- virtual AnyType operator()(Stack ) const {
- return SetAny<const E_F0 *>(this);}
- operator aType () const { return atype<Expression>();}
-};
-class E_F1 : public CodeAlloc{ public: virtual AnyType operator()(Stack,AnyType &) const =0;};
-class E_F2 : public CodeAlloc{ public: virtual AnyType operator()(Stack,AnyType &,AnyType &) const =0;};
-class E_FN : public CodeAlloc{ public: virtual AnyType operator()(Stack,size_t N,...) const =0;};
-class basicAC_F0;
-class ArrayOfaType : public CodeAlloc{
- aType tt[11];
- protected:
- int n;
- aType * t;
- bool ellipse;
- void operator=(const ArrayOfaType &);
- public:
- explicit ArrayOfaType(bool ell=false)
- :n(0),t(0),ellipse(ell) {}
- explicit ArrayOfaType(const aType & a,bool ell=false)
- :n(1),t(tt),ellipse(ell) {t[0]=a;}
- explicit ArrayOfaType(const aType & a,const aType & b,bool ell=false)
- :n(2),t(tt),ellipse(ell) {t[0]=a,t[1]=b;}
- explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,bool ell=false)
- :n(3),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;}
- explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d,bool ell=false)
- :n(4),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d;
- }
- explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d,const aType & e,bool ell=false)
- :n(5),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d; t[4]=e; }
- explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d,const aType & e,const aType & f,bool ell=false)
- :n(6),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d; t[4]=e; t[5]=f; }
- explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d,const aType & e,
- const aType & f,const aType & g,
- bool ell=false)
- :n(7),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d; t[4]=e; t[5]=f; t[6]=g; }
- explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d,const aType & e,
- const aType & f,const aType & g,const aType & h,
- bool ell=false)
- :n(8),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d; t[4]=e; t[5]=f; t[6]=g; t[7]=h; }
- explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d,const aType & e,
- const aType & f,const aType & g,const aType & h, const aType & i,
- bool ell=false)
- :n(9),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d; t[4]=e; t[5]=f; t[6]=g; t[7]=h; t[8]=i; }
- explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d, const aType & e,
- const aType & f,const aType & g,const aType & h, const aType & i, const aType & j,
- bool ell=false)
- :n(10),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d; t[4]=e; t[5]=f; t[6]=g; t[7]=h; t[8]=i; t[9]=j; }
- explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d,const aType & e,const aType & f,const aType & g,const aType & h, const aType & i, const aType & j, const aType & k,bool ell=false)
- :n(11),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d; t[4]=e; t[5]=f; t[6]=g; t[7]=h; t[8]=i; t[9]=j; t[10]=k; }
- ArrayOfaType(const basicAC_F0 & ) ;
- ArrayOfaType(const ArrayOfaType & );
- ArrayOfaType(const ListOfId * l);
- ~ArrayOfaType() { if(t && t != tt) delete [] t;t=0;n=0;}
- bool WithOutCast( const ArrayOfaType & a) const ;
- bool WithCast( const ArrayOfaType & a,int nbcast=100000) const ;
- bool operator==( const ArrayOfaType & a) const {
- if (a.n != n || a.ellipse !=ellipse) return false;
- for (int i=0;i<n;i++)
- if (t[i] != a.t[i])
- return false;
- return true;}
- friend ostream & operator<<(ostream & f,const ArrayOfaType & a);
-};
-class OneOperator : public ArrayOfaType {
- friend class MakeVectSpaceN;
- friend class basicForEachType;
- const basicForEachType * r;
- OneOperator *next;
- public:
- int pref;
- OneOperator(aType rr) ;
- OneOperator(aType rr,aType a) ;
- OneOperator(aType rr,aType a,aType b);
- OneOperator(aType rr,aType a,aType b,aType c) ;
- OneOperator(aType rr,aType a,aType b,aType c,aType d) ;
- OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e) ;
- OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f) ;
- OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f, aType g);
- OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f, aType g, aType h);
- OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f, aType g, aType h, aType i) ;
- OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f, aType g, aType h, aType i, aType j);
- OneOperator(aType rr,const ArrayOfaType &ta) ;
- OneOperator(aType rr,bool ellipse) ;
- OneOperator(aType rr,const ListOfId *l) ;
- typedef pair<const OneOperator *,int> pair_find;
- void operator+=(OneOperator &a){( (void) 0);a.next=next;next=&a;}
- virtual ~OneOperator();
- pair_find Find(const ArrayOfaType & at) const ;
- pair_find FindWithOutCast(const ArrayOfaType & at) const ;
- OneOperator * FindSameR(const ArrayOfaType & at) ;
- void Show(const ArrayOfaType & at,ostream &f=cout) const;
- void Show(ostream &f=cout) const;
- operator aType () const { return r;}
- virtual E_F0 * code(const basicAC_F0 &) const =0;
- virtual C_F0 code2(const basicAC_F0 &a) const ;
- const OneOperator * Simple() const { return next||n?0:this;}
- friend ostream & operator<<(ostream & f,const OneOperator & a);
-};
-class Polymorphic: public E_F0mps {
- private:
- typedef const char * Key;
- typedef OneOperator * Value;
- typedef map<Key,Value,Keyless> maptype;
- typedef maptype::const_iterator const_iterator;
- typedef maptype::iterator iterator;
- mutable maptype m;
- Expression e;
- public:
- Polymorphic() : m(),e(0) {}
- virtual AnyType operator()(Stack ) const { return Nothing;}
- virtual bool Empty() const {return true;}
- void clear() { m.clear();}
- const OneOperator * Find(const char *op, const ArrayOfaType &at) const;
- const OneOperator * FindWithOutCast(const char *op,const ArrayOfaType &at) const;
- void Show(const char *op,const ArrayOfaType & at,ostream &f=cout)const ;
- void Add(const char * op,OneOperator * p0 ,OneOperator * p1=0,OneOperator * p2=0,
- OneOperator * p3=0,OneOperator * p4=0,OneOperator * p5=0,
- OneOperator * p6=0,OneOperator * p7=0,OneOperator * p8=0,
- OneOperator * p9=0,OneOperator * pa=0,OneOperator * pb=0,
- OneOperator * pc=0,OneOperator * pd=0,OneOperator * pe=0
- ) const
- {Addp(op,p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,pa,pb,pc,pd,pe,0);}
- void Add(const char * op,OneOperator ** pp) const ;
- private:
- void Addp(const char * op,OneOperator * pp,...) const ;
- friend ostream & operator<<(ostream & f,const Polymorphic & a);
-};
-class basicAC_F0;
- class C_F0 {
- friend class CC_F0;
- protected:
- Expression f;
- aType r;
- public:
- C_F0() :f(0),r(0) {}
- C_F0(const C_F0 & c):f(c.f),r(c.r) {}
- C_F0(const C_F0 & a,const C_F0 & b);
- C_F0(const Type_Expr & a):f(a.second),r(a.first) {}
- C_F0(const Polymorphic *,const char *,const basicAC_F0 & );
- C_F0(const Polymorphic *,const char *, AC_F0 & );
- C_F0(const C_F0 & e,const char *op,const basicAC_F0 & p) ;
- C_F0(const C_F0 & e,const char *op, AC_F0 & p) ;
- C_F0(const C_F0 & e,const char *op,const C_F0 & ee) ;
- C_F0(const C_F0 & e,const char *op,const C_F0 & a,const C_F0 & b) ;
- C_F0(const C_F0 & e,const char *nm) ;
- C_F0(const Polymorphic * pop,const char *op);
- C_F0(const Polymorphic * pop,const char *op,const C_F0 & a);
- C_F0(const Polymorphic * pop,const char *op,const C_F0 & a,const C_F0 & b);
- C_F0(const Polymorphic * pop,const char *op,const C_F0 & a,const C_F0 & b,const C_F0 & c);
- C_F0( Expression ff,aType rr ): f(ff),r(rr) {
- }
- AnyType eval(Stack s) const {return (*f)(s);}
- Expression RightValue() const { return r->RightValueExpr(f);}
- Expression LeftValue() const;
- aType left() const {return r;}
- aType right() const {return r->right();}
- C_F0 RightExp() const { return C_F0(RightValue(),right());}
- operator E_F0 * () const {return f;}
- bool Empty() const {return !f || f->Empty();}
- bool NotNull() const {return f;}
- int TYPEOFID() const { return r ? r->TYPEOFID(): 0;}
- int nbitem() const { return f ? f->nbitem() : 0;}
- bool EvaluableWithOutStack() const { return f && f->EvaluableWithOutStack();}
- Expression Destroy() { return r->Destroy(*this);}
- operator const Polymorphic * () const {return dynamic_cast<const Polymorphic *>(f);}
- bool operator==(const C_F0 & a) const {return f==a.f && r == a.r;}
- bool operator!=(const C_F0 & a) const {return f!=a.f || r != a.r;}
- bool MeshIndependent() const { return f ==0 ? f->MeshIndependent() : false;}
- C_F0 OnReturn() { f=r->OnReturn(f); return *this; }
-private:
-friend class Block;
-friend class TableOfIdentifier;
- C_F0( Expression ff ): f(ff),r(0) {}
- };
-class CListOfInst;
-class ForTypeVoid: public basicForEachType{public:
- ForTypeVoid():basicForEachType(typeid(void),0,0,0,0,0) {}
-};
-template<class T>
-class ForEachType: public basicForEachType{public:
- ForEachType(Function1 iv=0,Function1 id=0,Function1 OOnReturn=0):basicForEachType(typeid(T),sizeof(T),0,0,iv,id,OOnReturn) {
- if (sizeof(T) > sizeof(AnyTypeWithOutCheck) )
- {
- cout << " Sorry the " <<typeid(T).name() << " is too large ( " << sizeof(T)
- << " > " << sizeof(AnyTypeWithOutCheck) << " ) " << endl;
- ( (void) 0);
- }
- }
-};
-template<class T>
-class ForEachType<T*>: public basicForEachType{public:
- ForEachType(Function1 iv=0,Function1 id=0,Function1 OOnReturn=0):basicForEachType(typeid(T),sizeof(T),0,0,iv,id,OOnReturn) {
- }
-};
-template<class A,class B> AnyType UnRef(Stack,const AnyType &a) ;
-template<class A> AnyType Initialize(Stack,const AnyType &a) ;
-template<class A> AnyType Destroy(Stack,const AnyType &a) ;
-template<class T,class PT=T*>
-class ForEachTypePtr: public basicForEachType { public:
- ForEachTypePtr();
- ForEachTypePtr(Function1 init,Function1 dl,Function1 onreturn=0);
- ForEachTypePtr(Function1 dl);
-};
-template<class T>
-class ForEachTypePtr<T*,T**>: public basicForEachType { public:
- ForEachTypePtr(T* bb=0,Function1 onreturn=0);
- ForEachTypePtr(Function1 init,Function1 dl,Function1 onreturn=0);
- ForEachTypePtr(Function1 dl);
-};
-template<class T,int RTYPE>
-class ForEachTypePtrfspace: public ForEachTypePtr<T> { public:
- ForEachTypePtrfspace():ForEachTypePtr<T>() {}
- int TYPEOFID() const {return RTYPE;}
-};
-class ForTypeAnyType: public basicForEachType{public:
- ForTypeAnyType(): basicForEachType(typeid(AnyType),sizeof(AnyType)) {}
- bool CastingFrom(const basicForEachType * ) const {return true;}
- C_F0 CastTo(const C_F0 & e) const {return e;}
-};
-template<class A,class B>
- AnyType Cast(Stack,const AnyType &b) {
- return SetAny<A>(static_cast<A>(GetAny<B>(b)));}
-template<class A,class B,A F(const B &)>
- AnyType FCast(Stack s,const AnyType &b) {
- return SetAny<A>(Add2StackOfPtr2Free(s,F(GetAny<B>(b))));}
-template<class A>
- AnyType UnRef(Stack,const AnyType &a) {
- return SetAny<A>(*PGetAny<A>(a));}
-template<class A,class B>
- AnyType UnRef(Stack,const AnyType &a) {
- return SetAny<A>(*GetAny<B>(a));}
-template<class A>
- AnyType UnRefCopyPtr(Stack s,const AnyType &a) {
- A ** ppa=PGetAny<A*>(a);
- A * pc = new A(**ppa);
- return SetAny<A*>(Add2StackOfPtr2Free(s,pc)) ;}
-template<class A> AnyType Initialize(Stack,const AnyType &x){
- A * a=PGetAny<A>(x);
- A *b=new A;
- memcpy(a,b,sizeof(A));
- ::operator delete(b);
- return SetAny<A*>(a);
-}
-template<class A> AnyType InitializePtr(Stack stack,const AnyType &x){
- A * a=PGetAny<A>(x);
- ( (void)0);
- *a=0;
- return x;
-}
-template<class A> AnyType InitializeDef(Stack stack,const AnyType &x){
- A * a=PGetAny<A>(x);
- ( (void)0);
- *a=A();
- return x;
-}
-template<class A> inline AnyType Delete(Stack,const AnyType &x){
- A * a=PGetAny<A>(x);
- ( (void)0);
- (*a).~A();
- return Nothing;
-}
-template<class A> inline AnyType Destroy(Stack,const AnyType &x){
- A * a=PGetAny<A>(x);
- ( (void)0);
- a->destroy();
- return Nothing;
-}
-template<class A> inline AnyType DestroyS(Stack,const AnyType &x){
- A a=GetAny<A>(x);
- ( (void)0);
- a.destroy();
- return Nothing;
-}
-template<class A> inline AnyType InitS(Stack,const AnyType &x){
- A a=GetAny<A>(x);
- ( (void)0);
- a.init();
- return Nothing;
-}
-template<class A> inline AnyType InitP(Stack,const AnyType &x){
- A *a=PGetAny<A>(x);
- ( (void)0);
- a->init();
- return Nothing;
-}
-template<class A> inline AnyType DestroyPtr(Stack,const AnyType &x) {
- const A * a=PGetAny<A>(x);
- ( (void)0);
- (*a)->destroy();
- return Nothing;
-};
-template<class A> inline AnyType DeletePtr(Stack,const AnyType &x) {
- const A * a=PGetAny<A>(x);
- ( (void)0);
- delete *a;
- return Nothing;
-};
-template<> AnyType inline DestroyPtr<string *>(Stack,const AnyType &x) {
- string ** a=PGetAny<string*>(x);
- ( (void)0);
- delete *a;
- return Nothing;
-};
-template<class A> AnyType Initialize(Stack,const AnyType &x,const AnyType &y){
- A * a=PGetAny<A>(x);
- A *b=new A(GetAny<A>(x));
- memcpy(a,b,sizeof(A));
- ::operator delete(b);
- return SetAny<A*>(a);
-}
-class E_F0_CFunc2 :public E_F0mps { public:
- CFunction2 f2;
- E_F0 *a,*b;
- AnyType operator()(Stack s) const {return f2(s,a,b);}
- E_F0_CFunc2( CFunction2 ff,E_F0 *aa,E_F0 *bb) : f2(ff),a(aa),b(bb){}
- bool EvaluableWithOutStack() const
- {return a->EvaluableWithOutStack() && b->EvaluableWithOutStack();}
- operator aType () const { return atype<void>();}
-};
-class E_F0_CFunc4 :public E_F0mps { public:
- CFunction4 f4;
- E_F0 *a,*b,*c,*d;
- AnyType operator()(Stack s) const {return f4(s,a,b,c,d);}
- E_F0_CFunc4( CFunction4 ff,E_F0 *aa,E_F0 *bb,E_F0 *cc,E_F0 *dd)
- : f4(ff),a(aa),b(bb),c(cc),d(dd){}
- operator aType () const { return atype<void>();}
-};
-template<class R,class A>
- class E_F1_F :public E_F1 { public:
- typedef R (*func)(A) ;
- func f;
- E_F1_F(func ff) : f(ff) {}
- AnyType operator()(Stack s,AnyType & a) const
- {return SetAny<R>(f(GetAny<A>(a)));}
-};
-template<class R,class A0,class A1>
- class E_F2_F :public E_F2 { public:
- typedef R (*func)(const A0 &,const A1&) ;
- func f;
- E_F2_F(func ff) : f(ff) {}
- AnyType operator()(Stack s,AnyType & a0,AnyType & a1) const
- {return SetAny<R>(f(GetAny<A0>(a0),GetAny<A1>(a1)));}
-};
-template<class R,class TA0,bool RO=true>
- class E_F_F0 :public E_F0 { public:
- template <class T> struct remove_reference {typedef T type;};
- template <class T> struct remove_reference<const T&> {typedef T type;};
- typedef typename remove_reference<TA0>::type A0;
- typedef R (*func)( TA0 ) ;
- func f;
- Expression a;
- E_F_F0(func ff,Expression aa) : f(ff),a(aa) {}
- AnyType operator()(Stack s) const
- {return SetAny<R>(f(GetAny<A0>( (*a)(s) )));}
- bool EvaluableWithOutStack() const
- {return a->EvaluableWithOutStack();}
- bool MeshIndependent() const {return a->MeshIndependent();}
- bool ReadOnly() const { return RO ;}
- int compare (const E_F0 *t) const {
- int rr;
- const E_F_F0* tt=dynamic_cast<const E_F_F0 *>(t);
- if (tt && f == tt->f) rr = a->compare(tt->a);
- else rr = E_F0::compare(t);
- return rr;
- }
- int Optimize(deque<pair<Expression,int> > &l,MapOfE_F0 & m, size_t & n) ;
- virtual ostream & dump(ostream &ff) const { ff << typeid(*this).name() <<" f= " << ff << " a= "<< *a << ' ' ;return ff; }
-};
-template<class R,class TA0,bool RO=true>
-class E_F_F0_Opt: public E_F_F0<R,TA0,RO> { public :
- size_t ia;
- E_F_F0_Opt(const E_F_F0<R,TA0,RO> &t,size_t iaa)
- : E_F_F0<R,TA0,RO>(t) , ia(iaa) {(static_cast<void> (0));}
- AnyType operator()(Stack s) const
- {
- return SetAny<R>( f( *static_cast<typename E_F_F0<R,TA0>::A0 *>(static_cast<void*>(static_cast<char *>(s)+ia)) ) );}
-};
-template<class R,class TA0,bool RO>
- int E_F_F0<R,TA0,RO>::Optimize(deque<pair<Expression,int> > &l,MapOfE_F0 & m, size_t & n)
- {
- int rr = find(m);
- if (rr) return rr;
- return insert(new E_F_F0_Opt<R,TA0,RO>(*this,a->Optimize(l,m,n)),l,m,n);
- }
-template<class A0>
- class E_VF_F0 :public E_F0 { public:
- typedef void (*func)( A0 ) ;
- func f;
- Expression a;
- E_VF_F0(func ff,Expression aa) : f(ff),a(aa) {}
- AnyType operator()(Stack s) const
- {f(GetAny<A0>( (*a)(s) ));return Nothing;}
- bool EvaluableWithOutStack() const
- {return a->EvaluableWithOutStack();}
- bool MeshIndependent() const { return a->MeshIndependent(); }
-};
-inline int clexico(int i,int j) { return i==0 ? j : i;}
-inline int clexico(int i,int j,int k) { int ll=clexico(i,j); return ll==0 ? k : ll;}
-template<class R,class TA0,class TA1>
- class E_F_F0F0 :public E_F0 { public:
- template <class T> struct remove_reference {typedef T type;};
- template <class T> struct remove_reference<T&> {typedef T type;};
- typedef typename remove_reference<TA0>::type A0;
- typedef typename remove_reference<TA1>::type A1;
- typedef R (*func)( A0 , A1 ) ;
- func f;
- Expression a0,a1;
- E_F_F0F0(func ff,Expression aa0,Expression aa1)
- : f(ff),a0(aa0),a1(aa1) {}
- AnyType operator()(Stack s) const
- {return SetAny<R>( f( GetAny<A0>((*a0)(s)) , GetAny<A1>((*a1)(s)) ) );}
- bool EvaluableWithOutStack() const
- {return a0->EvaluableWithOutStack() && a1->EvaluableWithOutStack();}
- bool MeshIndependent() const
- {return a0->MeshIndependent() && a1->MeshIndependent();}
- int compare (const E_F0 *t) const {
- int rr;
- const E_F_F0F0* tt=dynamic_cast<const E_F_F0F0 *>(t);
- if (tt && f == tt->f) rr= clexico(a0->compare(tt->a0),a1->compare(tt->a1));
- else rr = E_F0::compare(t);
- return rr;
- }
- int Optimize(deque<pair<Expression,int> > &l,MapOfE_F0 & m, size_t & n) ;
-};
-template<class R,class TA0,class TA1>
-class E_F_F0F0_Opt: public E_F_F0F0<R,TA0,TA1> { public :
- size_t ia,ib;
- E_F_F0F0_Opt(const E_F_F0F0<R,TA0,TA1> &t,size_t iaa,size_t ibb)
- : E_F_F0F0<R,TA0,TA1>(t) ,
- ia(iaa),ib(ibb) {}
- AnyType operator()(Stack s) const
- {
- return SetAny<R>( f( *static_cast<typename E_F_F0F0<R,TA0,TA1>::A0 *>(static_cast<void*>(static_cast<char *>(s)+ia)) ,
- *static_cast<typename E_F_F0F0<R,TA0,TA1>::A1 *>(static_cast<void*>(static_cast<char *>(s)+ib)) ) );}
-};
-template<class R,class TA0,class TA1>
- int E_F_F0F0<R,TA0,TA1>::Optimize(deque<pair<Expression,int> > &l,MapOfE_F0 & m, size_t & n)
- {
- int rr = find(m);
- if (rr) return rr;
- return insert(new E_F_F0F0_Opt<R,TA0,TA1>(*this,a0->Optimize(l,m,n),a1->Optimize(l,m,n)),l,m,n);
- }
-template<class R,class A0>
- class E_F_F0_ :public E_F0 { public:
- typedef R (*func)(const A0& ) ;
- func f;
- Expression a;
- E_F_F0_(func ff,Expression aa) : f(ff),a(aa) {}
- AnyType operator()(Stack s) const
- {return SetAny<R>(f(GetAny<A0>( (*a)(s) )));}
- bool EvaluableWithOutStack() const
- {return a->EvaluableWithOutStack() ;}
- bool MeshIndependent() const
- {return a->MeshIndependent();}
-};
-template<class R,class A0>
-class E_F_F0_Add2RC :public E_F0 { public:
- typedef R (*func)(const A0& ) ;
- func f;
- Expression a;
- E_F_F0_Add2RC(func ff,Expression aa) : f(ff),a(aa) {}
- AnyType operator()(Stack s) const
- {return SetAny<R>(Add2StackOfPtr2FreeRC(s,f(GetAny<A0>( (*a)(s) ))));}
- bool EvaluableWithOutStack() const
- {return a->EvaluableWithOutStack() ;}
- bool MeshIndependent() const
- {return a->MeshIndependent();}
-};
-template<class R,class A0>
- class E_F_F0s_ :public E_F0mps { public:
- typedef R (*func)(Stack stack,const A0& ) ;
- func f;
- Expression a;
- E_F_F0s_(func ff,Expression aa) : f(ff),a(aa) {}
- AnyType operator()(Stack s) const
- {return SetAny<R>(f(s,GetAny<A0>( (*a)(s) )));}
- bool MeshIndependent() const
- {return true;}
- operator aType () const { return atype<R>();}
-};
-template<class R,class A0,class A1,class E=E_F0>
- class E_F_F0F0_ :public E { public:
- typedef R (*func)(const A0 &,const A1 & ) ;
- func f;
- Expression a0,a1;
- E_F_F0F0_(func ff,Expression aa0,Expression aa1)
- : f(ff),a0(aa0),a1(aa1) {}
- AnyType operator()(Stack s) const
- {return SetAny<R>( f( GetAny<A0>((*a0)(s)) , GetAny<A1>((*a1)(s)) ) );}
- bool MeshIndependent() const
- {return a0->MeshIndependent() && a1->MeshIndependent();}
-};
-template<class R,class A0,class A1,class E=E_F0>
-class E_F_F0F0_Add2RC :public E { public:
-typedef R (*func)(const A0 &,const A1 & ) ;
-func f;
-Expression a0,a1;
-E_F_F0F0_Add2RC(func ff,Expression aa0,Expression aa1)
-: f(ff),a0(aa0),a1(aa1) {}
-AnyType operator()(Stack s) const
-{return SetAny<R>(Add2StackOfPtr2FreeRC(s, f( GetAny<A0>((*a0)(s)) , GetAny<A1>((*a1)(s)) ) ));}
-bool MeshIndependent() const
-{return a0->MeshIndependent() && a1->MeshIndependent();}
-};
-template<class R,class A0,class A1,class A2,class E=E_F0>
- class E_F_F0F0F0_ :public E { public:
- typedef R (*func)(const A0 &,const A1 & , const A2 &) ;
- func f;
- Expression a0,a1,a2;
- E_F_F0F0F0_(func ff,Expression aa0,Expression aa1,Expression aa2)
- : f(ff),a0(aa0),a1(aa1),a2(aa2) {}
- AnyType operator()(Stack s) const
- {return SetAny<R>( f( GetAny<A0>((*a0)(s)) , GetAny<A1>((*a1)(s)),GetAny<A2>((*a2)(s)) ) );}
- virtual size_t nbitem() const {return a2->nbitem(); }
- bool MeshIndependent() const
- {return a0->MeshIndependent() && a1->MeshIndependent()&& a2->MeshIndependent();}
-};
-template<class R,class A0,class A1,class A2,class E=E_F0>
- class E_F_stackF0F0F0_ :public E_F0mps { public:
- typedef R (*func)(Stack, const A0 &,const A1 & , const A2 &) ;
- func f;
- Expression a0,a1,a2;
- E_F_stackF0F0F0_(func ff,Expression aa0,Expression aa1,Expression aa2)
- : f(ff),a0(aa0),a1(aa1),a2(aa2) {}
- AnyType operator()(Stack s) const
- {return SetAny<R>( f(s, GetAny<A0>((*a0)(s)) , GetAny<A1>((*a1)(s)),GetAny<A2>((*a2)(s)) ) );}
- virtual size_t nbitem() const {return a2->nbitem(); }
- bool MeshIndependent() const { return true;}
-};
-template<class R,class A0,class A1>
- class E_F_F0F0_NC :public E_F0 { public:
- typedef R (*func)( A0 &,const A1 & ) ;
- func f;
- Expression a0,a1;
- E_F_F0F0_NC(func ff,Expression aa0,Expression aa1)
- : f(ff),a0(aa0),a1(aa1) {}
- AnyType operator()(Stack s) const
- {return SetAny<R>( f( GetAny<A0>((*a0)(s)) , GetAny<A1>((*a1)(s)) ) );}
- bool MeshIndependent() const
- {return a0->MeshIndependent() && a1->MeshIndependent() ; }
-};
- class E_F_StackF0F0 :public E_F0mps { public:
- typedef AnyType (*func)(Stack,Expression ,Expression ) ;
- func f;
- Expression a0,a1;
- E_F_StackF0F0(func ff,Expression aa0,Expression aa1)
- : f(ff),a0(aa0),a1(aa1) { }
- AnyType operator()(Stack s) const
- {return (*f)(s, a0 , a1) ;}
-};
-class E_F2_func :public E_F2 { public:
- Function2 f;
- AnyType operator()(Stack s,AnyType & a,AnyType & b) const {return f(s,a,b);}
- E_F2_func( Function2 ff) : f(ff) {}
-};
-class E_F0_Func1 :public E_F0 { public:
- Function1 f;
- E_F0 *a;
- AnyType operator()(Stack s) const {return f(s,(*a)(s));}
- E_F0_Func1( Function1 f1,E_F0 *aa) : f(f1),a(aa){}
- bool EvaluableWithOutStack() const {return a->EvaluableWithOutStack();}
- bool MeshIndependent() const {return a->MeshIndependent();}
- int compare (const E_F0 *t) const {
- int rr;
- const E_F0_Func1* tt=dynamic_cast<const E_F0_Func1 *>(t);
- if (tt && f == tt->f) rr = a->compare(tt->a);
- else rr = E_F0::compare(t);
- if(tt && 0)
- {
- cout << "\n\t\t\t -------- " << (void *) f << " " << (void *) tt->f << " rr=" << a->compare(tt->a) << endl;
- cout << "\t\t\tcmp E_F0_Func1 " << rr <<" << " << *this << " cmp " << *t << " " << tt << ">>\n";
- }
- return rr;
- }
- virtual ostream & dump(ostream &ff) const { ff << "E_F0_Func1 f= " << f << " a= "<< *a << ' ' ;return ff; }
-};
-class E_F0_Func2 :public E_F0 { public:
- Function2 f;
- E_F0 *a,*b;
- AnyType operator()(Stack s) const {return f(s,(*a)(s),(*b)(s));}
- E_F0_Func2( Function2 f1,E_F0 *aa,E_F0 *bb) : f(f1),a(aa),b(bb){}
- bool EvaluableWithOutStack() const
- {return a->EvaluableWithOutStack() &&b->EvaluableWithOutStack();}
- bool MeshIndependent() const {return a->MeshIndependent() && b->MeshIndependent();}
-};
-template<class R> class Value1:public E_F0
- {
- size_t offset;
- public:
- AnyType operator()(Stack s) const { return SetAny<R*>(static_cast<R *>(static_cast<void *>( static_cast<char *>(s)+offset)));}
- Value1(size_t o):offset(o) {}
-};
-template<class R> class GValue:public E_F0
- {
- mutable R v;
- public:
- AnyType operator()(Stack ) const { return SetAny<R*>(static_cast<R *>(static_cast<void *>(&v)));}
- GValue(R o):v(o) {}
- bool EvaluableWithOutStack() const {return true;}
-};
-template<class R> int ccompare(const R & a,const R& b){ return a==b ? 0 :( a<b ? -1 : +1);}
-template<class R> int ccompare(const complex<R> & a,const complex<R>& b){
- int c=ccompare(a.real(),b.real());
- return c==0 ? ccompare(a.imag(),b.imag()): c ;}
-template<class R> class EConstant:public E_F0
- {
- const R v;
- public:
- AnyType operator()(Stack ) const { ;return SetAny<R>(v);}
- EConstant(const R & o):v(o) { }
- bool EvaluableWithOutStack() const {return true;}
- operator aType () const { return atype<R>();}
- int compare (const E_F0 *t) const {
- int rr;
- const EConstant * tt=dynamic_cast<const EConstant *>(t);
- if (tt) rr = ccompare(v,tt->v);
- else rr = E_F0::compare(t);
- return rr;
- }
- ostream & dump(ostream &f) const { f << " ((" <<typeid(R).name() << ") " << v << ") " ;return f;}
-};
- class LocalVariable:public E_F0
- {
- size_t offset;
- aType t;
- public:
- AnyType operator()(Stack s) const {
- ( (void)0);
- return PtrtoAny(Stack_offset<void>(s,offset),t);}
- LocalVariable(size_t o,aType tt):offset(o),t(tt) {( (void) 0);
- ( (void)0);
- }
-};
-class LocalVariableFES : public LocalVariable { public:
- size_t data;
- LocalVariableFES(size_t o,aType tt,const size_t & d)
- : LocalVariable(o,tt),data(d) {}
- size_t nbitem() const { return data;}
-};
-template <class U>
-class LocalVariablePlus : public LocalVariable { public:
- U data;
- LocalVariablePlus(size_t o,aType tt,const U & d)
- : LocalVariable(o,tt),data(d) {}
-};
-template<class T> class PValue:public E_F0
- {
- T * p;
- public:
- AnyType operator()(Stack ) const { return p;}
- PValue(T * pp):p(pp) {}
-};
-template<class R> class PPValue:public E_F0
- {
- R ** p;
- public:
- AnyType operator()(Stack ) const { return SetAny<R*>(*p);}
- PPValue(R ** pp):p(pp) {}
-};
-template<class R>
-Type_Expr CPValue(R & v)
- {
- ( (void) 0);
- return make_pair(map_type[typeid(R*).name()],new PValue<R>(&v));
- }
-template<class R>
-Type_Expr CPPValue(R *& v)
- {
- ( (void) 0);
- return make_pair(map_type[typeid(R*).name()],new PPValue<R>(&v));
- }
-template<class R >
-Type_Expr CConstant(const R & v)
- {
- ( (void) 0);
- return make_pair(map_type[typeid(R).name()],new EConstant<R>(v));
- }
-class CC_F0 {
- Expression f;
- aType r;
-public:
- void operator=(const C_F0& c) { f=c.f;r=c.r;;}
- void operator=(const AC_F0& a) ;
- void operator=(long ) {f=0;r=0;}
- void operator=(const CListOfInst& c);
- operator C_F0 () const {return C_F0(f,r);}
- bool Empty() const {return !f || f->Empty();}
- aType left() const {return r;}
-};
-class ListOfInst : public E_F0mps {
- int n;
- Expression * list;
- int * linenumber;
- const int nx;
- public:
- ListOfInst():n(0),list(0),linenumber(0),nx(10){}
- ListOfInst(int nn):n(0),list(0),linenumber(0),nx(nn?nn:10){}
- void Add(const C_F0 & ins);
- AnyType operator()(Stack s) const;
- operator aType () const { return n ? (aType) * (list[n-1]) : atype<void>();}
- Expression &operator[](int i){return list[i];}
- bool empty() const {return n==0;}
- int size() const {return n;}
- Expression * ptr() const {return list;}
- int * nlines() const {return linenumber;}
- ~ListOfInst(){ cout << " ----- ~ListOfInst " << endl;
- if(list) delete [] list;list=0;if(linenumber) delete[] linenumber; linenumber=0;}
-};
-class CListOfInst { private:
- ListOfInst * f;
- const basicForEachType *r;
- public:
- void operator=(const CC_F0 &a){
- f=new ListOfInst();
- if( !a.Empty() ) {
- f->Add(a);
- r=a.left(); }}
- CListOfInst & operator+=(const CC_F0 & a);
- operator C_F0 () const { return C_F0(f,r);}
- void eval(Stack s) {(*f)(s);}
- int size() const {return f->size();}
- Expression * ptr() const {return f->ptr();}
- int * nlines() const { return f->nlines();}
-};
-AnyType FWhile(Stack ,E_F0 * test,E_F0 * ins);
-AnyType FFor(Stack s ,E_F0 * i0,E_F0 * i1,E_F0 * i2,E_F0 * ins);
-AnyType FIf(Stack s ,E_F0 * test,E_F0 * i1,E_F0 * i2,E_F0 * notuse);
-AnyType TTry(Stack s ,E_F0 * i0,E_F0 * i1,E_F0 * i2,E_F0 * notuse);
-extern TableOfIdentifier Global;
-void ShowType(ostream & );
-template<class T>
-inline C_F0 to(const C_F0 & a) { return map_type[typeid(T).name()]->CastTo(a);}
-inline C_F0 While(C_F0 test,C_F0 ins) {return C_F0(new E_F0_CFunc2(FWhile,to<bool>(test),ins),0);}
-inline C_F0 For(C_F0 i0,C_F0 i1,C_F0 i2,C_F0 ins) {return C_F0(new E_F0_CFunc4(FFor,i0,to<bool>(i1),i2,ins),0);}
-inline C_F0 Try(C_F0 i0,C_F0 i1,C_F0 i2) {return C_F0(new E_F0_CFunc4(TTry,i0,i1,i2,0),0);}
-inline C_F0 FIf(C_F0 i0,C_F0 i1,C_F0 i2) {return C_F0(new E_F0_CFunc4(FIf,to<bool>(i0),i1,i2,0),0);}
-inline C_F0 FIf(C_F0 i0,C_F0 i1) {return C_F0(new E_F0_CFunc4(FIf,to<bool>(i0),i1,0,0),0);}
-class basicAC_F0 {
- friend class E_Array;
- protected:
- typedef const C_F0 const_C_F0;
- int nb;
- C_F0 *a;
- public:
- typedef map<const char *,C_F0,Keyless> maptype ;
- typedef maptype::iterator iterator;
- typedef maptype::const_iterator const_iterator;
- maptype * named_parameter;
- basicAC_F0 & operator=(int i) {( (void) 0);named_parameter=0,nb=0;return *this;}
- basicAC_F0 & operator=(C_F0 & c) {named_parameter=0;nb=1;a=&c;return *this;}
- basicAC_F0 & operator=(pair<int,C_F0*> p) {named_parameter=0;nb=p.first;a=p.second;return *this;}
- const C_F0 & operator [] (int i) const {( (void) 0);return a[i];}
- int size() const {return nb;}
- C_F0 * ptr() const {return a;}
- C_F0 find(const char * k) const {
- (static_cast<void> (0));
- if (named_parameter) { const_iterator i=named_parameter->find(k) ;
- if (i == named_parameter->end() ) return C_F0();
- else return i->second;}
- else return C_F0();}
- struct name_and_type{
- const char * name;
- const type_info * type;
- } ;
- void SetNameParam(int n=0,name_and_type *l=0 , Expression * e=0) const ;
-};
-class AC_F0: public basicAC_F0 {
- const static int MaxSize;
- public:
- AC_F0 & operator=(pair<const char *,const C_F0> p) {
- named_parameter=0; a=new C_F0[MaxSize]; nb=0;Add(p.first,p.second);return *this;}
- AC_F0 & operator+=(pair<const char *,const C_F0> p) {Add(p.first,p.second);return *this;}
- AC_F0 & operator=(long k) {( (void) 0);named_parameter=0;a=new C_F0[MaxSize]; nb=0;return *this;}
- AC_F0 & operator=(const C_F0& c) {named_parameter=0; a=new C_F0[MaxSize]; nb=0;a[nb++]=c;return *this;}
- AC_F0 & operator+=(const C_F0& c) {
- if ( ! (a&& nb<MaxSize))
- CompileError("Sorry number of parameters > 1024");
- a[nb++]=c;return *this;}
- AC_F0 & Add(const char * nm,const C_F0 &c) {
- if (!named_parameter) named_parameter=new maptype();
- iterator i=named_parameter->find(nm);
- if(i==named_parameter->end()) named_parameter->insert(make_pair(nm,c));
- else {cout << " the named in the list already exists "<< nm <<endl; CompileError();}
- return *this;}
- int size() const {return nb;}
- const C_F0 & operator [] (int i) const {( (void) 0);return a[i];}
- void destroy() {
- nb=0;
- if(named_parameter)
- delete named_parameter;
- if (a)
- delete [] a;
- a=0;named_parameter=0;}
-};
-class basicAC_F0_wa : public basicAC_F0 { public:
- basicAC_F0_wa(const C_F0 & e) {
- named_parameter=0;
- nb=1;
- a= new C_F0[nb];
- a[0]=e;
- }
- basicAC_F0_wa(const C_F0 & e,const C_F0 & ee) {
- named_parameter=0;
- nb=2;
- a= new C_F0[nb];
- a[0]=e;
- a[1]=ee;
- }
- basicAC_F0_wa(C_F0 e,const basicAC_F0 & b) {
- named_parameter=0;
- if (b.named_parameter) named_parameter = new maptype(*b.named_parameter);
- nb=1+b.size();
- a= new C_F0[nb];
- a[0]=e;
- for (int i=1;i<nb;i++) a[i]=b[i-1];}
- ~basicAC_F0_wa(){delete [] a;}
- basicAC_F0_wa(const basicAC_F0 & b) {
- named_parameter=0;
- if (b.named_parameter) named_parameter = new maptype(*b.named_parameter);
- nb=b.size();
- a= new C_F0[nb];
- for (int i=0;i<nb;i++) a[i]=b[i];}
- private:
- void operator=(const basicAC_F0 & b);
-};
-class E_Array :public E_F0 { public:
- basicAC_F0_wa *v;
- E_Array(const basicAC_F0 & aa) : v(new basicAC_F0_wa(aa)) {( (void) 0);}
- AnyType operator()(Stack) const {
- cout << " No evaluation of an E_array" << endl;
- ( (void) 0);
- return Nothing;}
- const C_F0 & operator [] (int i) const {( (void) 0);return (*v)[i];}
- int size() const {return v->size();}
- size_t nbitem() const {return v->size();}
- void map(C_F0 (*mapping)(const C_F0 & )) const
- { for (int i=0;i<v->size();i++)
- v->a[i]=(*mapping)(v->a[i]);}
- virtual bool MeshIndependent() const {
- for (int i=0;i<v->size();i++)
- if (v->a[i].MeshIndependent()) return false;
- return false;
- }
- operator aType () const { return atype<void>();}
- };
-class PlotStream;
-class E_Border ;
-class E_BorderN :public E_F0mps { public:
- const E_Border * b;
- Expression n;
- const E_BorderN * next;
- E_BorderN(const E_Border * bb, C_F0 nn,const E_BorderN * nx=0) ;
- E_BorderN(const E_BorderN & bb,const E_BorderN * nx)
- : b(bb.b),n(bb.n),next(nx)
- {
- int kk=1;
- if(bb.next) {
- const E_BorderN ** pnext = &next;
- E_BorderN *pp;
- next = bb.next;
- for(int step=0;step<2;++step)
- {
- while (*pnext)
- {
- kk++;
- pp = new E_BorderN(**pnext);
- *pnext = pp;
- pnext = & pp->next;
- }
- if(step==0)
- *pnext= nx;
- }
- }
- }
- AnyType operator()(Stack) const {
- return SetAny<const E_BorderN *>(this);}
- operator aType () const { return atype<const E_BorderN *>();}
- int size() const { int k=0;for(const E_BorderN *pp=this;pp; pp=pp->next) k++; return k;}
- E_BorderN * operator+( const E_BorderN & bb) const
- { ( (void) 0);
- return new E_BorderN(bb,this);}
- long Nbseg(Stack stack) const { return GetAny<long>((*n)(stack));}
- double from(Stack stack) const ;
- double to(Stack stack) const ;
- double * var(Stack stack) const ;
- void code(Stack stack) const ;
- long label()const ;
- void Plot(Stack stack) const ;
- void SavePlot(Stack stack,PlotStream & plot ) const;
- void BoundingBox(Stack stack,double &xmin,double & xmax, double & ymin,double & ymax) const ;
-};
-class AddBorderOperator: public OneOperator{
- typedef const E_BorderN * A;
- public:
- E_F0 * code(const basicAC_F0 & args) const
- {
- A a0=dynamic_cast<A>((Expression) args[0]);
- A a1=dynamic_cast<A>((Expression) args[1]);
- ((a0 && a1) ? ( (void) 0) : throw(ErrorAssert("a0 && a1","AFunction.hpp", 1596)));
- return new E_BorderN(*a1,a0);}
- AddBorderOperator():
- OneOperator(map_type[typeid(A).name()],map_type[typeid(A).name()],map_type[typeid(A).name()])
- {pref = 0;}
-};
-class OneOperator_borderN : public OneOperator {public:
- const E_Border * theborder;
- E_F0 * code(const basicAC_F0 & a) const
- { return new E_BorderN(theborder,a[0]);}
- OneOperator_borderN(const E_Border * b)
- : OneOperator(atype<const E_BorderN *>(),atype<long>()),
- theborder(b){}
-};
-class E_Border :public Polymorphic { public:
- static basicAC_F0::name_and_type name_param[] ;
- static const int n_name_param =0;
- static long Count;
- Expression xvar,xfrom,xto,xcode;
- basicAC_F0_wa * tab;
- long label;
- E_Border(const E_Array * a) :
- xvar(0),xfrom(0),xto(0),xcode(0), tab(a? a->v:0) ,label(++Count)
- {
- (static_cast<void> (0));
- Add("(",new OneOperator_borderN(this));
- }
- E_Border(const basicAC_F0 & aa) :
- xvar(to<double*>(aa[0])),
- xfrom(to<double>(aa[1])),
- xto(to<double>(aa[2])),
- xcode(aa[3].LeftValue()),
- tab(0),
- label(++Count)
- { Add("(",new OneOperator_borderN(this));}
- AnyType operator()(Stack) const {
- return SetAny<const E_Border *>(this);}
- double length(Stack ) const { ((0) ? ( (void) 0) : throw(ErrorAssert("0","AFunction.hpp", 1640)));return 0.0; }
-};
-inline E_BorderN::E_BorderN(const E_Border *bb, C_F0 nn,const E_BorderN * nx)
- :b(bb),n(::to<long>(nn)),next(nx) { ( (void) 0);}
-inline double E_BorderN::from(Stack stack) const { return b->xfrom ? GetAny<double>((*b->xfrom)(stack)): double(0.0);}
-inline double E_BorderN::to(Stack stack) const { return b->xto? GetAny<double>((*b->xto)(stack)): b->length(stack) ;}
-inline double * E_BorderN::var(Stack stack) const { return b->xvar ? GetAny<double*>((*b->xvar)(stack)): (double*) 0 ;}
-inline void E_BorderN::code(Stack stack)const { (*b->xcode)(stack);}
-inline long E_BorderN::label()const { return b->label;}
-inline ArrayOfaType::ArrayOfaType(const basicAC_F0 & aa) : n(aa.size()),t(n ? (n<=4 ? tt : new aType[n]):0),ellipse(false) {
- for (int i=0;i<n;i++) t[i]=aa[i].left();}
-inline ArrayOfaType::ArrayOfaType(const ArrayOfaType & aa) : n(aa.n),t(n<=4?tt:new aType[n]),ellipse(aa.ellipse) {
- for (int i=0;i<n;i++) t[i]=aa.t[i];}
-inline C_F0 TableOfIdentifier::Find(const char * name) const {
- const_iterator i=m.find(name);
- if ( i == m.end()) { return C_F0();}
- else return C_F0(i->second);}
-inline C_F0 TableOfIdentifier::Find(const char * name,const basicAC_F0 & args) const {
- const_iterator i=m.find(name);
- if ( i == m.end()) {cout<<"No operator " << name<<endl;
- cout <<*this << endl;CompileError("TableOfIdentifier::Find");return C_F0();}
- else {return C_F0(C_F0(i->second),"(",args);}}
-inline size_t align8(size_t &off)
-{
- register size_t o= off %8 ;
- off += o ? 8-o : 0;
- return off;
-}
-template<class T>
-inline Type_Expr NewVariable(aType t,size_t &off)
-{
- size_t o= align8(off);
- off += t->un_ptr_type->size;
- return Type_Expr(t,new T(o,t));
-}
-template<class T>
-inline Type_Expr NewVariable(aType t,size_t &off,const basicAC_F0 &args)
-{
- size_t o= align8(off);
- off += t->un_ptr_type->size;
- return Type_Expr(t,new T(o,t,args));
-}
-template<class T,class U>
-inline Type_Expr NewVariable(aType t,size_t &off,const U & data)
-{
- size_t o= align8(off);
- off += t->un_ptr_type->size;
- return Type_Expr(t,new T(o,t,data));
-}
-template<class T>
-inline C_F0 TableOfIdentifier::NewVar(Key k,aType t,size_t & top,const C_F0 &i)
- {
- return C_F0(TheOperators,"<-",New(k,NewVariable<T>(t,top)),i);}
-template<class T>
-inline C_F0 TableOfIdentifier::NewVar(Key k,aType t,size_t & top,const basicAC_F0 &args)
- {
- return C_F0(TheOperators,"<-",basicAC_F0_wa(New(k,NewVariable<T>(t,top)),args));}
-template<class T>
-inline C_F0 TableOfIdentifier::NewFESpace(Key k,aType t,size_t & top,const basicAC_F0 &args)
- {
- return C_F0(TheOperators,"<-",basicAC_F0_wa(New(k,NewFESpace<T>(t,top,args)),args));}
-template<class T,class U>
-inline C_F0 TableOfIdentifier::NewVar(Key k,aType t,size_t & top,const basicAC_F0 &args,const U & data)
- {
- return C_F0(TheOperators,"<-",basicAC_F0_wa(New(k,NewVariable<T,U>(t,top,data)),args));}
-template<class T>
-inline C_F0 TableOfIdentifier::NewVar(Key k,aType t,size_t & top)
- { return t->Initialization(New(k,NewVariable<T>(t,top))); }
-inline C_F0 TableOfIdentifier::NewID(aType r,Key k, C_F0 & c,size_t &top, bool del )
- { New(k,(make_pair<aType, E_F0 *>(c.left(),c.LeftValue())),del);return 0; }
-inline C_F0 TableOfIdentifier::NewID(aType r,Key k, C_F0 & c,const ListOfId & l,size_t & top,bool del)
- { return r->Initialization(New(k,r->SetParam(c,&l,top),del));}
-typedef list<TableOfIdentifier *> ListOfTOfId;
- extern list<TableOfIdentifier *> tables_of_identifier;
- C_F0 Find(const char * name) ;
-inline C_F0 basicForEachType::Find(const char * k) const
- { C_F0 r( ti.Find(k));
- return r; }
-inline C_F0 basicForEachType::Find(const char * k,const basicAC_F0 & args) const {return ti.Find(k,args);}
-inline C_F0 basicForEachType::Initialization(const Type_Expr & e) const
- {
- if(!InitExp)
- {
- cout << "Internal Error: No Way to m Initialize this var type " << *this << endl;
- CompileError();
- }
- return C_F0(new E_F0_Func1(InitExp,e.second),this);
- }
-class E_comma : public E_F0 {public:
- Expression a,b;
- E_comma(Expression aa,Expression bb) : a(aa),b(bb) {}
- AnyType operator()(Stack s) const { (*a)(s); return (*b)(s);}
- bool MeshIndependent() const {
- return a->MeshIndependent() && b->MeshIndependent();}
-} ;
-inline C_F0::C_F0(const C_F0 & a,const C_F0 & b)
- {
- if (a.Empty())
- {r=b.r,f=b.f;}
- else if (b.Empty())
- {r=a.r,f=b.f;}
- else
- {r=b.r;
- f= new E_comma(a.f,b.f);}
- }
-inline C_F0::C_F0(const C_F0 & e,const char *op, AC_F0 & p)
- { *this=C_F0(e,op,(const basicAC_F0 &) p);
- p.destroy();
- }
-inline C_F0::C_F0(const Polymorphic * poly,const char *op, AC_F0 & p)
- { *this=C_F0(poly,op,(const basicAC_F0 &) p);
- p.destroy();
- }
-inline C_F0::C_F0(const C_F0 & e,const char *op,const basicAC_F0 & p)
- {
- const Polymorphic * pop=e;
- if (pop)
- {
- *this=C_F0(pop,op,p);
- }
- else {
- C_F0 x=e.r->Find(op);
- pop=x;
- if(pop)
- {
- basicAC_F0_wa ep(e,p);
- *this=C_F0(pop,"",ep);
- }
- else
- {
- cout << " unknow operator " << op << " on type " << *e.r << endl;
- CompileError();
- }}
- }
-inline C_F0::C_F0(const C_F0 & e,const char *op,const C_F0 & a,const C_F0 & b)
-{
- C_F0 tab[2]={a,b};
- basicAC_F0 p;
- p=make_pair<int,C_F0*>(2,tab);
- *this= C_F0(e,op,p);
-}
-inline C_F0::C_F0(const C_F0 & e,const char *op,const C_F0 & ee)
-{
- const Polymorphic * pop=e;
- if (pop)
- {
- *this=C_F0(pop,op,e,ee);
- }
- else {
- C_F0 x=e.r->Find(op);
- pop=x;
- if(pop)
- *this=C_F0(pop,"",e,ee);
- else
- {
- cout << " unknow operator " << op << " on type " << *e.r << " " << *ee.r<< endl;
- CompileError();
- }}
-}
-inline C_F0::C_F0(const C_F0 & e,const char *nm)
- {
- C_F0 x=e.r->Find(nm);
- const Polymorphic * pop=x;
- if (pop)
- *this=C_F0(pop,".",e);
- else
- {
- cout << " No operator ." << nm << " for type " << *e.r << endl;
- lgerror("");
- }
- }
-inline E_F0 * C_F0::LeftValue() const {
- return f;
-}
-aType TypeArray(aType,aType);
-aType TypeTemplate(aType,aType);
-aType TypeArray(aType c,aType b,aType a);
-void Init_map_type();
-class Block {
- static size_t Max(size_t a,size_t b){ return a < b ? b :a;}
- typedef const char * Key;
- Block * fatherblock;
- size_t top,topmax;
- TableOfIdentifier table;
- ListOfTOfId::iterator itabl;
- public:
- size_t OffSet(size_t ssize) {
- top=align8(top);
- size_t r=top; top+=ssize ;topmax=Max(topmax,top);
- return r;}
- Block(Block * f=0);
- size_t size() const { return Max(topmax,top);}
- void Add(Key k,Key op,OneOperator *p0)
- { table.Add(k,op,p0);}
-template<class T>
- C_F0 NewVar(Key k,aType t,const C_F0 &i)
- {return table.NewVar<T>(k, t,top,i);}
-template<class T>
- C_F0 NewFESpace(Key k,aType t,const basicAC_F0 &args)
- {return table.NewFESpace<T>(k, t,top,args);}
-template<class T>
- C_F0 NewVar(Key k,aType t, AC_F0 &args)
- {C_F0 r= table.NewVar<T>(k, t,top,args);
- args.destroy();
- topmax=Max(topmax,top);
- return r;}
-template<class T>
- C_F0 NewVar(Key k,aType t,const basicAC_F0 &args)
- {C_F0 r= table.NewVar<T>(k, t,top,args);
- topmax=Max(topmax,top);
- return r;}
-template<class T,class U>
- C_F0 NewVar(Key k,aType t,const basicAC_F0 &args,const U & data)
- {C_F0 r= table.NewVar<T,U>(k, t,top,args,data);
- topmax=Max(topmax,top);
- return r;}
-template<class T>
- C_F0 NewVar(Key k,aType t)
- {C_F0 r= table.NewVar<T>(k, t,top);
- topmax=Max(topmax,top);
- return r;
- }
- C_F0 NewID(aType t,Key k,C_F0 f,bool del=true)
- {C_F0 r= table.NewID(t,k, f,top,del);
- topmax=Max(topmax,top);
- return r;}
- C_F0 NewID(aType t,Key k,C_F0 f,const ListOfId & l,bool del=true)
- {C_F0 r= table.NewID(t,k,f,l,top,del);
- topmax=Max(topmax,top);
- return r;}
- static Block * open(Block *& c);
- CC_F0 close(Block *& c);
- C_F0 Find(const char * k) const {return table.Find(k);}
- ~Block();
-};
-template<class R,class A=R,class CODE=E_F_F0<R,A> >
-class OneOperator1 : public OneOperator {
- aType r,t0;
- typedef typename CODE::func func;
- func f;
- public:
- E_F0 * code(const basicAC_F0 & args) const
- { return new CODE(f,t0->CastTo(args[0]));}
- OneOperator1(func ff,int ppref=0):
- OneOperator(map_type[typeid(R).name()],map_type[typeid(A).name()]),
- t0( map_type[typeid(A).name()] ), f(ff) {pref=ppref;}
- OneOperator1(func ff,aType tt0,int ppref=0):
- OneOperator(map_type[typeid(R).name()],tt0),
- t0( map_type[typeid(A).name()] ), f(ff) {pref=ppref;}
-};
-template<class R,class A=R,class B=A,class CODE=E_F_F0F0<R,A,B> >
-class OneOperator2 : public OneOperator {
- aType r,t0,t1;
- typedef typename CODE::func func;
- func f;
- public:
- E_F0 * code(const basicAC_F0 & args) const
- { return new CODE(f,t0->CastTo(args[0]),t1->CastTo(args[1]));}
- OneOperator2(func ff):
- OneOperator(map_type[typeid(R).name()],map_type[typeid(A).name()],map_type[typeid(B).name()]),
- t0( map_type[typeid(A).name()] ),t1(map_type[typeid(B).name()] ), f(ff) {}
- OneOperator2(func ff,aType tt0,aType tt1):
- OneOperator(map_type[typeid(R).name()],tt0,tt1),
- t0( map_type[typeid(A).name()] ),t1(map_type[typeid(B).name()] ), f(ff) {}
-};
-template<class A,class B> struct SameType { static const int OK=0;};
-template<class A> struct SameType<A,A> { static const int OK=1;};
-template<> struct SameType<bool,bool> { static const int OK=10;};
-template<> struct SameType<long,long> { static const int OK=20;};
-template<> struct SameType<double,double> { static const int OK=30;};
-template<> struct SameType<Complex,Complex> { static const int OK=40;};
-template<> struct SameType<string*,string*> { static const int OK=50;};
-template <typename Arg1, typename Arg2,typename Arg3, class Result>
-struct ternary_function
-{
- typedef Arg1 first_argument_type;
- typedef Arg2 second_argument_type;
- typedef Arg3 third_argument_type;
- typedef Result result_type;
-};
-template <typename Arg1, typename Arg2,typename Arg3,typename Arg4 , class Result>
-struct quad_function
-{
- typedef Arg1 first_argument_type;
- typedef Arg2 second_argument_type;
- typedef Arg3 third_argument_type;
- typedef Arg4 fourth_argument_type;
- typedef Result result_type;
-};
-template<typename T,class CODE >
-class OneTernaryOperator : public OneOperator{
- typedef typename T::result_type R;
- typedef typename T::first_argument_type A;
- typedef typename T::second_argument_type B;
- typedef typename T::third_argument_type C;
- class Op : public E_F0 {
- typedef typename C::result_type Result;
- Expression a,b,c;
- public:
- AnyType operator()(Stack s) const
- {return SetAny<R>(static_cast<R>(C::f( GetAny<A>((*a)(s)) ,
- GetAny<B>((*b)(s)) ,
- GetAny<C>((*c)(s)))));}
- Op(Expression aa,Expression bb,Expression cc) : a(aa),b(bb),c(cc) {}
- bool MeshIndependent() const {
- return a->MeshIndependent() && b->MeshIndependent() && c->MeshIndependent();}
- };
- public:
- E_F0 * code(const basicAC_F0 & args) const
- { return new CODE(t[0]->CastTo(args[0]),t[1]->CastTo(args[1]),t[2]->CastTo(args[2]));}
- OneTernaryOperator():
- OneOperator(map_type[typeid(R).name()],
- map_type[typeid(A).name()],
- map_type[typeid(B).name()],
- map_type[typeid(C).name()]) {}
-};
-template<typename T,class CODE >
-class OneQuadOperator : public OneOperator{
- typedef typename T::result_type R;
- typedef typename T::first_argument_type A;
- typedef typename T::second_argument_type B;
- typedef typename T::third_argument_type C;
- typedef typename T::fourth_argument_type D;
- class Op : public E_F0 {
- typedef typename C::result_type Result;
- Expression a,b,c,d;
- public:
- AnyType operator()(Stack s) const
- {return SetAny<R>(static_cast<R>(T::f( GetAny<A>((*a)(s)) ,
- GetAny<B>((*b)(s)) ,
- GetAny<C>((*c)(s)),
- GetAny<D>((*d)(s))
- )));}
- Op(Expression aa,Expression bb,Expression cc,Expression dd) : a(aa),b(bb),c(cc),d(dd) {}
- bool MeshIndependent() const {
- return a->MeshIndependent() && b->MeshIndependent() && c->MeshIndependent() && d->MeshIndependent();}
- };
-public:
- E_F0 * code(const basicAC_F0 & args) const
- { return new CODE(t[0]->CastTo(args[0]),t[1]->CastTo(args[1]),t[2]->CastTo(args[2]),t[3]->CastTo(args[3]));}
- OneQuadOperator():
- OneOperator(map_type[typeid(R).name()],
- map_type[typeid(A).name()],
- map_type[typeid(B).name()],
- map_type[typeid(C).name()],
- map_type[typeid(D).name()]
- ) {}
-};
-template<typename T >
-class OneTernaryOperator3 : public OneOperator{
- typedef typename T::result_type R;
- typedef typename T::first_argument_type A;
- typedef typename T::second_argument_type B;
- typedef typename T::third_argument_type C;
- class Op : public E_F0 {
- Expression a,b,c;
- public:
- AnyType operator()(Stack s) const
- {return SetAny<R>(static_cast<R>(T::f( s, GetAny<A>((*a)(s)) ,
- GetAny<B>((*b)(s)) ,
- GetAny<C>((*c)(s)))));}
- Op(Expression aa,Expression bb,Expression cc) : a(aa),b(bb),c(cc) {}
- bool MeshIndependent() const { return a->MeshIndependent() && b->MeshIndependent() && c->MeshIndependent();}
- };
- public:
- E_F0 * code(const basicAC_F0 & args) const
- { return new Op(t[0]->CastTo(args[0]),t[1]->CastTo(args[1]),t[2]->CastTo(args[2]));}
- OneTernaryOperator3():
- OneOperator(map_type[typeid(R).name()],
- map_type[typeid(A).name()],
- map_type[typeid(B).name()],
- map_type[typeid(C).name()]) {}
-};
-struct OneBinaryOperatorMI {
- static bool MeshIndependent(Expression a,Expression b) { return a->MeshIndependent() && b->MeshIndependent();}
- static bool ReadOnly() { return true;}
-};
-struct OneBinaryOperatorMIWO {
- static bool MeshIndependent(Expression a,Expression b) { return a->MeshIndependent() && b->MeshIndependent();}
- static bool ReadOnly() { return false;}
-};
-template<typename C,class MI=OneBinaryOperatorMI>
-class OneBinaryOperator_st : public OneOperator{
- typedef typename C::result_type R;
- typedef typename C::first_argument_type A;
- typedef typename C::second_argument_type B;
- aType t0,t1;
- class Op : public E_F0 {
- typedef typename C::result_type Result;
- Expression a,b;
- public:
- AnyType operator()(Stack s) const
- {return SetAny<R>(static_cast<R>(C::f(s, GetAny<A>((*a)(s)) , GetAny<B>((*b)(s)))));}
- Op(Expression aa,Expression bb) : a(aa),b(bb) {}
- bool MeshIndependent() const { return MI::MeshIndependent(a,b);}
- bool ReadOnly() const { return MI::ReadOnly() ;}
- int Optimize(deque<pair<Expression,int> > &l,MapOfE_F0 & m, size_t & n)
- {
- int rr = find(m);
- if (rr) return rr;
- int Opa = a->Optimize(l,m,n);
- int Opb =b->Optimize(l,m,n);
- return insert(new Opt(*this,Opa,Opb),l,m,n);
- }
- int compare (const E_F0 *t) const {
- int rr;
- const Op * tt=dynamic_cast<const Op *>(t);
- if (tt ) rr = clexico(a->compare(tt->a),b->compare(tt->b));
- else rr = E_F0::compare(t);
- return rr;
- }
- virtual ostream & dump(ostream &f) const {
- f << "Op<" << typeid(C).name()
- << "> \n\t\t\t( a= "<< *a<< ") \n\t\t\t(b= "<< *b << ") " ;
- return f; }
- };
- class Opt: public Op { public :
- size_t ia,ib;
- Opt(const Op &t,size_t iaa,size_t ibb)
- : Op(t) ,
- ia(iaa),ib(ibb) {}
- AnyType operator()(Stack s) const
- {
- return SetAny<R>( C::f(s, *static_cast<A *>(static_cast<void*>(static_cast<char *>(s)+ia)) ,
- *static_cast<B *>(static_cast<void*>(static_cast<char *>(s)+ib)) ) );}
- };
-public:
- E_F0 * code(const basicAC_F0 & args) const
- {
- return new Op(t0->CastTo(args[0]),t1->CastTo(args[1]));}
- OneBinaryOperator_st():
- OneOperator(map_type[typeid(R).name()],map_type[typeid(A).name()],map_type[typeid(B).name()]),
- t0(t[0]),
- t1(t[1])
- {pref = SameType<A,B>::OK ;}
- OneBinaryOperator_st(aType tt0,aType tt1):
- OneOperator(map_type[typeid(R).name()],
- tt0 ? tt0 : map_type[typeid(A).name()] ,
- tt1 ? tt1 : map_type[typeid(B).name()]),
- t0(map_type[typeid(A).name()]),
- t1(map_type[typeid(B).name()])
- {pref = SameType<A,B>::OK ;}
-};
-struct evalE_F2 {
- static AnyType eval(Stack s,const E_F0 * ab,const E_F0 * a,const E_F0 * b, bool & meshidenp)
- {
- return ab->E_F0::eval(s,meshidenp);
- }
-};
-template<typename C,class MI=OneBinaryOperatorMI,class MIx=evalE_F2 >
-class OneBinaryOperator : public OneOperator{
- typedef typename C::result_type R;
- typedef typename C::first_argument_type A;
- typedef typename C::second_argument_type B;
- aType t0,t1;
- class Op : public E_F0 {
- typedef typename C::first_argument_type A;
- typedef typename C::second_argument_type B;
- typedef typename C::result_type Result;
- Expression a,b;
- public:
- AnyType operator()(Stack s) const
- {return SetAny<R>(static_cast<R>(C::f( GetAny<A>((*a)(s)) , GetAny<B>((*b)(s)))));}
- AnyType eval(Stack s, bool & meshidenp) const
- {return MIx::eval(s,this,a,b,meshidenp);}
- Op(Expression aa,Expression bb) : a(aa),b(bb) {}
- bool MeshIndependent() const { return MI::MeshIndependent(a,b);}
- bool ReadOnly() const { return MI::ReadOnly() ;}
- int Optimize(deque<pair<Expression,int> > &l,MapOfE_F0 & m, size_t & n)
- {
- int rr = find(m);
- if (rr) return rr;
- int Opa = a->Optimize(l,m,n);
- int Opb =b->Optimize(l,m,n);
- return insert(new Opt(*this,Opa,Opb),l,m,n);
- }
- int compare (const E_F0 *t) const {
- int rr;
- const Op * tt=dynamic_cast<const Op *>(t);
- if (tt ) rr = clexico(a->compare(tt->a),b->compare(tt->b));
- else rr = E_F0::compare(t);
- return rr;
- }
- virtual ostream & dump(ostream &f) const {
- f << "Op<" << typeid(C).name()
- << "> \n\t\t\t( a= "<< *a<< ") \n\t\t\t(b= "<< *b << ") " ;
- return f; }
- };
- class Opt: public Op { public :
- size_t ia,ib;
- Opt(const Op &t,size_t iaa,size_t ibb)
- : Op(t) ,
- ia(iaa),ib(ibb) {}
- AnyType operator()(Stack s) const
- {
- return SetAny<R>( C::f( *static_cast<A *>(static_cast<void*>(static_cast<char *>(s)+ia)) ,
- *static_cast<B *>(static_cast<void*>(static_cast<char *>(s)+ib)) ) );}
- };
-public:
- E_F0 * code(const basicAC_F0 & args) const
- {
- if ( args.named_parameter && !args.named_parameter->empty() )
- CompileError( " They are used Named parameter ");
- return new Op(t0->CastTo(args[0]),t1->CastTo(args[1]));}
- OneBinaryOperator():
- OneOperator(map_type[typeid(R).name()],map_type[typeid(A).name()],map_type[typeid(B).name()]),
- t0(t[0]),
- t1(t[1])
- {pref = SameType<A,B>::OK ;}
- OneBinaryOperator(aType tt0,aType tt1):
- OneOperator(map_type[typeid(R).name()],
- tt0 ? tt0 : map_type[typeid(A).name()] ,
- tt1 ? tt1 : map_type[typeid(B).name()]),
- t0(map_type[typeid(A).name()]),
- t1(map_type[typeid(B).name()])
- {pref = SameType<A,B>::OK ;}
-};
-template<typename R>
-class Operator_Aritm_If : public OneOperator{
- typedef bool A;
- typedef R B;
- typedef R C;
- class Op : public E_F0 {
- typedef R Result;
- Expression a,b,c;
- public:
- AnyType operator()(Stack s) const
- {
- return SetAny<R>(static_cast<R>( GetAny<bool>((*a)(s)) ? GetAny<B>((*b)(s)) : GetAny<C>((*c)(s)) ));
- }
- Op(Expression aa,Expression bb,Expression cc) : a(aa),b(bb),c(cc){}
- bool MeshIndependent() const { return a->MeshIndependent() && b->MeshIndependent() &&b->MeshIndependent() ;}
- int Optimize(deque<pair<Expression,int> > &l,MapOfE_F0 & m, size_t & n)
- {
- int rr = find(m);
- if (rr) return rr;
- int Opa = a->Optimize(l,m,n);
- int Opb =b->Optimize(l,m,n);
- int Opc =c->Optimize(l,m,n);
- return insert(new Opt(*this,Opa,Opb,Opc),l,m,n);
- }
- int compare (const E_F0 *t) const {
- int rr;
- const Op * tt=dynamic_cast<const Op *>(t);
- if (tt ) rr = clexico(a->compare(tt->a),b->compare(tt->b),c->compare(tt->c));
- else rr = E_F0::compare(t);
- return rr;
- }
- virtual ostream & dump(ostream &f) const {
- f << "Op<" << typeid(C).name()
- << "> \n\t\t\t( a= "<< *a<< ") \n\t\t\t(b= "<< *b << ") " ;
- return f; }
- };
- class Opt: public Op { public :
- size_t ia,ib,ic;
- Opt(const Op &t,size_t iaa,size_t ibb,size_t icc)
- : Op(t) ,
- ia(iaa),ib(ibb),ic(icc) {}
- AnyType operator()(Stack s) const
- {
- return SetAny<R>(
- static_cast<R> (
- *static_cast<bool *>(static_cast<void*>(static_cast<char *>(s)+ia)) ?
- *static_cast<B *>(static_cast<void*>(static_cast<char *>(s)+ib)) :
- *static_cast<C *>(static_cast<void*>(static_cast<char *>(s)+ic)) ) );}
- };
-public:
- E_F0 * code(const basicAC_F0 & args) const
- {
- if ( args.named_parameter && !args.named_parameter->empty() )
- CompileError( " They are used Named parameter ");
- return new Op(t[0]->CastTo(args[0]),t[1]->CastTo(args[1]),t[2]->CastTo(args[2]));}
- Operator_Aritm_If():
- OneOperator(map_type[typeid(R).name()],map_type[typeid(bool).name()],map_type[typeid(B).name()],map_type[typeid(B).name()])
- {pref = SameType<B,B>::OK ;}
-};
-template<class C>
-class Unary_Op : public E_F0 { public:
- typedef typename C::result_type R;
- typedef typename C::argument_type A;
- Expression a;
- public:
- AnyType operator()(Stack s) const
- { return SetAny<R>( C::f(GetAny<A>((*a)(s)))) ;}
- Unary_Op(Expression aa) : a(aa) {}
- int compare (const E_F0 *t) const {
- int rr;
- const Unary_Op * tt=dynamic_cast<const Unary_Op *>(t);
- if (tt) rr = a->compare(tt->a);
- else rr = E_F0::compare(t);
- return rr;
- }
- bool EvaluableWithOutStack() const {return a->EvaluableWithOutStack();}
- bool MeshIndependent() const {return a->MeshIndependent();}
- virtual ostream & dump(ostream &f) const {
- f << "Op1<" << typeid(C).name()
- << "> \n\t\t\t( a= "<< *a<< ") " ;
- return f; }
- };
-template<class C,class Op=Unary_Op<C> >
-class OneUnaryOperator : public OneOperator{
- typedef typename C::result_type R;
- typedef typename C::argument_type A;
- aType tA;
- public:
- E_F0 * code(const basicAC_F0 & args) const
- { if ( args.named_parameter && !args.named_parameter->empty() )
- CompileError( " They are used Named parameter ");
- return new Op(tA->CastTo(args[0]));}
- OneUnaryOperator(aType tt0=map_type[typeid(A).name()]):
- OneOperator(map_type[typeid(R).name()],tt0),
- tA(map_type[typeid(A).name()])
- {}
-};
-template<class R,class A=R>
-class OneOperator1s_ : public OneOperator {
- aType r;
- typedef R (*func)(Stack stack, const A &) ;
- func f;
- public:
- E_F0 * code(const basicAC_F0 & args) const
- { if ( args.named_parameter && !args.named_parameter->empty() )
- CompileError( " They are used Named parameter ");
- return new E_F_F0s_<R,A>(f,t[0]->CastTo(args[0]));}
- OneOperator1s_(func ff):
- OneOperator(map_type[typeid(R).name()],map_type[typeid(A).name()]),f(ff){}
-};
-template<class R,class A=R,class CODE=E_F_F0_<R,A> >
-class OneOperator1_ : public OneOperator {
- aType r,t0;
- typedef R (*func)(const A &) ;
- func f;
- public:
- E_F0 * code(const basicAC_F0 & args) const
- {
- if ( args.named_parameter && !args.named_parameter->empty() )
- CompileError( " They are used Named parameter ");
- return new CODE(f,t[0]->CastTo(args[0]));}
- OneOperator1_(func ff,int ppref=0):
- OneOperator(map_type[typeid(R).name()],map_type[typeid(A).name()]),t0( map_type[typeid(A).name()] ),f(ff){pref=ppref;}
- OneOperator1_(func ff,aType tt0,int ppref=0):
- OneOperator(map_type[typeid(R).name()],tt0),
- t0( map_type[typeid(A).name()]), f(ff) {pref=ppref;}
-};
-template<class R,class A,class B,class E> class E_F_F0F0_;
-template<class R,class A=R,class B=A,class CODE=E_F_F0F0_<R,A,B,E_F0> >
-class OneOperator2_ : public OneOperator {
- aType r,t0,t1;
- typedef typename CODE::func func;
- func f;
- public:
- E_F0 * code(const basicAC_F0 & args) const
- {
- if ( args.named_parameter && !args.named_parameter->empty() )
- CompileError( " They are used Named parameter ");
- return new CODE(f,t0->CastTo(args[0]),t1->CastTo(args[1]));}
- OneOperator2_(func ff):
- OneOperator(map_type[typeid(R).name()],map_type[typeid(A).name()],map_type[typeid(B).name()]),
- t0( map_type[typeid(A).name()] ),t1(map_type[typeid(B).name()] ), f(ff) {}
- OneOperator2_(int ppref,func ff):
- OneOperator(map_type[typeid(R).name()],map_type[typeid(A).name()],map_type[typeid(B).name()]),
- t0( map_type[typeid(A).name()] ),t1(map_type[typeid(B).name()] ), f(ff) {pref=ppref;}
- OneOperator2_(func ff,aType tt0,aType tt1):
- OneOperator(map_type[typeid(R).name()],tt0,tt1),
- t0( map_type[typeid(A).name()] ),t1(map_type[typeid(B).name()] ), f(ff) {}
-};
-template<class R,class A=R,class B=A,class C=B,class CODE=E_F_F0F0F0_<R,A,B,C,E_F0> >
-class OneOperator3_ : public OneOperator {
- aType tA,tB,tC;
- typedef typename CODE::func func;
- func f;
- public:
- E_F0 * code(const basicAC_F0 & args) const
- {
- if ( args.named_parameter && !args.named_parameter->empty() )
- CompileError( " They are used Named parameter ");
- return new CODE(f,tA->CastTo(args[0]),tB->CastTo(args[1]),tC->CastTo(args[2]));}
- OneOperator3_(func ff,
- aType tt0=map_type[typeid(A).name()],
- aType tt1=map_type[typeid(B).name()],
- aType tt2=map_type[typeid(C).name()])
- : OneOperator(map_type[typeid(R).name()],tt0,tt1,tt2),
- tA(map_type[typeid(A).name()]),
- tB(map_type[typeid(B).name()]),
- tC(map_type[typeid(C).name()]),
- f(ff){}
-};
-template<class CODE,int ppref=0>
-class OneOperatorCode : public OneOperator {
- public:
- E_F0 * code(const basicAC_F0 & args) const { return CODE::f(args);}
- OneOperatorCode(): OneOperator(atype<typename CODE::Result>(),CODE::typeargs()) {pref=ppref;}
- OneOperatorCode(aType rr,const ArrayOfaType & l): OneOperator(rr,l) {pref=ppref;}
- OneOperatorCode(aType rr,aType a): OneOperator(rr,a) {pref=ppref;}
- OneOperatorCode(aType rr,aType a,aType b): OneOperator(rr,a,b) {pref=ppref;}
- OneOperatorCode(aType rr,aType a,aType b,aType c): OneOperator(rr,a,b,c) {pref=ppref;}
-};
-template<class A,class B> struct binary_trait{ typedef A R ;};
-template<> struct binary_trait<int,double> { typedef double R;};
-template<> struct binary_trait<long,double> { typedef double R;};
-template<> struct binary_trait<int,complex<double> > { typedef complex<double> R;};
-template<> struct binary_trait<long,complex<double> > { typedef complex<double> R;};
-template<> struct binary_trait<double,complex<double> > { typedef complex<double> R ;};
-template<class A> struct binary_trait<A,string* > { typedef string* R ;};
-template<class T,class PT>
- ForEachTypePtr<T,PT>::ForEachTypePtr():
- basicForEachType(typeid(PT),sizeof(PT),
- new E_F1_funcT_Type(atype<T>(),this,UnRef<T,PT>),atype<T>(),
- ::Initialize<T>,::Delete<T>){}
-template<class T,class PT>
- ForEachTypePtr<T,PT>::ForEachTypePtr(Function1 init,Function1 dl,Function1 onreturn):
- basicForEachType(typeid(PT),sizeof(PT),
- new E_F1_funcT_Type(atype<T>(),this,UnRef<T,PT>),atype<T>(),
- init,
- dl , onreturn ){}
-template<class T,class PT>
- ForEachTypePtr<T,PT>::ForEachTypePtr(Function1 dl):
- basicForEachType(typeid(PT),sizeof(PT),
- new E_F1_funcT_Type(atype<T>(),this,UnRef<T,PT>),atype<T>(),
- ::Initialize<T>,dl){}
-template<class T>
- ForEachTypePtr<T*,T**>::ForEachTypePtr(T* unused,Function1 OOnReturn):
- basicForEachType(typeid(T**),sizeof(T**),
- new E_F1_funcT_Type(atype<T*>(),this,UnRef<T*>),atype<T*>(),
- ::InitializePtr<T*>,::DestroyPtr<T*>,OOnReturn){}
-template<class T>
- ForEachTypePtr<T*,T**>::ForEachTypePtr(Function1 init,Function1 dl,Function1 onreturn):
- basicForEachType(typeid(T**),sizeof(T**),
- new E_F1_funcT_Type(atype<T*>(),this,UnRef<T*>),atype<T*>(),
- init ,
- dl ,
- onreturn){}
-template<class T>
- ForEachTypePtr<T*,T**>::ForEachTypePtr(Function1 dl):
- basicForEachType(typeid(T**),sizeof(T**),
- new E_F1_funcT_Type(atype<T*>(),this,UnRef<T*>),atype<T*>(),
- ::InitializePtr<T*>,dl){}
-inline C_F0 & operator+=(C_F0 & a,C_F0 &b)
-{
- C_F0 r = C_F0(TheOperators,"+",a,b);
- a=r;
- return a;
-}
-template<typename T,typename PT>
-void Dcl_TypeandPtr_ (Function1 i,Function1 d,Function1 pi,Function1 pd,Function1 OnReturn=0,Function1 pOnReturn=0)
- {
- map_type[typeid(T).name()] = new ForEachType<T>(i,d,OnReturn);
- map_type[typeid(PT).name()] = new ForEachTypePtr<T,PT>(pi,pd,pOnReturn);
- }
-template<class T>
-void Dcl_TypeandPtr (Function1 i,Function1 d,Function1 pi,Function1 pd,Function1 OnReturn=0,Function1 pOnReturn=0)
-{
-map_type[typeid(T).name()] = new ForEachType<T>(i,d,OnReturn);
-map_type[typeid(T*).name()] = new ForEachTypePtr<T>(pi,pd,pOnReturn);
-}
-template<class T>
- void Dcl_TypeandPtr (Function1 pi,Function1 pd)
- {
- map_type[typeid(T).name()] = new ForEachType<T>();
- map_type[typeid(T*).name()] = new ForEachTypePtr<T>(pi,pd);
- }
-template<class T>
- void Dcl_TypeandPtr (Function1 pd)
- {
- map_type[typeid(T).name()] = new ForEachType<T>();
- map_type[typeid(T*).name()] = new ForEachTypePtr<T>(pd);
- }
-template<class T>
- void Dcl_TypeandPtr ()
- {
- map_type[typeid(T).name()] = new ForEachType<T>();
- map_type[typeid(T*).name()] = new ForEachTypePtr<T>();
- }
-template<class T>
- aType Dcl_Type (Function1 iv=0,Function1 id=0,Function1 Onreturn=0)
- {
- if (sizeof(T) >sizeof(AnyData)) {
- cout << " the type " << typeid(T).name() << " is too large " << sizeof(AnyData) << endl;
- ( (void) 0);}
- return map_type[typeid(T).name()] = new ForEachType<T>(iv,id,Onreturn);
- }
-template<class T>
- void Add(const char * k,const char * op,OneOperator *p0,OneOperator *p1=0,
- OneOperator *p2=0,OneOperator *p3=0,OneOperator *p4=0,
- OneOperator *p5=0,OneOperator *p6=0)
- {atype<T>()->Add(k,op,p0,p1,p2,p3,p4,p5,p6);}
-inline C_F0 operator *(const C_F0 &a,const C_F0 &b)
-{
- return a==*pOne ? b : ( b ==*pOne ? a : C_F0(TheOperators,"*",a,b)) ;}
-inline C_F0 &operator +=(C_F0 &a,const C_F0 &b)
-{
- C_F0 r=C_F0(TheOperators,"+",a,b);
- a=r;
- return a;}
-inline void CC_F0::operator=(const CListOfInst& c)
- { C_F0 cc=c;f=cc.f;r=cc.r;}
-inline CListOfInst & CListOfInst::operator+=(const CC_F0 & a)
- { if( !a.Empty()){ f->Add(a);r=a.left();};return *this;}
-inline Type_Expr basicForEachType::SetParam(const C_F0 & ,const ListOfId * ,size_t & ) const
- { cout << " int basicForEachType " << name() << endl;
- throw(ErrorInternal("basicForEachType::SetParam non defined",2757,"AFunction.hpp")); }
-inline bool basicForEachType::CastingFrom(aType t) const {
- ( (void) 0);
- if ( t == this) return true;
- return casting->FindSameR(ArrayOfaType(t,false));
- }
-inline void CerrCast(const pair<const basicForEachType*,const E_F1_funcT_Type *> & i)
-{
- cout << "\t" << *i.first << ":" << i.second << endl;
-}
-inline C_F0 basicForEachType::CastTo(const C_F0 & e) const
-{
- ( (void) 0);
- aType t = e.left();
- if (this== t) return e;
- C_F0 ce=e;
- basicAC_F0 at;
- at=ce;
- OneOperator * opcast =casting->FindSameR(ArrayOfaType(t,false));
- if ( opcast )
- if ( *opcast == at )
- return C_F0(opcast->code(at),this);
- else {
- aType tr = e.right();
- ce = C_F0(e.RightValue(),tr);
- at = ce;
- return C_F0(opcast->code(at),this); }
- else
- { cout << "Impossible to cast " << *e.left() << " in " << *this << endl;
- if (casting) casting->Show(cout) ;
- CompileError();}
- return C_F0();
-}
-class E_F1_funcT_Type: public OneOperator{ public:
- Function1 f;
- E_F0 * code(const basicAC_F0 & args) const {
- if ( args.named_parameter && !args.named_parameter->empty() )
- CompileError( " They are used Named parameter ");
- return new E_F0_Func1(f,args[0]);}
- E_F1_funcT_Type(const basicForEachType *rr,const basicForEachType *aa,Function1 ff)
- : OneOperator(rr,aa), f(ff) {}
-};
-template<class R,class A>
-class E_F1_funcT :public E_F1_funcT_Type{ public:
- E_F1_funcT(Function1 ff) : E_F1_funcT_Type(map_type[typeid(R).name()],map_type[typeid(A).name()],ff){}
- E_F1_funcT(aType rr,aType a,Function1 ff) : E_F1_funcT_Type(rr,a,ff){}
-};
-inline Expression basicForEachType::RightValueExpr(Expression f) const
-{
- if (un_ptr) return new E_F0_Func1(un_ptr->f,f);
- else return f;
-}
-inline void CompileError(string msg,aType r){
- string m= r ? msg + " type: " + r->name() : msg ;
- lgerror(m.c_str());
- }
- inline void ExecError(string msg){
- throw(ErrorExec(msg.c_str(),1));
- }
-const Function1 NotReturnOfthisType = reinterpret_cast<Function1>(1);
-inline Expression basicForEachType::OnReturn(Expression f) const {
- if(!DoOnReturn) return f;
- else if(DoOnReturn== NotReturnOfthisType )
- CompileError("Problem when returning this type (sorry work in progress FH!) ", this);
- else return new E_F0_Func1(DoOnReturn,f);
- return 0;
-}
-inline void CC_F0::operator=(const AC_F0& a) { f=new E_Array(a); r= atype<E_Array>();};
-inline UnId::UnId(const char * idd,const C_F0 & ee,aType rr=0,bool reff=false)
- :id(idd),r(rr),e(ee),array(0),re(ee.left()) ,ref(reff){}
-class E_exception : public exception { public:
- enum CODE_exception { UNKNOWN,e_break,e_continue,e_return} ;
- CODE_exception code;
- AnyType r;
- public:
- E_exception(CODE_exception c,AnyType rr=Nothing) : code(c),r(rr) {}
- const int type() {return code;}
- virtual const char * what() const throw() { return "E_exception (break,continue or return) "; }
- ~E_exception() throw() {}
-};
-class E_throw : public E_F0mps { public:
- E_exception::CODE_exception kind;
- Expression ret;
- E_throw(E_exception::CODE_exception c,Expression e=0) :kind(c),ret(e) {}
- AnyType operator()(Stack s) const {
- (ret ? throw(E_exception(kind,(*ret)(s)))
- : throw(E_exception(kind)));
- return Nothing; }
- operator aType () const { return atype<void>();}
- } ;
-class E_block : public E_F0mps { public:
- const int n;
- Expression * code;
- int * linenumber;
- Expression clean;
- E_block(CListOfInst l,C_F0 c)
- : n(l.size()),code(l.ptr()),linenumber(l.nlines()),clean(c) {}
- E_block( C_F0 l,C_F0 c)
- : n(1),code(new Expression),clean(c) { code[0]=l;}
- AnyType operator()(Stack s) const ;
- operator aType () const { return atype<void>();}
-};
-class Routine;
-class E_Routine : public E_F0mps { public:
- Expression code;
- Expression clean;
- aType rt;
- int nbparam;
- Expression * param;
- const char * name;
- E_Routine(const Routine * routine,const basicAC_F0 & args);
- AnyType operator()(Stack s) const;
- ~E_Routine() ;
- private:
- E_Routine(const E_Routine &);
- void operator=(const E_Routine &);
- operator aType () const{ return rt;}
-};
-class Routine: public OneOperator{ public:
- size_t offset;
- aType tfunc,tret;
- const char * name;
- const ListOfId param;
- Block * currentblock;
- Expression ins;
- Expression clean;
- E_F0 * code(const basicAC_F0 & args) const ;
- Routine(aType tf,aType tr,const char * iden, ListOfId *l,Block * & cb);
- Block * Set(C_F0 instr) ;
-};
-class TypeLineFunction: public ForEachType<C_F0> {
- public:
- TypeLineFunction() : ForEachType<C_F0>(0,0) {}
- void SetArgs(const ListOfId *lid) const {
- if (lid) CompileError("No Argument in line function");
- }
- Type_Expr SetParam(const C_F0 & c,const ListOfId *l,size_t & top) const
- { return Type_Expr(c.left(),c.LeftValue()); }
- C_F0 Initialization(const Type_Expr & ) const
- { return C_F0(); }
-};
-class E_F0_Optimize : public E_F0 {
- deque<pair<Expression,int> > l;
- MapOfE_F0 m;
- int NBbitem;
- int ret;
-public:
- E_F0_Optimize(deque<pair<Expression,int> > &ll,MapOfE_F0 & mm,int rett) :
- l(ll),m(mm),NBbitem(1),ret(rett) {}
- int sizevar() const {return l.size();}
- AnyType eval(Stack s,int notinit,bool * unvar) const {
- int k= l.size(),kk=0;
- if(notinit ==0)
- {
- for (int i=0;i<k;i++)
- { size_t offset = l[i].second;
- unvar[i]=true;
- *Stack_offset<AnyType>(s,offset) = l[i].first->eval(s, unvar[i]);
- if( unvar[i]) kk++;
- }
- if (verbosity/100 && verbosity % 10 == 2)
- cout << "E_F0_Optimize nb MI exp: " << kk << " / " << k << endl;
- }
- else
- for (int i=0;i<k;i++)
- { size_t offset = l[i].second;
- if(!unvar[i])
- *Stack_offset<AnyType>(s,offset) = (*l[i].first)(s);
- }
- return *Stack_offset<AnyType>(s,ret);
- }
- virtual AnyType operator()(Stack s) const {
- int k= l.size();
- for (int i=0;i<k;i++)
- { size_t offset = l[i].second;
- *Stack_offset<AnyType>(s,offset) = (*l[i].first)(s);
- }
- return *Stack_offset<AnyType>(s,ret);
- }
- virtual bool Empty() const {return l.size(); }
- virtual size_t nbitem() const { return NBbitem;}
- virtual bool EvaluableWithOutStack() const {return false;}
- virtual bool MeshIndependent() const {return false;}
- virtual E_F0 * right_E_F0() const { return 0;}
- virtual ~E_F0_Optimize() {}
- virtual operator aType () const { return *(l.back().first);}
-};
-inline int E_F0::find(const MapOfE_F0 & m) {
- MapOfE_F0::const_iterator i= m.find(this);
- if(i != m.end()) {
- if( (verbosity / 100)% 10 == 1)
- {
- cout << "\n find : ";
- cout << i->second << " mi=" ;
- cout << MeshIndependent() << " " ;
- cout << typeid(*this).name() ;
- cout << " cmp = " << compare(i->first) ;
- cout << " " << i->first->compare(this) << " ";
- dump(cout);
- }
- (static_cast<void> (0));
- }
- return i == m.end() ? 0 : i->second ;
- }
- inline int E_F0::insert(Expression opt,deque<pair<Expression,int> > &l,MapOfE_F0 & m, size_t & n)
- {
- int rr=align8(n);
- pair<Expression,int> p(this,rr);
- if( (verbosity / 100)% 10 == 1)
- cout << " -- insert opt " << n << " " << *this << endl;
- n += sizeof(AnyType);
- l.push_back(make_pair<Expression,int>(opt,rr));
- m.insert(p);
- return rr;
- }
-extern queue<pair<const E_Routine*,int> > debugstack;
-struct NothingType {
- NothingType() {};
-};
-extern basicForEachType * typevarreal, * typevarcomplex;
-void initArrayOperators();
-void initArrayDCL();
- void ClearMem();
-inline C_F0 OneOperator::code2(const basicAC_F0 &a) const {return C_F0(code(a),r);}
-template<class R>
-class OneOperator0 : public OneOperator {public:
- class E_F0_F :public E_F0 { public:
- typedef R (*func)( ) ;
- func f;
- E_F0_F(func ff) : f(ff) {}
- AnyType operator()(Stack ) const {return SetAny<R>( f()) ;}
- operator aType () const { return atype<R>();}
- };
- typedef R (*func)() ;
- func f;
-public:
- E_F0 * code(const basicAC_F0 & args) const
- {
- if ( args.named_parameter && !args.named_parameter->empty() )
- CompileError( " They are used Named parameter ");
- return new E_F0_F(f);}
- OneOperator0(func ff): OneOperator(map_type[typeid(R).name()]),f(ff){}
-};
-template<class R >
-Type_Expr CVariable(R (*ff)() )
-{
- ( (void) 0);
- return make_pair(map_type[typeid(R).name()],new typename OneOperator0<R>::E_F0_F(ff));
-}
-namespace std
-{
- using ::va_list;
-}
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- template<typename _Tp, typename _Sequence = deque<_Tp> >
- class stack
- {
- typedef typename _Sequence::value_type _Sequence_value_type;
- template<typename _Tp1, typename _Seq1>
- friend bool
- operator==(const stack<_Tp1, _Seq1>&, const stack<_Tp1, _Seq1>&);
- template<typename _Tp1, typename _Seq1>
- friend bool
- operator<(const stack<_Tp1, _Seq1>&, const stack<_Tp1, _Seq1>&);
- public:
- typedef typename _Sequence::value_type value_type;
- typedef typename _Sequence::reference reference;
- typedef typename _Sequence::const_reference const_reference;
- typedef typename _Sequence::size_type size_type;
- typedef _Sequence container_type;
- protected:
- _Sequence c;
- public:
- explicit
- stack(const _Sequence& __c = _Sequence())
- : c(__c) { }
- bool
- empty() const
- { return c.empty(); }
- size_type
- size() const
- { return c.size(); }
- reference
- top()
- {
- ;
- return c.back();
- }
- const_reference
- top() const
- {
- ;
- return c.back();
- }
- void
- push(const value_type& __x)
- { c.push_back(__x); }
- void
- pop()
- {
- ;
- c.pop_back();
- }
- };
- template<typename _Tp, typename _Seq>
- inline bool
- operator==(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
- { return __x.c == __y.c; }
- template<typename _Tp, typename _Seq>
- inline bool
- operator<(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
- { return __x.c < __y.c; }
- template<typename _Tp, typename _Seq>
- inline bool
- operator!=(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
- { return !(__x == __y); }
- template<typename _Tp, typename _Seq>
- inline bool
- operator>(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
- { return __y < __x; }
- template<typename _Tp, typename _Seq>
- inline bool
- operator<=(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
- { return !(__y < __x); }
- template<typename _Tp, typename _Seq>
- inline bool
- operator>=(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
- { return !(__x < __y); }
-}
-typedef std::list<std::string> OneEnvironmentData;
-typedef std::map<std::string,OneEnvironmentData > EnvironmentData;
-extern EnvironmentData ffenvironment;
-extern long verbosity;
-bool EnvironmentInsert(std::string key,std::string item,std::string before);
-void GetEnvironment();
-void EnvironmentLoad();
-extern bool lexdebug;
-extern long mpisize,mpirank;
-class mylex : public CodeAlloc {
- public:
- typedef const char * Key;
- typedef pair<int,aType> Value;
- struct Keyless : binary_function<Key,Key, bool>
- { bool operator()(const Key& x, const Key& y) const{ return strcmp(x,y)<0;} };
- typedef map<const char *,Value,Keyless> MapMotClef;
- typedef map<const char *, deque<string> ,Keyless > MapMacroDef;
- typedef map<string, string > MapMacroParam;
- typedef MapMotClef::const_iterator const_iterator;
- typedef MapMotClef::iterator iterator;
- public:
- int linenumber,charnumber;
- list<string> ffincludedir;
- typedef list<string>::iterator Iffincludedir;
- typedef list<string>::const_iterator ICffincludedir;
- private:
- bool firsttime;
- int level;
- char buf[1024];
- int typetoken;
- bool echo;
- stack<char *> strdata;
- struct xxxx {
- int l;
- istream * f;
- const string * filename;
- istream * nf;
- xxxx() : l(0), f(0) , filename(0),nf(0) {}
- void open(mylex *lexx,const char * ff) ;
- void readin(mylex *lexx,const string & s,const string *name=0);
- void close() ;
- };
- friend struct mylex::xxxx;
- xxxx pilesource[100];
- istream & source() const {return * pilesource[level].f;}
- ostream & cout ;
- MapMotClef MotClef;
- list<MapMacroDef> *listMacroDef;
- list<MapMacroParam> *listMacroParam;
- public:
- mylex(ostream & out,bool eecho=true);
- string token() const;
- void print(ostream &f) const;
- int scan(int lvl=0);
- int lineno(){return linenumber;}
- char * YYText() { return buf;}
- void dump(ostream & f ) ;
- void erreur(const char * s) {
- cout << " Error line number" <<linenumber << ": " << s << endl;
- throw(ErrorCompile("lex:",linenumber)); }
- bool InMotClef (aType & t, int & r) const ;
- void Add(Key k,int r,aType t);
- void Check(bool b,Key k,const char * s) {
- if(b) {cout <<"Add " << s << " null: " << k << endl;
- CompileError();}}
- void Add(Key k,int i) ;
- void Add(Key k,aType t);
- void AddF(Key k,aType t);
- void AddSpace(Key k,aType t);
- const char * filename() const {
- if ( level >=0 )
- return pilesource[level].filename ? pilesource[level].filename->c_str() : " -- in macro -- ";
- return "-- unkown --";}
- void input(const char * filename) ;
- void input(const string &str,const string *name=0);
- bool close() ;
- char * newcopy(const char * s)
- {
- char *r(new char [strlen(s)+1]);
- strcpy(r, s);
- strdata.push(r);
- return r;
- }
- ostream & ShowStack(ostream & f);
-~mylex();
-private:
- int basescan();
- int EatCommentAndSpace(string *data=0);
- int scan1();
- bool SetMacro(int &ret);
- bool CallMacro(int &ret);
- char * match(int i);
- void ErrorScan(const char * s) {
- cout << "\n" ;
- ShowStack(cout);
- throw(ErrorCompile(s,lineno(),YYText() ) );}
-} ;
-mylex * Newlex( ostream & out,bool =true);
- void Destroylex(mylex * m);
-extern mylex *zzzfff;
-namespace std __attribute__ ((__visibility__ ("default")))
-{
- struct _Resetiosflags { ios_base::fmtflags _M_mask; };
- inline _Resetiosflags
- resetiosflags(ios_base::fmtflags __mask)
- { return { __mask }; }
- template<typename _CharT, typename _Traits>
- inline basic_istream<_CharT, _Traits>&
- operator>>(basic_istream<_CharT, _Traits>& __is, _Resetiosflags __f)
- {
- __is.setf(ios_base::fmtflags(0), __f._M_mask);
- return __is;
- }
- template<typename _CharT, typename _Traits>
- inline basic_ostream<_CharT, _Traits>&
- operator<<(basic_ostream<_CharT, _Traits>& __os, _Resetiosflags __f)
- {
- __os.setf(ios_base::fmtflags(0), __f._M_mask);
- return __os;
- }
- struct _Setiosflags { ios_base::fmtflags _M_mask; };
- inline _Setiosflags
- setiosflags(ios_base::fmtflags __mask)
- { return { __mask }; }
- template<typename _CharT, typename _Traits>
- inline basic_istream<_CharT, _Traits>&
- operator>>(basic_istream<_CharT, _Traits>& __is, _Setiosflags __f)
- {
- __is.setf(__f._M_mask);
- return __is;
- }
- template<typename _CharT, typename _Traits>
- inline basic_ostream<_CharT, _Traits>&
- operator<<(basic_ostream<_CharT, _Traits>& __os, _Setiosflags __f)
- {
- __os.setf(__f._M_mask);
- return __os;
- }
- struct _Setbase { int _M_base; };
- inline _Setbase
- setbase(int __base)
- { return { __base }; }
- template<typename _CharT, typename _Traits>
- inline basic_istream<_CharT, _Traits>&
- operator>>(basic_istream<_CharT, _Traits>& __is, _Setbase __f)
- {
- __is.setf(__f._M_base == 8 ? ios_base::oct :
- __f._M_base == 10 ? ios_base::dec :
- __f._M_base == 16 ? ios_base::hex :
- ios_base::fmtflags(0), ios_base::basefield);
- return __is;
- }
- template<typename _CharT, typename _Traits>
- inline basic_ostream<_CharT, _Traits>&
- operator<<(basic_ostream<_CharT, _Traits>& __os, _Setbase __f)
- {
- __os.setf(__f._M_base == 8 ? ios_base::oct :
- __f._M_base == 10 ? ios_base::dec :
- __f._M_base == 16 ? ios_base::hex :
- ios_base::fmtflags(0), ios_base::basefield);
- return __os;
- }
- template<typename _CharT>
- struct _Setfill { _CharT _M_c; };
- template<typename _CharT>
- inline _Setfill<_CharT>
- setfill(_CharT __c)
- { return { __c }; }
- template<typename _CharT, typename _Traits>
- inline basic_istream<_CharT, _Traits>&
- operator>>(basic_istream<_CharT, _Traits>& __is, _Setfill<_CharT> __f)
- {
- __is.fill(__f._M_c);
- return __is;
- }
- template<typename _CharT, typename _Traits>
- inline basic_ostream<_CharT, _Traits>&
- operator<<(basic_ostream<_CharT, _Traits>& __os, _Setfill<_CharT> __f)
- {
- __os.fill(__f._M_c);
- return __os;
- }
- struct _Setprecision { int _M_n; };
- inline _Setprecision
- setprecision(int __n)
- { return { __n }; }
- template<typename _CharT, typename _Traits>
- inline basic_istream<_CharT, _Traits>&
- operator>>(basic_istream<_CharT, _Traits>& __is, _Setprecision __f)
- {
- __is.precision(__f._M_n);
- return __is;
- }
- template<typename _CharT, typename _Traits>
- inline basic_ostream<_CharT, _Traits>&
- operator<<(basic_ostream<_CharT, _Traits>& __os, _Setprecision __f)
- {
- __os.precision(__f._M_n);
- return __os;
- }
- struct _Setw { int _M_n; };
- inline _Setw
- setw(int __n)
- { return { __n }; }
- template<typename _CharT, typename _Traits>
- inline basic_istream<_CharT, _Traits>&
- operator>>(basic_istream<_CharT, _Traits>& __is, _Setw __f)
- {
- __is.width(__f._M_n);
- return __is;
- }
- template<typename _CharT, typename _Traits>
- inline basic_ostream<_CharT, _Traits>&
- operator<<(basic_ostream<_CharT, _Traits>& __os, _Setw __f)
- {
- __os.width(__f._M_n);
- return __os;
- }
- extern template ostream& operator<<(ostream&, _Setfill<char>);
- extern template ostream& operator<<(ostream&, _Setiosflags);
- extern template ostream& operator<<(ostream&, _Resetiosflags);
- extern template ostream& operator<<(ostream&, _Setbase);
- extern template ostream& operator<<(ostream&, _Setprecision);
- extern template ostream& operator<<(ostream&, _Setw);
- extern template istream& operator>>(istream&, _Setfill<char>);
- extern template istream& operator>>(istream&, _Setiosflags);
- extern template istream& operator>>(istream&, _Resetiosflags);
- extern template istream& operator>>(istream&, _Setbase);
- extern template istream& operator>>(istream&, _Setprecision);
- extern template istream& operator>>(istream&, _Setw);
- extern template wostream& operator<<(wostream&, _Setfill<wchar_t>);
- extern template wostream& operator<<(wostream&, _Setiosflags);
- extern template wostream& operator<<(wostream&, _Resetiosflags);
- extern template wostream& operator<<(wostream&, _Setbase);
- extern template wostream& operator<<(wostream&, _Setprecision);
- extern template wostream& operator<<(wostream&, _Setw);
- extern template wistream& operator>>(wistream&, _Setfill<wchar_t>);
- extern template wistream& operator>>(wistream&, _Setiosflags);
- extern template wistream& operator>>(wistream&, _Resetiosflags);
- extern template wistream& operator>>(wistream&, _Setbase);
- extern template wistream& operator>>(wistream&, _Setprecision);
- extern template wistream& operator>>(wistream&, _Setw);
-}
-using namespace std;
-inline void Check_Kn(const char * str,const char * file,int line)
-{
- cout << "CHECK_KN: " << str << " in file: " << file << ", line " << line <<endl;
- ((0) ? ( (void) 0) : throw(ErrorAssert("0","../femlib/RNM.hpp", 52)));
- abort();
-}
-inline double conj(const double & x){return x;}
-inline float conj(const float &x){return x;}
-inline long conj(const long &x){return x;}
-inline double real(const double &x){return x;}
-inline float real(const float &x){return x;}
-namespace RNM {
-template<class T> inline T Min (const T &a,const T &b){return a < b ? a : b;}
-template<class T> inline T Max (const T &a,const T & b){return a > b ? a : b;}
-template<class T> inline T Abs (const T &a){return a <0 ? -a : a;}
-template<class T> inline void Exchange (T& a,T& b) {T c=a;a=b;b=c;}
-template<class T> inline T Max (const T &a,const T & b,const T & c){return Max(Max(a,b),c);}
-template<class T> inline T Min (const T &a,const T & b,const T & c){return Min(Min(a,b),c);}
-template<class T>
-inline complex<T> Min(const complex<T> &a,complex<T> &b)
-{ return complex<T>(min(a.real(),b.real()),min(a.imag(),b.imag()));}
-template<class T>
-inline complex<T> Max(const complex<T> &a,const complex<T> &b)
-{ return complex<T>(max(a.real(),b.real()),max(a.imag(),b.imag()));}
- }
-template<class R> class KNMK_ ;
-template<class R> class KNM_ ;
-template<class R> class KN_ ;
-template<class R> class TKN_ ;
-template<class R> class notKN_ ;
-template<class R> class notnotKN_ ;
-template<class R> class KNMK ;
-template<class R> class KNM ;
-template<class R> class KN ;
-template<class R> class conj_KN_ ;
-template<class R> class Add_KN_;
-template<class R> class Sub_KN_;
-template<class R> class Mulc_KN_;
-template<class R> class Add_Mulc_KN_;
-template<class R> class Mul_KNM_KN_;
-template<class R> class DotStar_KN_;
-template<class R> class DotSlash_KN_;
-template<class R> class outProduct_KN_;
-template<class R> class if_KN_;
-template<class R> class if_arth_KN_;
-template<class R> class ifnot_KN_;
-template<class R,class I> class KN_ITAB;
-template<class R,typename A,typename B> class F_KN_;
-template<class P,class Q>
- struct PplusQ { const P & p;const Q & q;
- PplusQ(const P & pp,const Q & qq) : p(pp),q(qq){}
- };
-template<class R>
-struct VirtualMatrice { public:
- int N,M;
- VirtualMatrice(int nn,int mm): N(nn),M(mm) {}
- VirtualMatrice(int nn): N(nn),M(nn) {}
- virtual void addMatMul(const KN_<R> & x, KN_<R> & y) const =0;
- virtual void addMatTransMul(const KN_<R> & , KN_<R> & ) const
- { throw(ErrorInternal("VirtualMatrice::addMatTransMul not implemented ",247,"../femlib/RNM.hpp")); }
- virtual bool WithSolver() const {return false;}
- virtual void Solve( KN_<R> & ,const KN_<R> & ) const
- { throw(ErrorInternal("VirtualMatrice::solve not implemented ",250,"../femlib/RNM.hpp")); }
- virtual bool ChecknbLine (int n) const= 0;
- virtual bool ChecknbColumn (int m) const =0;
- struct plusAx { const VirtualMatrice * A; const KN_<R> x;
- plusAx( const VirtualMatrice * B,const KN_<R> & y) :A(B),x(y)
- { ((B->ChecknbColumn(y.N())) ? ( (void) 0) : throw(ErrorAssert("B->ChecknbColumn(y.N())","../femlib/RNM.hpp", 261))); }
- };
- plusAx operator*(const KN_<R> & x) const {return plusAx(this,x);}
- struct plusAtx { const VirtualMatrice * A; const KN_<R> x;
- plusAtx( const VirtualMatrice * B,const KN_<R> & y) :A(B),x(y)
- {((B->ChecknbLine(y.N())) ? ( (void) 0) : throw(ErrorAssert("B->ChecknbLine(y.N())","../femlib/RNM.hpp", 268)));} };
- struct solveAxeqb { const VirtualMatrice * A; const KN_<R> b;
- solveAxeqb( const VirtualMatrice * B,const KN_<R> & y) :A(B),b(y)
- {((B->ChecknbColumn(y.N())) ? ( (void) 0) : throw(ErrorAssert("B->ChecknbColumn(y.N())","../femlib/RNM.hpp", 272)));} };
- virtual ~VirtualMatrice(){}
-};
-class ShapeOfArray;
-class FromTo{ public:
- long from,to;
- FromTo(long i,long j):from(i),to(j) {;}
- };
-class SubArray{ public:
- const long n,step,start;
- explicit SubArray(long nn,long sta=0,long s=1): n(nn),step(s),start(sta) {}
- SubArray(const FromTo& ft) : n(ft.to-ft.from+1),step(1),start(ft.from) {}
- SubArray(const ShapeOfArray & );
- long end() const { return start+ step*n;}
- long last() const { return start+ step*(n-1);}
- long len1() const { return step*(n-1);}
-};
-class ShapeOfArray{ protected:
- public:
- long n;
- long step;
- long next;
- ShapeOfArray(const ShapeOfArray & s,long nn): n(s.n),step(s.n),next(nn) {}
- ShapeOfArray(long nn): n(nn),step(1),next(-1) {}
- ShapeOfArray(long nn,long s): n(nn),step(s),next(-1) {}
- ShapeOfArray(long nn,long s,long nextt): n(nn),step(s),next(nextt) {}
- ShapeOfArray(const ShapeOfArray &old,const SubArray &sub)
- : n(sub.n),step(old.step*sub.step),next(old.next)
- { ;}
- ShapeOfArray(const ShapeOfArray &old,long stepo,long start)
- : n(old.n-start),step(old.step*stepo),next(old.next)
- { ;}
- long end() const { return n*step;}
- long last() const { return (n-1)*step;}
- long constant() const { return step==0;}
- long index(long k) const { ;
- return step*k;}
- ShapeOfArray operator*(long stepp) const {return ShapeOfArray(n,step*stepp,next);}
- bool SameShape(const ShapeOfArray & a) const
- { return !step || !a.step || a.n == n ;}
- long N(const ShapeOfArray & a) { return step ? n : a.n;}
- long operator[](long k) const {
- ;
- return step*k;}
- void init(long nn,long s=1,long nextt=-1) { n=nn; step=s; next=nextt;}
-};
-ostream & operator<<(ostream & f,const ShapeOfArray & s);
-inline bool SameShape(const ShapeOfArray & a,const ShapeOfArray & b)
- { return !a.step || !b.step || a.n == b.n ;}
-inline long N(const ShapeOfArray & a,const ShapeOfArray & b)
- { ; return a.step ? a.n : b.n ;}
-inline SubArray::SubArray(const ShapeOfArray & s)
- :n(s.n),step(s.step),start(0) {}
-template<class R>
-ostream & operator<<(ostream & f,const KN_<R> & v) ;
-template<class R> istream & operator>>(istream & f, KN_<R> & v);
-template<class R> istream & operator>>(istream & f, KN<R> & v);
-template<class R>
-class SetArray { public:
- R o,step;
- long n;
- explicit SetArray(long nn,R oo=R(),R sstep=R(1)): o(oo),n(nn),step(sstep) {}
- template<class K> SetArray(SetArray<K> sa): o(sa.o),n(sa.n),step(sa.step) {}
- R operator[](long i) const { return i <= n ? o + R(i)*step : R();}
- long size() const {return n;}
-};
-template<class R>
-class KN_: public ShapeOfArray {
-protected:
- R *v;
-public:
- typedef R K;
- long N() const {return n;}
- bool unset() const { return !v;}
- void set(R * vv,int nn,int st=1,int nx=-1) {v=vv;n=nn;step=st;next=nx;}
- long size() const{return step?n*step:n;}
- operator R *() const {return v;}
- KN_(const KN_<R> & u) :ShapeOfArray(u),v(u.v){}
- KN_(const KN_<R> & U,const SubArray & sa) : ShapeOfArray(U,sa),v(U.v + U.index(sa.start)) {}
- KN_ operator()(const SubArray & sa) const { return KN_(*this,sa);}
- R & operator[](long i) const {return v[index(i)];}
- R & operator()(long i) const {return v[index(i)];}
- R & operator[](int i) const {return v[index(i)];}
- R & operator()(int i) const {return v[index(i)];}
- R operator,(const KN_<R> & v) const;
- KN_& operator =(const SetArray<R> & u) ;
- KN_& operator +=(const SetArray<R> & u) ;
- KN_& operator -=(const SetArray<R> & u) ;
- KN_& operator *=(const SetArray<R> & u) ;
- KN_& operator /=(const SetArray<R> & u) ;
- KN_& operator =(const KN_<R> & u) ;
- KN_& operator +=(const KN_<R> & u) ;
- KN_& operator -=(const KN_<R> & u) ;
- KN_& operator *=(const KN_<R> & u) ;
- KN_& operator /=(const KN_<R> & u) ;
- KN_& operator = (R a) ;
- KN_& operator +=(R a) ;
- KN_& operator -=(R a) ;
- KN_& operator /=(R a) ;
- KN_& operator *=(R a) ;
- KN_& operator = (R* a) { return operator =(KN_<R>(a,n));}
- KN_& operator += (R* a) { return operator+=(KN_<R>(a,n));}
- KN_& operator -= (R* a) { return operator-=(KN_<R>(a,n));}
- KN_& operator *= (R* a) { return operator*=(KN_<R>(a,n));}
- KN_& operator /= (R* a) { return operator/=(KN_<R>(a,n));}
- R min() const ;
- R max() const ;
- R sum() const ;
- double norm() const ;
- double l2() const ;
- double l1() const ;
- double linfty() const ;
- double lp(double p) const ;
- template<class T> long last(const T &) const;
- template<class T> long first(const T &) const;
- void map(R (*f)(R ));
- void map(R (*f)(const R& ));
- template<class T>
- void set(R (*f)(const T& ),KN_<T> & u);
- KN_& operator =(const DotStar_KN_<R> & u) ;
- KN_& operator+=(const DotStar_KN_<R> & u) ;
- KN_& operator-=(const DotStar_KN_<R> & u) ;
- KN_& operator*=(const DotStar_KN_<R> & u) ;
- KN_& operator/=(const DotStar_KN_<R> & u) ;
- KN_& operator =(const DotSlash_KN_<R> & u) ;
- KN_& operator+=(const DotSlash_KN_<R> & u) ;
- KN_& operator-=(const DotSlash_KN_<R> & u) ;
- KN_& operator*=(const DotSlash_KN_<R> & u) ;
- KN_& operator/=(const DotSlash_KN_<R> & u) ;
- KN_& operator =(const if_KN_<R> & u) ;
- KN_& operator+=(const if_KN_<R> & u) ;
- KN_& operator-=(const if_KN_<R> & u) ;
- KN_& operator*=(const if_KN_<R> & u) ;
- KN_& operator/=(const if_KN_<R> & u) ;
- KN_& operator =(const ifnot_KN_<R> & u) ;
- KN_& operator+=(const ifnot_KN_<R> & u) ;
- KN_& operator-=(const ifnot_KN_<R> & u) ;
- KN_& operator*=(const ifnot_KN_<R> & u) ;
- KN_& operator/=(const ifnot_KN_<R> & u) ;
- KN_& operator =(const Add_KN_<R> & u) ;
- KN_& operator+=(const Add_KN_<R> & u) ;
- KN_& operator-=(const Add_KN_<R> & u) ;
- KN_& operator*=(const Add_KN_<R> & u) ;
- KN_& operator/=(const Add_KN_<R> & u) ;
- template<class I,class T> KN_& operator = (const KN_ITAB<T,I> & u);
- template<class I,class T> KN_& operator += (const KN_ITAB<T,I> & u);
- template<class I,class T> KN_& operator -= (const KN_ITAB<T,I> & u);
- template<class I,class T> KN_& operator *= (const KN_ITAB<T,I> & u);
- template<class I,class T> KN_& operator /= (const KN_ITAB<T,I> & u);
- KN_ITAB< KN_<R>,const KN_<int> > operator()(const KN_<int> &itab) ;
- KN_ITAB< KN_<R>,const KN_<long> > operator()(const KN_<long> &itab) ;
- KN_ITAB<const KN_<R>,const KN_<int> > operator()(const KN_<int> &itab) const ;
- KN_ITAB<const KN_<R>,const KN_<long> > operator()(const KN_<long> &itab) const ;
- KN_& operator =(const Sub_KN_<R> & u) ;
- KN_& operator-=(const Sub_KN_<R> & u) ;
- KN_& operator+=(const Sub_KN_<R> & u) ;
- KN_& operator*=(const Sub_KN_<R> & u) ;
- KN_& operator/=(const Sub_KN_<R> & u) ;
- KN_& operator =(const Mulc_KN_<R> & u) ;
- KN_& operator+=(const Mulc_KN_<R> & u) ;
- KN_& operator-=(const Mulc_KN_<R> & u) ;
- KN_& operator*=(const Mulc_KN_<R> & u) ;
- KN_& operator/=(const Mulc_KN_<R> & u) ;
- KN_& operator =(const Add_Mulc_KN_<R> & u) ;
- KN_& operator+=(const Add_Mulc_KN_<R> & u) ;
- KN_& operator-=(const Add_Mulc_KN_<R> & u) ;
- KN_& operator*=(const Add_Mulc_KN_<R> & u) ;
- KN_& operator/=(const Add_Mulc_KN_<R> & u) ;
- KN_& operator =(const if_arth_KN_<R> & u) ;
- KN_& operator+=(const if_arth_KN_<R> & u) ;
- KN_& operator-=(const if_arth_KN_<R> & u) ;
- KN_& operator*=(const if_arth_KN_<R> & u) ;
- KN_& operator/=(const if_arth_KN_<R> & u) ;
- KN_& operator =(const Mul_KNM_KN_<R> & u) ;
- KN_& operator+=(const Mul_KNM_KN_<R> & u) ;
- KN_& operator-=(const Mul_KNM_KN_<R> & u) ;
- KN_& operator*=(const Mul_KNM_KN_<R> & u) ;
- KN_& operator/=(const Mul_KNM_KN_<R> & u) ;
- KN_& operator =(const typename VirtualMatrice<R>::plusAx & Ax)
- {*this=R(); Ax.A->addMatMul(Ax.x,*this);return *this;}
- KN_& operator =(const typename VirtualMatrice<R>::plusAtx & Ax)
- {*this=R(); Ax.A->addMatTransMul(Ax.x,*this);return *this;}
- KN_& operator +=(const typename VirtualMatrice<R>::plusAx & Ax)
- { Ax.A->addMatMul(Ax.x,*this);return *this;}
- KN_& operator +=(const typename VirtualMatrice<R>::plusAtx & Ax)
- { Ax.A->addMatTransMul(Ax.x,*this);return *this;}
- KN_& operator =(const typename VirtualMatrice<R>::solveAxeqb & Ab)
- {*this=R(); Ab.A->Solve(*this,Ab.b);return *this;}
- template<class A,class B,class C> KN_& operator = (const F_KN_<A,B,C> & u) ;
- template<class A,class B,class C> KN_& operator += (const F_KN_<A,B,C> & u) ;
- template<class A,class B,class C> KN_& operator -= (const F_KN_<A,B,C> & u) ;
- template<class A,class B,class C> KN_& operator /= (const F_KN_<A,B,C> & u) ;
- template<class A,class B,class C> KN_& operator *= (const F_KN_<A,B,C> & u) ;
- friend ostream & operator<< <R>(ostream & f,const KN_<R> & v) ;
- KN_(R *u,const ShapeOfArray & s):ShapeOfArray(s),v(u){}
- KN_(R *u,long nn,long s):ShapeOfArray(nn,s),v(u){}
- KN_(R *u,long nn,long s,long nextt):ShapeOfArray(nn,s,nextt),v(u){}
- KN_(R *u,long nn):ShapeOfArray(nn),v(u){}
- TKN_<R> t() ;
- const TKN_<R> t() const ;
- notKN_<R> operator!() ;
- const notKN_<R> operator!() const ;
- private:
- KN_& operator++(){;v += next;return *this;}
- KN_& operator--(){;v -= next;return *this;}
- KN_ operator++(int ){; KN_ old=*this;v = v +next;return old;}
- KN_ operator--(int ){; KN_ old=*this;v = v -next;return old;}
- KN_(const KN_<R> & u,long offset) :ShapeOfArray(u),v(&u[offset]){}
- KN_(const KN_<R> & u,const ShapeOfArray &sh,long startv=0)
- :ShapeOfArray(sh*u.step),v(&u[startv]){}
- KN_(const KN_<R> & u,long nnext,const ShapeOfArray &sh,long startv=0)
- :ShapeOfArray(sh.n,sh.step*u.step,nnext),v(&u[startv]){ }
- friend class KNM_<R>;
- friend class KNMK_<R>;
- friend class KN<R>;
- friend class KNM<R>;
- friend class KNMK<R>;
-};
-template<class R>
-class KNM_: public KN_<R> {
- public:
- ShapeOfArray shapei;
- ShapeOfArray shapej;
- public:
- long IsVector1() const { return (shapei.n*shapej.n) == this->n ;}
- long N() const {return shapei.n;}
- long M() const {return shapej.n;}
- long size() const { return shapei.n*shapej.n;}
- KNM_(R* u,const ShapeOfArray & s,
- const ShapeOfArray & si,
- const ShapeOfArray & sj)
- : KN_<R>(u,s),shapei(si),shapej(sj){}
- KNM_(R* u,long n,long m)
- : KN_<R>(u,ShapeOfArray(n*m)),shapei(n,1,n),shapej(m,n,1){}
- KNM_(R* u,long n,long m,long s)
- : KN_<R>(u,ShapeOfArray(n*m,s)),shapei(n,1,n),shapej(m,n,1){}
- KNM_(KN_<R> u,long n,long m)
- : KN_<R>(u,ShapeOfArray(m*n)),shapei(n,1,n),shapej(m,n,1){ }
- KNM_(const KN_<R> &u,const ShapeOfArray & si,const ShapeOfArray & sj,long offset=0)
- : KN_<R>(&u[offset],si.last()+sj.last()+1,u.step),shapei(si),shapej(sj)
- {;}
- KNM_(const KN_<R> &u,const ShapeOfArray & si,const ShapeOfArray & sj,long offset,long nnext)
- : KN_<R>(&u[offset],si.last()+sj.last()+1,u.step,nnext),shapei(si),shapej(sj)
- {;}
- KNM_(KNM_<R> U,const SubArray & si,const SubArray & sj)
- :KN_<R>(U,SubArray(U.ij(si.len1(),sj.len1())+1,U.ij(si.start,sj.start))),
- shapei(U.shapei,si),shapej(U.shapej,sj){}
- KNM_(KNM_<R> U,const SubArray & sa,const SubArray & si,const SubArray & sj)
- :KN_<R>(U,SubArray(sa)),shapei(U.shapei,si),shapej(U.shapej,sj){}
- KNM_(const KNM_<R> & u)
- :KN_<R>(u),shapei(u.shapei),shapej(u.shapej) {}
- KNM_ operator()(const SubArray & sa,const SubArray & sb) const
- { return KNM_(*this,sa,sb);}
- long ij(long i,long j) const
- { return shapei.index(i)+shapej.index(j);}
- long indexij(long i,long j) const
- { return this->index(shapei.index(i)+shapej.index(j));}
- R & operator()(long i,long j) const
- { return this->v[indexij(i,j)];}
- R & operator()(int i,int j) const
- { return this->v[indexij(i,j)];}
- KN_<R> operator()(const char,long j ) const
- { return KN_<R>(&this->v[this->index(shapej.index(j))],shapei*this->step);}
- KN_<R> operator()(long i ,const char) const
- { return KN_<R>(&this->v[this->index(shapei.index(i))],shapej*this->step);}
- KN_<R> operator()(const char,int j ) const
- { return KN_<R>(&this->v[this->index(shapej.index(j))],shapei*this->step);}
- KN_<R> operator()(int i ,const char) const
- { return KN_<R>(&this->v[this->index(shapei.index(i))],shapej*this->step);}
- KN_<R> operator()(const char,const char) const
- { return *this;}
- KNM_<R> t() const
- { return KNM_<R>(this->v,*this,shapej,shapei);}
- KNM_& operator =(const KNM_<R> & u) ;
- KNM_& operator =(R a) ;
- KNM_& operator+=(R a) ;
- KNM_& operator-=(R a) ;
- KNM_& operator/=(R a) ;
- KNM_& operator*=(R a) ;
- KNM_& operator+=(const KNM_<R> & u) ;
- KNM_& operator-=(const KNM_<R> & u) ;
- KNM_& operator*=(const KNM_<R> & u) ;
- KNM_& operator/=(const KNM_<R> & u) ;
- KNM_ &operator =(const outProduct_KN_<R> &);
- KNM_ &operator +=(const outProduct_KN_<R> &);
- KNM_ &operator -=(const outProduct_KN_<R> &);
- KNM_ &operator /=(const outProduct_KN_<R> &);
- KNM_ &operator *=(const outProduct_KN_<R> &);
-private:
- KNM_& operator++() {this->v += this->next;return *this;}
- KNM_& operator--() {this->v -= this->next;return *this;}
- KNM_ operator++(int ){KNM_<R> old=*this;this->v = this->v +this->next;return old;}
- KNM_ operator--(int ){KNM_<R> old=*this;this->v = this->v -this->next;return old;}
- friend class KN_<R>;
- friend class KNMK_<R>;
- friend class KN<R>;
- friend class KNM<R>;
- friend class KNMK<R>;
-};
-template<class T,class I>
-struct KN_ITAB
-{
- KN_ITAB(const T &vv,const I &iindex) : v(vv),index(iindex) {}
- T v;
- I index;
- KN_ITAB & operator=(const T & t);
- KN_ITAB & operator+=(const T & t);
- KN_ITAB & operator-=(const T & t);
- KN_ITAB & operator*=(const T & t);
- KN_ITAB & operator/=(const T & t);
- typename T::R & operator[](long i){ return v[index[i]];}
- const typename T::R & operator[](long i) const { return v[index[i]];}
- long N() const { return index.N();}
-};
-template<class R> KN_ITAB<const KN_<R>,const KN_<int> > KN_<R>::operator()(const KN_<int> &itab) const { return KN_ITAB<const KN_<R>,const KN_<int> > (*this,itab);}
-template<class R> KN_ITAB<const KN_<R>,const KN_<long> > KN_<R>::operator()(const KN_<long> &itab) const { return KN_ITAB<const KN_<R>,const KN_<long> > (*this,itab);}
-template<class R> KN_ITAB< KN_<R>,const KN_<int> > KN_<R>::operator()(const KN_<int> &itab) { return KN_ITAB<KN_<R>,const KN_<int> > (*this,itab);}
-template<class R> KN_ITAB< KN_<R>,const KN_<long> > KN_<R>::operator()(const KN_<long> &itab) { return KN_ITAB<KN_<R>,const KN_<long> > (*this,itab);}
-template<class R>
-struct TKN_:public KN_<R> {
- TKN_(const KN_<R> &x) : KN_<R>(x) {}
-};
-template<class R>
-struct notKN_:public KN_<R> {
- notKN_(const KN_<R> &x) : KN_<R>(x) {}
- notnotKN_<R> operator!() ;
- const notnotKN_<R> operator!() const ;
-};
-template<class R>
-struct notnotKN_:public KN_<R> {
- notnotKN_(const notKN_<R> &x) : KN_<R>(x) {}
- notKN_<R> operator!() ;
- const notKN_<R> operator!() const ;
-};
-template<class R>
-TKN_<R> KN_<R>::t() { return *this;}
-template<class R>
-const TKN_<R> KN_<R>::t() const { return *this;}
-template<class R>
-notKN_<R> KN_<R>::operator!() { return *this;}
-template<class R>
-const notKN_<R> KN_<R>::operator!() const { return *this;}
-template<class R>
-notnotKN_<R> notKN_<R>::operator!() { return *this;}
-template<class R>
-const notnotKN_<R> notKN_<R>::operator!() const { return *this;}
-template<class R>
-struct outProduct_KN_ {
- const KN_<R> a,b;
- R c;
- long N() const {return a.N(); }
- long M() const {return b.N(); }
- outProduct_KN_(const KN_<R> & aa, const KN_<R> &bb,R cc=(R)1) : a(aa),b(bb),c(cc) {}
- outProduct_KN_(const KN_<R> * aa, const KN_<R> &bb,R cc=(R)1) : a(*aa),b(bb),c(cc) {}
- outProduct_KN_(const KN_<R> * aa, const KN_<R> *bb,R cc=(R)1) : a(*aa),b(*bb),c(cc) {}
- outProduct_KN_(const Mulc_KN_<R> & aa,const KN_<R> & bb) : a(aa.a),b(bb),c(aa.b) {}
- outProduct_KN_ operator * (R cc) { return outProduct_KN_(a,b,c*cc);}
-};
-template<class R>
-struct if_KN_ {
- const KN_<R> & a,&b;
- R c;
- if_KN_(const KN_<R> & aa, const KN_<R> &bb,R cc=1.) : a(aa),b(bb),c(cc) {}
- if_KN_ operator * (R cc) { return if_KN_(a,b,c*cc);}
-};
-template<class R>
-struct ifnot_KN_ {
- const KN_<R> & a,&b;
- R c;
- ifnot_KN_(const KN_<R> & aa, const KN_<R> &bb,R cc=1.) : a(aa),b(bb),c(cc) {}
- ifnot_KN_ operator * (R cc) { return ifnot_KN_(a,b,c*cc);}
-};
-template<class R>
-outProduct_KN_<R> operator*(const KN_<R> &a,const TKN_<R> &b)
-{ return outProduct_KN_<R>(a,b);}
-template<class R>
-ifnot_KN_<R> operator*(const KN_<R> &a,const notKN_<R> &b)
-{ return ifnot_KN_<R>(b,a);}
-template<class R>
-ifnot_KN_<R> operator*(const KN_<R> &a,const notnotKN_<R> &b)
-{ return if_KN_<R>(b,a);}
-template<class R>
-ifnot_KN_<R> operator*(const notKN_<R> &b,const KN_<R> &a)
-{ return ifnot_KN_<R>(b,a);}
-template<class R>
-ifnot_KN_<R> operator*(const notnotKN_<R> &b,const KN_<R> & a)
-{ return if_KN_<R>(b,a);}
-template<class R>
-R operator*(const TKN_<R> &a,const KN_<R> &b)
-{ return (a,b);}
-template<class R>
-class KNMK_: public KN_<R> {
- friend class KNMK<R>;
- public:
- ShapeOfArray shapei;
- ShapeOfArray shapej;
- ShapeOfArray shapek;
- public:
- long IsVector1() const { return (shapei.n*shapej.n*shapek.n) == this->n ;}
- long N() const {return shapei.n;}
- long M() const {return shapej.n;}
- long K() const {return shapek.n;}
- long size() const { return shapei.n*shapej.n*shapek.n;}
- KNMK_(const ShapeOfArray & s,
- const ShapeOfArray & si,
- const ShapeOfArray & sj,
- const ShapeOfArray & sk,
- R * u)
- : KN_<R>(u,s),shapei(si),shapej(sj),shapek(sk){}
- KNMK_(R* u,long n,long m,long k)
- : KN_<R>(u, ShapeOfArray(n*m*k)),shapei(n,1,n),shapej(m,n,1),shapek(k,n*m,n*m){};
- KNMK_(const KNMK_<R> &U,const SubArray & si,const SubArray & sj,const SubArray & sk) :
- KN_<R>(U,SubArray(U.ijk(si.len1(),sj.len1(),sk.len1())+1,
- U.ijk(si.start,sj.start,sk.start))),
- shapei(U.shapei,si),
- shapej(U.shapej,sj),
- shapek(U.shapek,sk){}
- KNMK_(const KNMK_<R> & u) :KN_<R>(u),shapei(u.shapei),shapej(u.shapej),shapek(u.shapek) {}
- long ijk(long i,long j,long k) const
- { return shapei.index(i)+shapej.index(j)+shapek.index(k);}
- long indexijk(long i,long j,long k) const
- {return this->index(shapei.index(i)+shapej.index(j)+shapek.index(k));}
- R & operator()(long i,long j,long k) const {return this->v[indexijk(i,j,k)];}
- R & operator()(int i,int j,int k) const {return this->v[indexijk(i,j,k)];}
- KN_<R> operator()(const char ,long j,long k) const {
- return KN_<R>(*this,-1,shapei,shapej[j]+shapek[k]);}
- KN_<R> operator()(long i,const char ,long k) const {
- return KN_<R>(*this,-1,shapej,shapei[i]+shapek[k]);}
- KN_<R> operator()(long i,long j,const char ) const {
- return KN_<R>(*this,-1,shapek,shapei[i]+shapej[j]);}
- KN_<R> operator()(const char ,int j,int k) const {
- return KN_<R>(*this,-1,shapei,shapej[j]+shapek[k]);}
- KN_<R> operator()(int i,const char ,int k) const {
- return KN_<R>(*this,-1,shapej,shapei[i]+shapek[k]);}
- KN_<R> operator()(int i,int j,const char ) const {
- return KN_<R>(*this,-1,shapek,shapei[i]+shapej[j]);}
- KNM_<R> operator()(const char ,const char ,long k) const {
- return KNM_<R>(*this,shapei,shapej,shapek[k],shapek.next);}
- KNM_<R> operator()(const char ,long j,const char ) const {
- return KNM_<R>(*this,shapei,shapek,shapej[j],-1 );}
- KNM_<R> operator()(long i,const char ,const char ) const {
- return KNM_<R>(*this,shapej,shapek,shapei[i],-1 );}
- KNM_<R> operator()(const char ,const char ,int k) const {
- return KNM_<R>(*this,shapei,shapej,shapek[k],shapek.next);}
- KNM_<R> operator()(const char ,int j,const char ) const {
- return KNM_<R>(*this,shapei,shapek,shapej[j],-1 );}
- KNM_<R> operator()(int i,const char ,const char ) const {
- return KNM_<R>(*this,shapej,shapek,shapei[i],-1 );}
- KNMK_& operator =(const KNMK_<R> & u) ;
- KNMK_& operator+=(const KNMK_<R> & u) ;
- KNMK_& operator-=(const KNMK_<R> & u) ;
- KNMK_& operator/=(const KNMK_<R> & u) ;
- KNMK_& operator*=(const KNMK_<R> & u) ;
- KNMK_& operator =(R a) ;
- KNMK_& operator+=(R a) ;
- KNMK_& operator-=(R a) ;
- KNMK_& operator/=(R a) ;
- KNMK_& operator*=(R a) ;
- KNMK_ operator()(SubArray si,SubArray sj,SubArray sk) const
- {return KNMK_(*this,si,sj,sk);}
- private:
-friend class KNM_<R>;
-friend class KN_<R>;
-};
-template<class R>
-class KN :public KN_<R> { public:
- typedef R K;
- KN() : KN_<R>(0,0) {}
- KN(long nn) : KN_<R>(new R[nn],nn) {}
- KN(long nn, R * p) : KN_<R>(new R[nn],nn)
- { KN_<R>::operator=(KN_<R>(p,nn));}
- KN(long nn,R (*f)(long i) ) : KN_<R>(new R[nn],nn)
- {for(long i=0;i<this->n;i++) this->v[i]=f(i);}
- KN(long nn,const R & a) : KN_<R>(new R[nn],nn)
- { KN_<R>::operator=(a);}
- KN(long nn,long s,const R a) : KN_<R>(new R[nn],nn,s)
- { KN_<R>::operator=(a);}
- template<class S> KN(const KN_<S> & s):KN_<R>(new R[s.n],s.n)
- {for (long i=0;i<this->n;i++) this->v[i] = s[i];}
- template<class S> KN(const KN_<S> & s,R (*f)(S )):KN_<R>(new R[s.n],s.n)
- {for (long i=0;i<this->n;i++) this->v[i] = f(s[i]);}
- KN(const KN<R> & u):KN_<R>(new R[u.n],u.n)
- { KN_<R>::operator=(u);}
- KN(bool ,KN<R> & u):KN_<R>(u) {u.v=0;u.n=0;}
- ~KN(){delete [] this->v;}
- void CheckSet() { if(!(this->n)) {cout << "Error RNM set array\n";; exit(1);}}
- KN& operator = (R* a) { CheckSet(); return operator =(KN_<R>(a,this->n));}
- KN& operator += (R* a) { CheckSet(); return operator+=(KN_<R>(a,this->n));}
- KN& operator -= (R* a) { CheckSet(); return operator-=(KN_<R>(a,this->n));}
- KN& operator *= (R* a) { CheckSet(); return operator*=(KN_<R>(a,this->n));}
- KN& operator /= (R* a) { CheckSet(); return operator/=(KN_<R>(a,this->n));}
- KN& operator =(const SetArray<R> & u)
- { if(this->unset()) set(new R[u.size()],u.size(),0,0); KN_<R>::operator= (u);return *this;}
- KN& operator +=(const SetArray<R> & u)
- { if(this->unset()) set(new R[u.size()],u.size(),0,0); KN_<R>::operator+= (u);return *this;}
- KN& operator -=(const SetArray<R> & u)
- { if(this->unset()) set(new R[u.size()],u.size(),0,0); KN_<R>::operator-= (u);return *this;}
- KN& operator *=(const SetArray<R> & u)
- { if(this->unset()) set(new R[u.size()],u.size(),0,0); KN_<R>::operator*= (u);return *this;}
- KN& operator /=(const SetArray<R> & u)
- { if(this->unset()) set(new R[u.size()],u.size(),0,0); KN_<R>::operator/= (u);return *this;}
- KN& operator =(R a)
- { if(this->unset()) set(new R[1],1,0,0); KN_<R>::operator= (a);return *this;}
- KN& operator =(const KN_<R>& a)
- { if(this->unset()) set(new R[a.N()],a.N()); KN_<R>::operator= (a);return *this;}
- KN& operator =(const KN<R>& a)
- { if(this->unset()) set(new R[a.N()],a.N()); KN_<R>::operator= (a);return *this;}
- KN& operator =(const Add_KN_<R> & u)
- { if(this->unset()) set(new R[u.a.N()],u.a.N());KN_<R>::operator=(u);return *this;}
- KN& operator =(const DotStar_KN_<R> & u)
- { if(this->unset()) set(new R[u.a.N()],u.a.N());KN_<R>::operator=(u);return *this;}
- KN& operator =(const if_KN_<R> & u)
- { if(this->unset()) set(new R[u.a.N()],u.a.N());KN_<R>::operator=(u);return *this;}
- KN& operator =(const ifnot_KN_<R> & u)
- { if(this->unset()) set(new R[u.a.N()],u.a.N());KN_<R>::operator=(u);return *this;}
- KN& operator =(const DotSlash_KN_<R> & u)
- { if(this->unset()) set(new R[u.a.N()],u.a.N());KN_<R>::operator=(u);return *this;}
- KN& operator =(const Sub_KN_<R> & u)
- { if(this->unset()) set(new R[u.a.N()],u.a.N());KN_<R>::operator=(u);return *this;}
- KN& operator =(const Mulc_KN_<R> & u)
- { if(this->unset()) set(new R[u.a.N()],u.a.N());KN_<R>::operator=(u);return *this;}
- KN& operator =(const Add_Mulc_KN_<R> & u)
- { if(this->unset()) set(new R[u.a.N()],u.a.N());KN_<R>::operator=(u);return *this;}
- KN& operator =(const if_arth_KN_<R> & u)
- { if(this->unset()) set(new R[u.a.N()],u.a.N());KN_<R>::operator=(u);return *this;}
- KN& operator =(const Mul_KNM_KN_<R> & u)
- { if(this->unset()) set(new R[u.b.N()],u.b.N());KN_<R>::operator=(u);return *this;}
- KN& operator =(const typename VirtualMatrice<R>::plusAx & Ax)
- { if(this->unset() && Ax.A->N ) set(new R[Ax.A->N],Ax.A->N);KN_<R>::operator=(Ax);return *this;}
- KN& operator =(const typename VirtualMatrice<R>::solveAxeqb & Ab)
- { if(this->unset()) set(new R[Ab.b.N()],Ab.b.N());KN_<R>::operator=(Ab);return *this;}
- KN& operator +=(const typename VirtualMatrice<R>::plusAx & Ax)
- { if(this->unset() && Ax.A->N) {
- set(new R[Ax.A->N],Ax.A->N);
- KN_<R>::operator=(R());}
- KN_<R>::operator+=(Ax);
- return *this;}
- KN& operator =(const typename VirtualMatrice<R>::plusAtx & Ax)
- { if(this->unset()&&Ax.A->M) set(new R[Ax.A->M],Ax.A->M);KN_<R>::operator=(Ax);return *this;}
- KN& operator +=(const typename VirtualMatrice<R>::plusAtx & Ax)
- { if(this->unset()&&Ax.A->M) {
- set(new R[Ax.A->M],Ax.A->M);
- KN_<R>::operator=(R());}
- KN_<R>::operator+=(Ax);
- return *this;}
- template<class P,class Q>
- KN& operator =(const PplusQ<P,Q> & PQ)
- { *this=PQ.p; *this+=PQ.q;return *this; }
- template<class P,class Q>
- KN& operator +=(const PplusQ<P,Q> & PQ)
- { *this+=PQ.p; *this+=PQ.q;return *this; }
- KN& operator -=(R a)
- { KN_<R>::operator-=(a);return *this;}
- KN& operator -=(const KN_<R>& a)
- { KN_<R>::operator-= (a);return *this;}
- KN& operator -=(const Add_KN_<R> & u)
- { KN_<R>::operator-=(u);return *this;}
- KN& operator -=(const DotStar_KN_<R> & u)
- { KN_<R>::operator-=(u);return *this;}
- KN& operator -=(const DotSlash_KN_<R> & u)
- { KN_<R>::operator-=(u);return *this;}
- KN& operator -=(const Sub_KN_<R> & u)
- { KN_<R>::operator-=(u);return *this;}
- KN& operator -=(const Mulc_KN_<R> & u)
- { KN_<R>::operator-=(u);return *this;}
- KN& operator -=(const Add_Mulc_KN_<R> & u)
- { KN_<R>::operator-=(u);return *this;}
- KN& operator -=(const if_arth_KN_<R> & u)
- { KN_<R>::operator-=(u);return *this;}
- KN& operator -=(const Mul_KNM_KN_<R> & u)
- { KN_<R>::operator-=(u);return *this;}
- KN& operator +=(R a)
- { KN_<R>::operator += (a);return *this;}
- KN& operator += (const KN_<R>& a)
- { KN_<R>::operator+= (a);return *this;}
- KN& operator +=(const Add_KN_<R> & u)
- { KN_<R>::operator+=(u);return *this;}
- KN& operator +=(const DotStar_KN_<R> & u)
- { KN_<R>::operator+=(u);return *this;}
- KN& operator +=(const DotSlash_KN_<R> & u)
- { KN_<R>::operator+=(u);return *this;}
- KN& operator +=(const Sub_KN_<R> & u)
- { KN_<R>::operator+=(u);return *this;}
- KN& operator +=(const Mulc_KN_<R> & u)
- { KN_<R>::operator+=(u);return *this;}
- KN& operator +=(const Add_Mulc_KN_<R> & u)
- { KN_<R>::operator+=(u);return *this;}
- KN& operator +=(const if_arth_KN_<R> & u)
- { KN_<R>::operator+=(u);return *this;}
- KN& operator +=(const Mul_KNM_KN_<R> & u)
- { KN_<R>::operator+=(u);return *this;}
- KN& operator/=(R a)
- { KN_<R>::operator/=(a);return *this;}
- KN& operator /= (const KN_<R>& a)
- { KN_<R>::operator/= (a);return *this;}
- KN& operator /=(const Add_KN_<R> & u)
- { KN_<R>::operator/=(u);return *this;}
- KN& operator /=(const Sub_KN_<R> & u)
- { KN_<R>::operator/=(u);return *this;}
- KN& operator /=(const Mulc_KN_<R> & u)
- { KN_<R>::operator/=(u);return *this;}
- KN& operator /=(const Add_Mulc_KN_<R> & u)
- { KN_<R>::operator/=(u);return *this;}
- KN& operator /=(const if_arth_KN_<R> & u)
- { KN_<R>::operator/=(u);return *this;}
- KN& operator /=(const Mul_KNM_KN_<R> & u)
- { KN_<R>::operator/=(u);return *this;}
- KN& operator*=(R a)
- { KN_<R>::operator*=(a);return *this;}
- KN& operator*=(const KN_<R>& a)
- { KN_<R>::operator*= (a);return *this;}
- KN& operator *=(const Add_KN_<R> & u)
- { KN_<R>::operator*=(u);return *this;}
- KN& operator *=(const Sub_KN_<R> & u)
- { KN_<R>::operator*=(u);return *this;}
- KN& operator *=(const Mulc_KN_<R> & u)
- { KN_<R>::operator*=(u);return *this;}
- KN& operator *=(const Add_Mulc_KN_<R> & u)
- { KN_<R>::operator*=(u);return *this;}
- KN& operator *=(const if_arth_KN_<R> & u)
- { KN_<R>::operator*=(u);return *this;}
- KN& operator *=(const Mul_KNM_KN_<R> & u)
- { KN_<R>::operator*=(u);return *this;}
- template<class I,class T> KN& operator = (const KN_ITAB<T ,I> & ui)
- { KN_<R>::operator =(ui); return *this;}
- template<class I,class T> KN& operator += (const KN_ITAB<T ,I> & ui)
- { KN_<R>::operator +=(ui); return *this;}
- template<class I,class T> KN& operator -= (const KN_ITAB<T ,I> & ui)
- { KN_<R>::operator -=(ui); return *this;}
- template<class I,class T> KN& operator *= (const KN_ITAB<T ,I> & ui)
- { KN_<R>::operator *=(ui); return *this;}
- template<class I,class T> KN& operator /= (const KN_ITAB<T ,I> & ui)
- { KN_<R>::operator /=(ui); return *this;}
- void init(long nn) {this->n=nn;this->step=1;this->next=-1;this->v=new R[nn];}
- void init() {this->n=0;this->step=1;this->next=-1;this->v=0;}
- void init(const KN_<R> & a){init(a.N()); operator=(a);}
- void resize(long nn) {
- if ( nn != this->n)
- {
- R *vo=this->v;
- long no=std::min(this->n,nn), so=this->step;
- ShapeOfArray::init(nn);
- this->v=new R[this->n];
- if(this->v && vo)
- for(long i=0,j=0;j<no;i++,j+=so)
- this->v[i]=vo[j];
- delete [] vo;} }
- void destroy(){(static_cast<void> (0)); if(this->next++ ==-1) {delete [] this->v; this->v=0;this->n=0;}}
- void increment() {(static_cast<void> (0)); this->next--;}
-};
-template<class R>
-class KNM: public KNM_<R>{ public:
- KNM(long nn,long mm)
- :KNM_<R>(new R[nn*mm],nn,mm){}
- KNM(const KNM<R> & u)
- :KNM_<R>(new R[u.size()],u.N(),u.M())
- { KN_<R>::operator=(u);}
- explicit KNM(const KNM_<R> & u)
- :KNM_<R>(new R[u.size()],u.N(),u.M())
- { KNM_<R>::operator=(u);}
- ~KNM(){delete [] this->v;}
- KNM& operator=(const KNM_<R> & u)
- { if(this->unset()) this->init(u.N(),u.M()) ; KNM_<R>::operator=(u);return *this;}
- KNM& operator=(R a)
- { if(this->unset()) Check_Kn(" KNM operator=(double)","../femlib/RNM.hpp",1146);; KNM_<R>::operator=(a);return *this;}
- KNM& operator+=(R a)
- { if(this->unset()) Check_Kn(" KNM operator+=(double)","../femlib/RNM.hpp",1148);; KNM_<R>::operator+=(a);return *this;}
- KNM& operator-=(R a)
- {if(this->unset()) Check_Kn(" KNM operator-=(double)","../femlib/RNM.hpp",1150);; KNM_<R>::operator-=(a);return *this;}
- KNM& operator/=(R a)
- {if(this->unset()) Check_Kn(" KNM operator/=(double)","../femlib/RNM.hpp",1152);; KNM_<R>::operator/=(a);return *this;}
- KNM& operator*=(R a)
- {if(this->unset()) Check_Kn(" KNM operator*=(double)","../femlib/RNM.hpp",1154);; KNM_<R>::operator*=(a);return *this;}
- KNM& operator+=(const KNM_<R> & u)
- { if(this->unset()) this->init(u.N(),u.M()) ; KNM_<R>::operator+=(u);return *this;}
- KNM& operator-=(const KNM_<R> & u)
- { if(this->unset()) this->init(u.N(),u.M()) ;KNM_<R>::operator-=(u);return *this;}
- KNM& operator/=(const KNM_<R> & u)
- { if(this->unset()) this->init(u.N(),u.M()) ;KNM_<R>::operator/=(u);return *this;}
- KNM& operator*=(const KNM_<R> & u)
- { if(this->unset()) this->init(u.N(),u.M()) ; KNM_<R>::operator*=(u);return *this;}
- KNM &operator =(const outProduct_KN_<R> & u)
- { if(this->unset()) this->init(u.N(),u.M()) ; KNM_<R>::operator =(u);return *this;}
- KNM &operator +=(const outProduct_KN_<R> & u)
- { if(this->unset()) this->init(u.N(),u.M()) ; KNM_<R>::operator+=(u);return *this;}
- KNM &operator -=(const outProduct_KN_<R> & u)
- { if(this->unset()) this->init(u.N(),u.M()) ; KNM_<R>::operator-=(u);return *this;}
- KNM &operator /=(const outProduct_KN_<R> & u)
- { if(this->unset()) this->init(u.N(),u.M()) ;KNM_<R>::operator/=(u);return *this;}
- KNM &operator *=(const outProduct_KN_<R> & u)
- { if(this->unset()) this->init(u.N(),u.M()) ;KNM_<R>::operator*=(u);return *this;}
- void init() {
- this->n=0;this->step=1;this->next=-1;this->v=0;
- this->shapei.init(0);
- this->shapej.init(0);}
- void init(long nn,long mm) {
- ShapeOfArray::init(nn*mm);
- this->shapei.init(nn,1,nn);
- this->shapej.init(mm,nn,1),
- this->v=new R[nn*mm];}
- void resize(long nn,long mm) {
- long kk=nn*mm;
- long lso = this->size();
- long n = this->shapei.n;
- long m = this->shapej.n;
- if( n !=nn && m != mm)
- {
- KNM_ <R> old(*this);
- long no=std::min(n,nn);
- long mo=std::min(m,mm);
- R *vo=this->v;
- ShapeOfArray::init(kk);
- this->v=new R[this->n];
- this->shapei.init(nn,1,nn);
- this->shapej.init(mm,nn,1);
- if(this->v && vo)
- (*this)(SubArray(no),SubArray(mo)) = old(SubArray(no),SubArray(mo));
- delete []vo;
- }
- }
- void destroy(){(static_cast<void> (0)); if(this->next++ ==-1) {delete [] this->v; this->v=0;this->n=0;}}
- void increment() {(static_cast<void> (0)); this->next--;}
-};
-template<class R>
-class KNMK: public KNMK_<R>{ public:
- KNMK(long n,long m,long k)
- :KNMK_<R>(new R[n*m*k],n,m,k){}
- explicit KNMK(const KNMK_<R> & u)
- :KNMK_<R>(new R[u.size()],u.N(),u.M(),u.K())
- { KNMK_<R>::operator=(u);}
- KNMK(const KNMK<R> & u)
- :KNMK_<R>(new R[u.size()],u.N(),u.M(),u.K())
- { KNMK_<R>::operator=(u);}
- ~KNMK(){delete [] this->v;}
- KNMK& operator=(const KNMK_<R> & u)
- { KNMK_<R>::operator=(u);return *this;}
- KNMK& operator=(R a)
- { KNMK_<R>::operator=(a);return *this;}
- KNMK& operator+=(R a)
- { KNMK_<R>::operator+=(a);return *this;}
- KNMK& operator-=(R a)
- { KNMK_<R>::operator-=(a);return *this;}
- KNMK& operator/=(R a)
- { KNMK_<R>::operator/=(a);return *this;}
- KNMK& operator*=(R a)
- { KNMK_<R>::operator*=(a);return *this;}
- KNMK& operator+=(const KNMK_<R> & u)
- { KNMK_<R>::operator+=(u);return *this;}
- KNMK& operator-=(const KNMK_<R> & u)
- { KNMK_<R>::operator-=(u);return *this;}
- KNMK& operator*=(const KNMK_<R> & u)
- { KNMK_<R>::operator*=(u);return *this;}
- KNMK& operator/=(const KNMK_<R> & u)
- { KNMK_<R>::operator/=(u);return *this;}
-};
-template<class R>
-class conj_KN_{public:
- const KN_<R> & a;
- conj_KN_(const KN_<R> & aa) : a(aa){}
-};
-inline const KN_<long> conj(const KN_<long> &a){ return a;}
-inline const KN_<double> conj(const KN_<double> &a){ return a;}
-inline const KN_<float> conj(const KN_<float> &a){ return a;}
-template<class R> conj_KN_<R> conj(const KN_<R> &a){ return a;}
-template<class R>
-class DotStar_KN_{public:
- const KN_<R> a; const KN_<R> b;
- DotStar_KN_(const KN_<R> & aa,const KN_<R> & bb) : a(aa),b(bb) {}
- };
-template<class R>
-class DotSlash_KN_{public:
- const KN_<R> a; const KN_<R> b;
- DotSlash_KN_(const KN_<R> & aa,const KN_<R> & bb) : a(aa),b(bb) {}
- };
-template<class R>
-class Add_KN_{public:
- const KN_<R> a; const KN_<R> b;
- Add_KN_(const KN_<R> & aa,const KN_<R> & bb)
- : a(aa),b(bb) { ;}
- };
-template<class R>
-class Sub_KN_{public:
- const KN_<R> a; const KN_<R> b;
- Sub_KN_(const KN_<R> & aa,const KN_<R> & bb)
- : a(aa),b(bb) { ;}
- };
-template<class R>
-class Mulc_KN_ { public:
- const KN_<R> a; R b;
- Mulc_KN_(const KN_<R> & aa,R bb) : a(aa),b(bb) {}
- Mulc_KN_(const Mulc_KN_<R> & aa,R bb) : a(aa.a),b(aa.b*bb) {}
- Mulc_KN_ operator-() const {return Mulc_KN_(a,-b);}
- outProduct_KN_<R> operator*(const TKN_<double> & bb)
-{ return outProduct_KN_<R>(a,bb,b);}
- };
-template<class R>
-class Add_Mulc_KN_ { public:
- const KN_<R> a,b;
- const R ca,cb;
- Add_Mulc_KN_(const Mulc_KN_<R> & aa,const Mulc_KN_<R> & bb)
- : a(aa.a),b(bb.a),ca(aa.b),cb(bb.b) { ;}
- Add_Mulc_KN_(const Mulc_KN_<R> & aa,const KN_<R> & bb,const R cbb)
- : a(aa.a),b(bb),ca(aa.b),cb(cbb) { ;}
- Add_Mulc_KN_(const KN_<R> & aa,const R caa,const KN_<R> & bb,const R cbb)
- : a(aa),b(bb),ca(caa),cb(cbb) { ;}
- };
-template<class R>
-class if_arth_KN_ { public:
- const KN_<R> a,b,c;
- if_arth_KN_(const KN_<R> & aa,const KN_<R> & bb,const KN_<R> & cc)
- : a(aa),b(bb),c(cc){ ;}
- };
-template<class R>
-class Mul_KNM_KN_ { public:
- const KNM_<R> &A;
- const KN_<R> &b;
- Mul_KNM_KN_(const KNM_<R> &aa,const KN_<R> &bb)
- : A(aa),b(bb) {;}
-};
-ostream & operator<<(ostream & f,const ShapeOfArray & s);
-template<class R> ostream & operator<<(ostream & f,const KN_<R> & v);
-template<class R> ostream & operator<<(ostream & f,const KNM_<R> & v);
-template<class R> ostream & operator<<(ostream & f,const KNMK_<R> & v);
-template<class R> inline ostream & operator<<(ostream & f,const KN<R> & v)
- { return f << (const KN_<R> &) v;}
-template<class R> inline ostream & operator<<(ostream & f,const KNM<R> & v)
- { return f << (const KNM_<R> &) v;}
-template<class R> inline ostream & operator<<(ostream & f,const KNMK<R> & v)
- { return f << (const KNMK_<R> &) v;}
-template<class R> inline Add_KN_<R> operator+(const KN_<R> &a,const KN_<R> &b)
- { return Add_KN_<R>(a,b);}
-template<class R> inline Sub_KN_<R> operator-(const KN_<R> &a,const KN_<R> &b)
- { return Sub_KN_<R>(a,b);}
-template<class R> inline Mulc_KN_<R> operator*(const KN_<R> &a,const R &b)
- { return Mulc_KN_<R>(a,b);}
-template<class R> inline Mulc_KN_<R> operator/(const KN_<R> &a,const R &b)
- { return Mulc_KN_<R>(a,1/b);}
-template<class R> inline Mulc_KN_<R> operator*(const R &b,const KN_<R> &a)
- { return Mulc_KN_<R>(a,b);}
-template<class R> inline Mulc_KN_<R> operator-(const KN_<R> &a)
- { return Mulc_KN_<R>(a,-1);}
-template<class R> inline Add_Mulc_KN_<R> operator+(const Mulc_KN_<R>& a,const Mulc_KN_<R> &b)
- { return Add_Mulc_KN_<R>(a,b);}
-template<class R> inline Add_Mulc_KN_<R> operator-(const Mulc_KN_<R>& a,const Mulc_KN_<R> &b)
- { return Add_Mulc_KN_<R>(a,b.a,-b.b);}
-template<class R> inline Add_Mulc_KN_<R> operator+(const Mulc_KN_<R>& a,const KN_<R> &b)
- { return Add_Mulc_KN_<R>(a,b,R(1));}
-template<class R> inline Add_Mulc_KN_<R> operator-(const Mulc_KN_<R>& a,const KN_<R> &b)
- { return Add_Mulc_KN_<R>(a,b,R(-1));}
-template<class R> inline Add_Mulc_KN_<R> operator+(const KN_<R> & b,const Mulc_KN_<R>& a)
- { return Add_Mulc_KN_<R>(a,b,R(1));}
-template<class R> inline Add_Mulc_KN_<R> operator-(const KN_<R> & a,const Mulc_KN_<R>& b)
- { return Add_Mulc_KN_<R>(a,R(1),b.a,-b.b);}
-template<class R> inline Mul_KNM_KN_<R> operator*(const KNM_<R> & A,const KN_<R> & b)
- { return Mul_KNM_KN_<R>(A,b);}
-template<class R> inline bool SameShape(const ShapeOfArray & a,const Add_Mulc_KN_<R> & b)
- { return SameShape(a,b.a) ;}
-template<class R> inline bool SameShape(const ShapeOfArray & a,const if_arth_KN_<R> & b)
- { return SameShape(a,b.a) ;}
-template<class R> inline bool SameShape(const ShapeOfArray & a,const Add_KN_<R> & b)
- { return SameShape(a,b.a) ;}
-template<class R> inline bool SameShape(const ShapeOfArray & a,const Sub_KN_<R> & b)
- { return SameShape(a,b.a) ;}
-template<class R> inline bool SameShape(const ShapeOfArray & a,const Mulc_KN_<R> & b)
- { return SameShape(a,b.a) ;}
-template<class R> inline bool SameShape(const ShapeOfArray & a,const DotStar_KN_<R> & b)
- { return SameShape(a,b.a) ;}
-template<class R> inline bool SameShape(const ShapeOfArray & a,const DotSlash_KN_<R> & b)
- { return SameShape(a,b.a) ;}
-template<class R> inline bool SameShape(const ShapeOfArray & a,const Mul_KNM_KN_<R> & b)
- { return a.n==b.A.N() ;}
- inline bool SameShape(const ShapeOfArray & ,const VirtualMatrice<double>::plusAx & )
- { return true ;}
- inline bool SameShape(const ShapeOfArray & ,const VirtualMatrice<double>::plusAtx & )
- { return true ;}
- inline bool SameShape(const ShapeOfArray & ,const VirtualMatrice<complex<double> >::plusAx & )
- { return true ;}
- inline bool SameShape(const ShapeOfArray & ,const VirtualMatrice<complex<double> >::plusAtx & )
- { return true ;}
- inline bool SameShape(const ShapeOfArray & ,const double)
- { return true;}
- inline bool SameShape(const ShapeOfArray & ,const complex<double>)
- { return true;}
- inline bool SameShape(const ShapeOfArray & ,const complex<float>)
- { return true;}
-template<class R>
- inline bool SameShape(KNM<R>& m, const outProduct_KN_<R>& p)
- { return p.a.N()>=m.N() && m.M()>=p.b.N(); }
-template<class R> inline long SameAdress(const KN_<R> &a, const KN_<R> &b) { return &a[0]==&b[0];}
-template<class R>
- PplusQ< typename VirtualMatrice<R>::plusAx, Mulc_KN_<R> > operator-(const typename VirtualMatrice<R>::plusAx & A,const KN_<R> & B)
- { return PplusQ< typename VirtualMatrice<R>::plusAx, Mulc_KN_<R> >(A,Mulc_KN_<R>(B,R(-1.)));}
-template<class R>
- PplusQ< typename VirtualMatrice<R>::plusAx, KN_<R> > operator+(const typename VirtualMatrice<R>::plusAx & A,const KN_<R> & B)
- { return PplusQ< typename VirtualMatrice<R>::plusAx, KN_<R> >(A,B);}
-template<class R>
- PplusQ< typename VirtualMatrice<R>::plusAx, Mulc_KN_<R> > operator-(const typename VirtualMatrice<R>::plusAx & A,const KN<R> & B)
- { return PplusQ< typename VirtualMatrice<R>::plusAx, Mulc_KN_<R> >(A,Mulc_KN_<R>(B,R(-1.)));}
-template<class R>
- PplusQ< typename VirtualMatrice<R>::plusAx, KN_<R> > operator+(const typename VirtualMatrice<R>::plusAx & A,const KN<R> & B)
- { return PplusQ< typename VirtualMatrice<R>::plusAx, KN_<R> >(A,B);}
-template<class R>
-KN_<R> diagonal(const KNM<R> & A) {
- ;
- return KN_<R>(A,SubArray(A.N(),0,A.N()+1));}
-class Inv_KN_long{ public:
- KN_<long> t;
- Inv_KN_long(const KN_<long> & v)
- : t(v) {}
- Inv_KN_long( KN_<long> const * & v)
- : t(*v) {}
- operator const KN_<long> & () const {return t;}
-};
-template<class R>
-class KN_2Ptr { public:
- KN_<R> a;
- const KN_<R> ca;
- KN<R> c;
- KN_2Ptr(KN_<R> & vv) : a(vv),ca(vv),c() { (static_cast<void> (0)); if (ca.step !=1 ) c=ca;}
- KN_2Ptr(const KN_<R> & vv) : a(0,0),ca(vv),c() { (static_cast<void> (0)); if (ca.step !=1 ) c=ca; }
- operator R *() { return c.unset() ? (R *) ca:(R *) c ;}
- operator const R *() const { return c.unset() ? (R *) ca:(R *) c ;}
- ~KN_2Ptr() { if(!a.unset() && !c.unset() ) {a=c; } }
-};
-template<class R,typename A,typename B=R> class F_KN_
-{
- public:
- A (*f)(B);
- KN_<R> a;
- long N() const {return a.N();}
- F_KN_( A (*ff)(B),const KN_<R> & aa): f(ff),a(aa) {}
- A operator[](long i) const { return f(a[i]);}
- bool check(long n) const { return n <= a.N() || a.constant(); }
- bool constant() const {return a.constant();}
-};
-template<class R,typename A,typename B>
-inline bool SameShape(const ShapeOfArray & a,const F_KN_<R,A,B> & b)
- { return !a.step || b.constant() || a.n == b.N() ;}
-namespace RNM {
-template <class T> inline double norm(const T & x){return std::norm(x);}
-inline double norm(double x){return x*x;}
-inline double norm(float x){return x*x;}
-inline long norm(long x){return x*x;}
-inline int norm(int x){return x*x;}
-}
-template<class R>
-void MatMul(KNM_<R> & ab, KNM_<R> & a, KNM_<R> & b){
- long N= a.shapei.n;
- long M= a.shapej.n;
- ;
- ;
- ;
- ;
- ;
- KN_<R> ai =a(0);
- for(long i=0;i<N;i++,++ai){
- KN_<R> bj=b[0];
- for(long j=0;j<M;j++,++bj)
- ab(i,j) = (ai , bj) ;}
-}
-inline ostream & operator<<(ostream & f,const ShapeOfArray & s)
- { f << s.n ;
- const int i10=10;
- int prec=f.precision();
- if(prec<i10) f.precision(i10);
- if(s.step != 1)
- f << ":" << s.step ;
- if (s.step*s.n != s.next )
- f << " n: " << setw(3) << s.next ;
- f << ",";
- if(prec<i10) f.precision(prec);
- return f;
- };
-template<class R> ostream & operator<<(ostream & f,const KN_<R> & v)
- {
- f << v.N() << "\t\n\t" ;
- const int i10=10;
- int prec=f.precision();
- if(prec<i10) f.precision(i10);
- for (long i=0;i<v.N();i++)
- f << setw(3) << v[i] << ((i % 5) == 4 ? "\n\t" : "\t");
- if(prec<i10) f.precision(prec);
- return f;
- };
-template<class R> istream & operator>>(istream & f, KN_<R> & v)
- {
- int n;char c;
- f >> n;
- ((f.good()) ? ( (void) 0) : throw(ErrorAssert("f.good()","../femlib/RNM_tpl.hpp", 108)));
- ((n==v.N()) ? ( (void) 0) : throw(ErrorAssert("n==v.N()","../femlib/RNM_tpl.hpp", 109)));
- while (f.get(c) && (c!='\n' && c!='\r' ) ) ;
- for (int i=0;i<n;i++)
- { f >> v[i] ;
- ((f.good()) ? ( (void) 0) : throw(ErrorAssert("f.good()","../femlib/RNM_tpl.hpp", 114)));}
- return f;
-}
-template<class R> istream & operator>>(istream & f, KN<R> & v)
- {
- int n;char c;
- f >> n;
- if (v.unset()) v.init(n);
- cout << n << " == " << v.N() << endl;
- ((n==v.N()) ? ( (void) 0) : throw(ErrorAssert("n==v.N()","../femlib/RNM_tpl.hpp", 124)));
- while (f.get(c) && (c!='\n' && c!='\r' ) ) ;
- for (int i=0;i<n;i++)
- {
- f >> v[i] ;
- ((f.good()) ? ( (void) 0) : throw(ErrorAssert("f.good()","../femlib/RNM_tpl.hpp", 130)));}
- return f;
-}
-template<class R> ostream & operator<<(ostream & f,const KNM_<R> & v)
- {
- const int i10=10;
- int prec=f.precision();
- if(prec<i10) f.precision(i10);
- f << v.N()<<' '<<v.M() << "\t\n\t" ;
- for (long i=0;i<v.N();i++) {
- for (long j=0;j<v.M();j++)
- f << " " << setw(3) << v(i,j);
- f << "\n\t";}
- if(prec<i10) f.precision(prec);
- return f;
- };
-template<class R> ostream & operator<<(ostream & f,const KNMK_<R> & v)
- {
- f << v.N()<< 'x' <<v.M()<< 'x'<<v.K() << "\t:\n\t" ;
- const int i10=10;
- int prec=f.precision();
- if(prec<i10) f.precision(i10);
- for (long i=0;i<v.shapei.n;i++){
- for (long j=0;j<v.shapej.n;j++){
- for (long k=0;k<v.shapek.n;k++)
- f << " " << setw(3) << v(i,j,k);
- f << "\n\t";}
- f << "\n\t";}
- if(prec<i10) f.precision(prec);
- return f;
- };
-template<class R>
- R KN_<R>::operator,(const KN_<R> & u) const {
- ;
- R s=0;
- R * l(v);
- R *r(u.v);
- for (long i=0;i<n;i++,l += step, r += u.step) s += *l * *r;
- return s;
- }
-template<class R>
- R operator,(const KN_<R> & u,const conj_KN_<R> & vc) {
- int n=u.n;
- ;
- R s=0;
- R * l(u);
- R *r(vc.a);
- int stepl= u.step, stepr=vc.a.step;
- for (long i=0;i<n;i++,l += stepl, r += stepr) s += *l * conj(*r);
- return s;
- }
-template<class R>
- R operator,(const conj_KN_<R> & u,const KN_<R> & vc) {
- int n=u.a.n;
- ;
- R s=0;
- R * l(u.a);
- R *r(vc);
- int stepl= u.a.step, stepr=vc.step;
- for (long i=0;i<n;i++,l += stepl, r += stepr) s += conj(*l) * (*r);
- return s;
- }
-template<class R>
- R operator,(const KN<R> & u,const conj_KN_<R> & vc) { return ( (KN_<R>) u,vc);}
-template<class R>
- R operator,(const conj_KN_<R> & u,const KN<R> & vc) { return ( u, (KN_<R>) vc);}
-template<class R>
-R KN_<R>::min() const {
- R minv = v[index(0)];
- for (long i=1;i<n;i++)
- minv = RNM::Min(minv, v[index(i)]) ;
- return minv;
- }
-template<class R>
-R KN_<R>::max() const {
- R maxv = v[index(0)];
- for (long i=1;i<n;i++)
- maxv = RNM::Max(maxv ,v[index(i)]);
- return maxv;
- }
-template<class R>
-R KN_<R>::sum() const {
- R s = v[index(0)];
- for (long i=1;i<n;i++)
- s += v[index(i)];
- return s;
- }
-template<class R>
-double KN_<R>::norm() const {
- double s = 0.;
- for (long i=0;i<n;i++)
- s += RNM::norm(v[index(i)]);
- return s;
- }
-template<class R>
-double KN_<R>::l2() const {
- double s = 0.;
- for (long i=0;i<n;i++)
- s += RNM::norm(v[index(i)]);
- return sqrt(s);
- }
-template<class R>
-double KN_<R>::l1() const {
- double s = 0.;
- for (long i=0;i<n;i++)
- s += std::abs(v[index(i)]);
- return (s);
- }
-template<class R>
-double KN_<R>::linfty() const {
- double s = 0.;
- for (long i=0;i<n;i++)
- s = std::max( (double) std::abs(v[index(i)]),s);
- return (s);
- }
-template<class R>
-double KN_<R>::lp(double p) const {
- if( p==1.) return l1();
- else if (p==2.) return l2();
- else if(p>1.e10) return linfty();
- else
- {
- double s = 0.;
- for (long i=0;i<n;i++)
- s = pow(std::max( (double) std::abs(v[index(i)]),s),p);
- return pow(s,1./p);
- }
- }
-template<class R> template<class T>
-long KN_<R>::last(const T & a) const {
- for (long i=n;i-- >0;)
- if (a(v[index(i)]))
- return i;
- return -1;
- }
-template<class R> template<class T>
-long KN_<R>::first(const T & a) const {
- for (long i=0;i<n;i++)
- if (a(v[index(i)])) return i;
- return n;
- }
-template<class R>
- void KN_<R>::map(R (*f)(R )) {
- for (long i=0;i<n;i++)
- { R & x(v[index(i)]);
- x = f(x);}
- }
-template<class R>
- void KN_<R>::map(R (*f)(const R& )) {
- for (long i=0;i<n;i++)
- { R & x(v[index(i)]);
- x = f(x);}
- }
-template<class R>
-template<class T>
- void KN_<R>::set(R (*f)(const T& ),KN_<T> & u)
- {
- ;
- for (long i=0;i<n;i++)
- { R & x(v[index(i)]);
- v[index(i)]= f(u[i]);}
- }
-template<class R>
-KNM_<R> & KNM_<R>::operator = (const outProduct_KN_<R> & u)
-{
- ;
- long n= N(), m= M();
- R * ai(u.a),cc, c= u.c;
- long stepi=u.a.step;
- R * bj, *bb(u.b);
- long stepj=u.b.step;
- KN_<R> li((*this)(0,'.'));
- int stepij= li.step;
- for (long i=0;i<n;i++,ai += stepi,++li)
- {
- cc= c * *ai;
- R * mij = li;
- bj = bb;
- for (long j=0; j<m; j++, bj += stepj, mij += stepij )
- *mij = cc * conj(*bj) ;
- }
- return *this;
- }
-template<class R>
-template<class A,class B,class C>
- KN_<R>& KN_<R>::operator = (const F_KN_<A,B,C> & u) {
- ;
- R * l(v);
- for (long i=0;i<n;i++,l += step)
- *l = u[i];
- return *this;}
-template<class R>
-KN_<R>& KN_<R>::operator = (const SetArray<R> & u) {
- R * l(v);
- for (long i=0;i<n;i++,l += step)
- *l = u[i];
-return *this;}
-template<class R>
- KN_<R>& KN_<R>::operator = (const Mul_KNM_KN_<R> & u) {
- ;
- R * l(v); KN_<R> li(u.A(0,'.'));
- for (long i=0;i<n;i++,l += step,++li)
- *l = (li,u.b);
- return *this;}
-template<class R>
- KN_<R>& KN_<R>::operator = (const DotStar_KN_<R> & u) {
- ;
- long stepa(u.a.step),stepb(u.b.step);
- R * l(v); R *aa(u.a), *bb(u.b);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb)
- *l = *aa * *bb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator = (const DotSlash_KN_<R> & u) {
- ;
- long stepa(u.a.step),stepb(u.b.step);
- R * l(v); R *aa(u.a), *bb(u.b);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb)
- *l = *aa / *bb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator = (const Add_KN_<R> & u) {
- ;
- long stepa(u.a.step),stepb(u.b.step);
- R * l(v); R *aa(u.a), *bb(u.b);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb)
- *l = *aa+*bb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator = (const Sub_KN_<R> & u) {
- ;
- long stepa(u.a.step),stepb(u.b.step);
- R * l(v); R *aa(u.a), *bb(u.b);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb)
- *l = *aa-*bb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator = (const Mulc_KN_<R> & u) {
- ;
- long stepa(u.a.step);
- R * l(v); R *aa(u.a),bb(u.b) ;
- for (long i=0;i<n;i++,l += step, aa +=stepa)
- *l = *aa * bb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator = (const Add_Mulc_KN_<R> & u) {
- ;
- const long stepa(u.a.step),stepb(u.b.step);
- const R ca(u.ca),cb(u.cb);
- R * l(v);
- const R *aa(u.a),*bb(u.b);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb)
- *l = *aa*ca + *bb*cb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator = (const if_arth_KN_<R> & u) {
- ;
- R zero=R();
- const long stepa(u.a.step),stepb(u.b.step),stepc(u.c.step);
- R * l(v);
- const R *aa(u.a),*bb(u.b),*cc(u.c);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb , cc += stepc)
- *l = ( (*aa != zero) ? *bb : *cc);
- return *this;
- }
-template<class R>
-inline KN_<R>& KN_<R>::operator = (R a) {
- R * l(v);
- for (long i=0;i<n;i++,l += step)
- *l = a;
- return *this;
- }
-template<class R>
-inline KNM_<R> & KNM_<R>::operator = (R a)
-{
- if(IsVector1() )
- KN_<R>::operator = (a);
- else {
- KN_<R> lj(operator()('.',0));
- for (long j=0;j<M();++j,++lj)
- lj = a;}
- return *this;
-}
-template<class R>
-inline KNMK_<R> & KNMK_<R>::operator = (R a)
-{
- if(IsVector1() )
- KN_<R>::operator = (a);
- else {
- KNM_<R> lj(operator()('.','.',0));
- long j=K();
- while(j--)
- {lj = a;++lj;}
- }
- return *this;
-}
-template<class R>
-inline KN_<R>& KN_<R>::operator = (const KN_<R> & u) {
- ;
- R * l(v);
- const R *r(u);
- for (long i=0;i<n;i++,l += step, r += u.step) *l = *r;
- return *this;
- }
-template<class R>
-inline KNM_<R> & KNM_<R>::operator = (const KNM_<R> & u)
-{
- if(IsVector1() && u.IsVector1() )
- KN_<R>::operator =(u);
- else {
- KN_<R> lj(operator()('.',0));
- KN_<R> uj(u('.',0));
- long j=M();
- while ( j--)
- { lj = uj;++lj;++uj;}
- }
- return *this;
-}
-template<class R>
-inline KNMK_<R> & KNMK_<R>::operator = (const KNMK_<R> & u)
-{
- if(IsVector1() && u.IsVector1() )
- KN_<R>::operator =(u);
- else {
- ;
- KNM_<R> lj(operator()('.','.',0));
- KNM_<R> uj(u('.','.',0));
- long j=K();
- while (j--)
- { lj = uj;++lj;++uj;}
- }
- return *this;
-}
-template<class R>
-KNM_<R> & KNM_<R>::operator += (const outProduct_KN_<R> & u)
-{
- ;
- long n= N(), m= M();
- R * ai(u.a),cc, c= u.c;
- long stepi=u.a.step;
- R * bj, *bb(u.b);
- long stepj=u.b.step;
- KN_<R> li((*this)(0,'.'));
- int stepij= li.step;
- for (long i=0;i<n;i++,ai += stepi,++li)
- {
- cc= c * *ai;
- R * mij = li;
- bj = bb;
- for (long j=0; j<m; j++, bj += stepj, mij += stepij )
- *mij += cc * conj(*bj) ;
- }
- return *this;
- }
-template<class R>
-template<class A,class B,class C>
- KN_<R>& KN_<R>::operator += (const F_KN_<A,B,C> & u) {
- ;
- R * l(v);
- for (long i=0;i<n;i++,l += step)
- *l += u[i];
- return *this;}
-template<class R>
-KN_<R>& KN_<R>::operator += (const SetArray<R> & u) {
- R * l(v);
- for (long i=0;i<n;i++,l += step)
- *l += u[i];
-return *this;}
-template<class R>
- KN_<R>& KN_<R>::operator += (const Mul_KNM_KN_<R> & u) {
- ;
- R * l(v); KN_<R> li(u.A(0,'.'));
- for (long i=0;i<n;i++,l += step,++li)
- *l += (li,u.b);
- return *this;}
-template<class R>
- KN_<R>& KN_<R>::operator += (const DotStar_KN_<R> & u) {
- ;
- long stepa(u.a.step),stepb(u.b.step);
- R * l(v); R *aa(u.a), *bb(u.b);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb)
- *l += *aa * *bb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator += (const DotSlash_KN_<R> & u) {
- ;
- long stepa(u.a.step),stepb(u.b.step);
- R * l(v); R *aa(u.a), *bb(u.b);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb)
- *l += *aa / *bb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator += (const Add_KN_<R> & u) {
- ;
- long stepa(u.a.step),stepb(u.b.step);
- R * l(v); R *aa(u.a), *bb(u.b);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb)
- *l += *aa+*bb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator += (const Sub_KN_<R> & u) {
- ;
- long stepa(u.a.step),stepb(u.b.step);
- R * l(v); R *aa(u.a), *bb(u.b);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb)
- *l += *aa-*bb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator += (const Mulc_KN_<R> & u) {
- ;
- long stepa(u.a.step);
- R * l(v); R *aa(u.a),bb(u.b) ;
- for (long i=0;i<n;i++,l += step, aa +=stepa)
- *l += *aa * bb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator += (const Add_Mulc_KN_<R> & u) {
- ;
- const long stepa(u.a.step),stepb(u.b.step);
- const R ca(u.ca),cb(u.cb);
- R * l(v);
- const R *aa(u.a),*bb(u.b);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb)
- *l += *aa*ca + *bb*cb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator += (const if_arth_KN_<R> & u) {
- ;
- R zero=R();
- const long stepa(u.a.step),stepb(u.b.step),stepc(u.c.step);
- R * l(v);
- const R *aa(u.a),*bb(u.b),*cc(u.c);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb , cc += stepc)
- *l += ( (*aa != zero) ? *bb : *cc);
- return *this;
- }
-template<class R>
-inline KN_<R>& KN_<R>::operator += (R a) {
- R * l(v);
- for (long i=0;i<n;i++,l += step)
- *l += a;
- return *this;
- }
-template<class R>
-inline KNM_<R> & KNM_<R>::operator += (R a)
-{
- if(IsVector1() )
- KN_<R>::operator += (a);
- else {
- KN_<R> lj(operator()('.',0));
- for (long j=0;j<M();++j,++lj)
- lj += a;}
- return *this;
-}
-template<class R>
-inline KNMK_<R> & KNMK_<R>::operator += (R a)
-{
- if(IsVector1() )
- KN_<R>::operator += (a);
- else {
- KNM_<R> lj(operator()('.','.',0));
- long j=K();
- while(j--)
- {lj += a;++lj;}
- }
- return *this;
-}
-template<class R>
-inline KN_<R>& KN_<R>::operator += (const KN_<R> & u) {
- ;
- R * l(v);
- const R *r(u);
- for (long i=0;i<n;i++,l += step, r += u.step) *l += *r;
- return *this;
- }
-template<class R>
-inline KNM_<R> & KNM_<R>::operator += (const KNM_<R> & u)
-{
- if(IsVector1() && u.IsVector1() )
- KN_<R>::operator +=(u);
- else {
- KN_<R> lj(operator()('.',0));
- KN_<R> uj(u('.',0));
- long j=M();
- while ( j--)
- { lj += uj;++lj;++uj;}
- }
- return *this;
-}
-template<class R>
-inline KNMK_<R> & KNMK_<R>::operator += (const KNMK_<R> & u)
-{
- if(IsVector1() && u.IsVector1() )
- KN_<R>::operator +=(u);
- else {
- ;
- KNM_<R> lj(operator()('.','.',0));
- KNM_<R> uj(u('.','.',0));
- long j=K();
- while (j--)
- { lj += uj;++lj;++uj;}
- }
- return *this;
-}
-template<class R>
-KNM_<R> & KNM_<R>::operator -= (const outProduct_KN_<R> & u)
-{
- ;
- long n= N(), m= M();
- R * ai(u.a),cc, c= u.c;
- long stepi=u.a.step;
- R * bj, *bb(u.b);
- long stepj=u.b.step;
- KN_<R> li((*this)(0,'.'));
- int stepij= li.step;
- for (long i=0;i<n;i++,ai += stepi,++li)
- {
- cc= c * *ai;
- R * mij = li;
- bj = bb;
- for (long j=0; j<m; j++, bj += stepj, mij += stepij )
- *mij -= cc * conj(*bj) ;
- }
- return *this;
- }
-template<class R>
-template<class A,class B,class C>
- KN_<R>& KN_<R>::operator -= (const F_KN_<A,B,C> & u) {
- ;
- R * l(v);
- for (long i=0;i<n;i++,l += step)
- *l -= u[i];
- return *this;}
-template<class R>
-KN_<R>& KN_<R>::operator -= (const SetArray<R> & u) {
- R * l(v);
- for (long i=0;i<n;i++,l += step)
- *l -= u[i];
-return *this;}
-template<class R>
- KN_<R>& KN_<R>::operator -= (const Mul_KNM_KN_<R> & u) {
- ;
- R * l(v); KN_<R> li(u.A(0,'.'));
- for (long i=0;i<n;i++,l += step,++li)
- *l -= (li,u.b);
- return *this;}
-template<class R>
- KN_<R>& KN_<R>::operator -= (const DotStar_KN_<R> & u) {
- ;
- long stepa(u.a.step),stepb(u.b.step);
- R * l(v); R *aa(u.a), *bb(u.b);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb)
- *l -= *aa * *bb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator -= (const DotSlash_KN_<R> & u) {
- ;
- long stepa(u.a.step),stepb(u.b.step);
- R * l(v); R *aa(u.a), *bb(u.b);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb)
- *l -= *aa / *bb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator -= (const Add_KN_<R> & u) {
- ;
- long stepa(u.a.step),stepb(u.b.step);
- R * l(v); R *aa(u.a), *bb(u.b);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb)
- *l -= *aa+*bb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator -= (const Sub_KN_<R> & u) {
- ;
- long stepa(u.a.step),stepb(u.b.step);
- R * l(v); R *aa(u.a), *bb(u.b);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb)
- *l -= *aa-*bb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator -= (const Mulc_KN_<R> & u) {
- ;
- long stepa(u.a.step);
- R * l(v); R *aa(u.a),bb(u.b) ;
- for (long i=0;i<n;i++,l += step, aa +=stepa)
- *l -= *aa * bb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator -= (const Add_Mulc_KN_<R> & u) {
- ;
- const long stepa(u.a.step),stepb(u.b.step);
- const R ca(u.ca),cb(u.cb);
- R * l(v);
- const R *aa(u.a),*bb(u.b);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb)
- *l -= *aa*ca + *bb*cb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator -= (const if_arth_KN_<R> & u) {
- ;
- R zero=R();
- const long stepa(u.a.step),stepb(u.b.step),stepc(u.c.step);
- R * l(v);
- const R *aa(u.a),*bb(u.b),*cc(u.c);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb , cc += stepc)
- *l -= ( (*aa != zero) ? *bb : *cc);
- return *this;
- }
-template<class R>
-inline KN_<R>& KN_<R>::operator -= (R a) {
- R * l(v);
- for (long i=0;i<n;i++,l += step)
- *l -= a;
- return *this;
- }
-template<class R>
-inline KNM_<R> & KNM_<R>::operator -= (R a)
-{
- if(IsVector1() )
- KN_<R>::operator -= (a);
- else {
- KN_<R> lj(operator()('.',0));
- for (long j=0;j<M();++j,++lj)
- lj -= a;}
- return *this;
-}
-template<class R>
-inline KNMK_<R> & KNMK_<R>::operator -= (R a)
-{
- if(IsVector1() )
- KN_<R>::operator -= (a);
- else {
- KNM_<R> lj(operator()('.','.',0));
- long j=K();
- while(j--)
- {lj -= a;++lj;}
- }
- return *this;
-}
-template<class R>
-inline KN_<R>& KN_<R>::operator -= (const KN_<R> & u) {
- ;
- R * l(v);
- const R *r(u);
- for (long i=0;i<n;i++,l += step, r += u.step) *l -= *r;
- return *this;
- }
-template<class R>
-inline KNM_<R> & KNM_<R>::operator -= (const KNM_<R> & u)
-{
- if(IsVector1() && u.IsVector1() )
- KN_<R>::operator -=(u);
- else {
- KN_<R> lj(operator()('.',0));
- KN_<R> uj(u('.',0));
- long j=M();
- while ( j--)
- { lj -= uj;++lj;++uj;}
- }
- return *this;
-}
-template<class R>
-inline KNMK_<R> & KNMK_<R>::operator -= (const KNMK_<R> & u)
-{
- if(IsVector1() && u.IsVector1() )
- KN_<R>::operator -=(u);
- else {
- ;
- KNM_<R> lj(operator()('.','.',0));
- KNM_<R> uj(u('.','.',0));
- long j=K();
- while (j--)
- { lj -= uj;++lj;++uj;}
- }
- return *this;
-}
-template<class R>
-KNM_<R> & KNM_<R>::operator *= (const outProduct_KN_<R> & u)
-{
- ;
- long n= N(), m= M();
- R * ai(u.a),cc, c= u.c;
- long stepi=u.a.step;
- R * bj, *bb(u.b);
- long stepj=u.b.step;
- KN_<R> li((*this)(0,'.'));
- int stepij= li.step;
- for (long i=0;i<n;i++,ai += stepi,++li)
- {
- cc= c * *ai;
- R * mij = li;
- bj = bb;
- for (long j=0; j<m; j++, bj += stepj, mij += stepij )
- *mij *= cc * conj(*bj) ;
- }
- return *this;
- }
-template<class R>
-template<class A,class B,class C>
- KN_<R>& KN_<R>::operator *= (const F_KN_<A,B,C> & u) {
- ;
- R * l(v);
- for (long i=0;i<n;i++,l += step)
- *l *= u[i];
- return *this;}
-template<class R>
-KN_<R>& KN_<R>::operator *= (const SetArray<R> & u) {
- R * l(v);
- for (long i=0;i<n;i++,l += step)
- *l *= u[i];
-return *this;}
-template<class R>
- KN_<R>& KN_<R>::operator *= (const Mul_KNM_KN_<R> & u) {
- ;
- R * l(v); KN_<R> li(u.A(0,'.'));
- for (long i=0;i<n;i++,l += step,++li)
- *l *= (li,u.b);
- return *this;}
-template<class R>
- KN_<R>& KN_<R>::operator *= (const DotStar_KN_<R> & u) {
- ;
- long stepa(u.a.step),stepb(u.b.step);
- R * l(v); R *aa(u.a), *bb(u.b);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb)
- *l *= *aa * *bb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator *= (const DotSlash_KN_<R> & u) {
- ;
- long stepa(u.a.step),stepb(u.b.step);
- R * l(v); R *aa(u.a), *bb(u.b);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb)
- *l *= *aa / *bb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator *= (const Add_KN_<R> & u) {
- ;
- long stepa(u.a.step),stepb(u.b.step);
- R * l(v); R *aa(u.a), *bb(u.b);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb)
- *l *= *aa+*bb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator *= (const Sub_KN_<R> & u) {
- ;
- long stepa(u.a.step),stepb(u.b.step);
- R * l(v); R *aa(u.a), *bb(u.b);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb)
- *l *= *aa-*bb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator *= (const Mulc_KN_<R> & u) {
- ;
- long stepa(u.a.step);
- R * l(v); R *aa(u.a),bb(u.b) ;
- for (long i=0;i<n;i++,l += step, aa +=stepa)
- *l *= *aa * bb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator *= (const Add_Mulc_KN_<R> & u) {
- ;
- const long stepa(u.a.step),stepb(u.b.step);
- const R ca(u.ca),cb(u.cb);
- R * l(v);
- const R *aa(u.a),*bb(u.b);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb)
- *l *= *aa*ca + *bb*cb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator *= (const if_arth_KN_<R> & u) {
- ;
- R zero=R();
- const long stepa(u.a.step),stepb(u.b.step),stepc(u.c.step);
- R * l(v);
- const R *aa(u.a),*bb(u.b),*cc(u.c);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb , cc += stepc)
- *l *= ( (*aa != zero) ? *bb : *cc);
- return *this;
- }
-template<class R>
-inline KN_<R>& KN_<R>::operator *= (R a) {
- R * l(v);
- for (long i=0;i<n;i++,l += step)
- *l *= a;
- return *this;
- }
-template<class R>
-inline KNM_<R> & KNM_<R>::operator *= (R a)
-{
- if(IsVector1() )
- KN_<R>::operator *= (a);
- else {
- KN_<R> lj(operator()('.',0));
- for (long j=0;j<M();++j,++lj)
- lj *= a;}
- return *this;
-}
-template<class R>
-inline KNMK_<R> & KNMK_<R>::operator *= (R a)
-{
- if(IsVector1() )
- KN_<R>::operator *= (a);
- else {
- KNM_<R> lj(operator()('.','.',0));
- long j=K();
- while(j--)
- {lj *= a;++lj;}
- }
- return *this;
-}
-template<class R>
-inline KN_<R>& KN_<R>::operator *= (const KN_<R> & u) {
- ;
- R * l(v);
- const R *r(u);
- for (long i=0;i<n;i++,l += step, r += u.step) *l *= *r;
- return *this;
- }
-template<class R>
-inline KNM_<R> & KNM_<R>::operator *= (const KNM_<R> & u)
-{
- if(IsVector1() && u.IsVector1() )
- KN_<R>::operator *=(u);
- else {
- KN_<R> lj(operator()('.',0));
- KN_<R> uj(u('.',0));
- long j=M();
- while ( j--)
- { lj *= uj;++lj;++uj;}
- }
- return *this;
-}
-template<class R>
-inline KNMK_<R> & KNMK_<R>::operator *= (const KNMK_<R> & u)
-{
- if(IsVector1() && u.IsVector1() )
- KN_<R>::operator *=(u);
- else {
- ;
- KNM_<R> lj(operator()('.','.',0));
- KNM_<R> uj(u('.','.',0));
- long j=K();
- while (j--)
- { lj *= uj;++lj;++uj;}
- }
- return *this;
-}
-template<class R>
-KNM_<R> & KNM_<R>::operator /= (const outProduct_KN_<R> & u)
-{
- ;
- long n= N(), m= M();
- R * ai(u.a),cc, c= u.c;
- long stepi=u.a.step;
- R * bj, *bb(u.b);
- long stepj=u.b.step;
- KN_<R> li((*this)(0,'.'));
- int stepij= li.step;
- for (long i=0;i<n;i++,ai += stepi,++li)
- {
- cc= c * *ai;
- R * mij = li;
- bj = bb;
- for (long j=0; j<m; j++, bj += stepj, mij += stepij )
- *mij /= cc * conj(*bj) ;
- }
- return *this;
- }
-template<class R>
-template<class A,class B,class C>
- KN_<R>& KN_<R>::operator /= (const F_KN_<A,B,C> & u) {
- ;
- R * l(v);
- for (long i=0;i<n;i++,l += step)
- *l /= u[i];
- return *this;}
-template<class R>
-KN_<R>& KN_<R>::operator /= (const SetArray<R> & u) {
- R * l(v);
- for (long i=0;i<n;i++,l += step)
- *l /= u[i];
-return *this;}
-template<class R>
- KN_<R>& KN_<R>::operator /= (const Mul_KNM_KN_<R> & u) {
- ;
- R * l(v); KN_<R> li(u.A(0,'.'));
- for (long i=0;i<n;i++,l += step,++li)
- *l /= (li,u.b);
- return *this;}
-template<class R>
- KN_<R>& KN_<R>::operator /= (const DotStar_KN_<R> & u) {
- ;
- long stepa(u.a.step),stepb(u.b.step);
- R * l(v); R *aa(u.a), *bb(u.b);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb)
- *l /= *aa * *bb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator /= (const DotSlash_KN_<R> & u) {
- ;
- long stepa(u.a.step),stepb(u.b.step);
- R * l(v); R *aa(u.a), *bb(u.b);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb)
- *l /= *aa / *bb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator /= (const Add_KN_<R> & u) {
- ;
- long stepa(u.a.step),stepb(u.b.step);
- R * l(v); R *aa(u.a), *bb(u.b);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb)
- *l /= *aa+*bb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator /= (const Sub_KN_<R> & u) {
- ;
- long stepa(u.a.step),stepb(u.b.step);
- R * l(v); R *aa(u.a), *bb(u.b);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb)
- *l /= *aa-*bb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator /= (const Mulc_KN_<R> & u) {
- ;
- long stepa(u.a.step);
- R * l(v); R *aa(u.a),bb(u.b) ;
- for (long i=0;i<n;i++,l += step, aa +=stepa)
- *l /= *aa * bb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator /= (const Add_Mulc_KN_<R> & u) {
- ;
- const long stepa(u.a.step),stepb(u.b.step);
- const R ca(u.ca),cb(u.cb);
- R * l(v);
- const R *aa(u.a),*bb(u.b);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb)
- *l /= *aa*ca + *bb*cb;
- return *this;
- }
-template<class R>
- KN_<R>& KN_<R>::operator /= (const if_arth_KN_<R> & u) {
- ;
- R zero=R();
- const long stepa(u.a.step),stepb(u.b.step),stepc(u.c.step);
- R * l(v);
- const R *aa(u.a),*bb(u.b),*cc(u.c);
- for (long i=0;i<n;i++,l += step, aa +=stepa, bb += stepb , cc += stepc)
- *l /= ( (*aa != zero) ? *bb : *cc);
- return *this;
- }
-template<class R>
-inline KN_<R>& KN_<R>::operator /= (R a) {
- R * l(v);
- for (long i=0;i<n;i++,l += step)
- *l /= a;
- return *this;
- }
-template<class R>
-inline KNM_<R> & KNM_<R>::operator /= (R a)
-{
- if(IsVector1() )
- KN_<R>::operator /= (a);
- else {
- KN_<R> lj(operator()('.',0));
- for (long j=0;j<M();++j,++lj)
- lj /= a;}
- return *this;
-}
-template<class R>
-inline KNMK_<R> & KNMK_<R>::operator /= (R a)
-{
- if(IsVector1() )
- KN_<R>::operator /= (a);
- else {
- KNM_<R> lj(operator()('.','.',0));
- long j=K();
- while(j--)
- {lj /= a;++lj;}
- }
- return *this;
-}
-template<class R>
-inline KN_<R>& KN_<R>::operator /= (const KN_<R> & u) {
- ;
- R * l(v);
- const R *r(u);
- for (long i=0;i<n;i++,l += step, r += u.step) *l /= *r;
- return *this;
- }
-template<class R>
-inline KNM_<R> & KNM_<R>::operator /= (const KNM_<R> & u)
-{
- if(IsVector1() && u.IsVector1() )
- KN_<R>::operator /=(u);
- else {
- KN_<R> lj(operator()('.',0));
- KN_<R> uj(u('.',0));
- long j=M();
- while ( j--)
- { lj /= uj;++lj;++uj;}
- }
- return *this;
-}
-template<class R>
-inline KNMK_<R> & KNMK_<R>::operator /= (const KNMK_<R> & u)
-{
- if(IsVector1() && u.IsVector1() )
- KN_<R>::operator /=(u);
- else {
- ;
- KNM_<R> lj(operator()('.','.',0));
- KNM_<R> uj(u('.','.',0));
- long j=K();
- while (j--)
- { lj /= uj;++lj;++uj;}
- }
- return *this;
-}
-inline double pow(double x,long l) { return pow(x,(double)l);}
-template<class R,class A=R>
-struct Op1_neg: public unary_function<A,R> {
- static R f(const A & a) { return - (R)a;} };
-template<class R,class A=R>
-struct Op1_plus: public unary_function<A,R> {
- static R f(const A & a) { return + (R)a;} };
-template<class A>
-struct Op1_not: public unary_function<A,bool> {
- static bool f(const A & a) { return ! (bool)a;} };
-template<class R,class A=R,class B=A>
-struct Op2_add: public binary_function<A,B,R> {
- static R f(const A & a,const B & b) { return ((R)a + (R)b);} };
-template<class R,class A=R,class B=A>
-struct Op2_sub: public binary_function<A,B,R> {
- static R f(const A & a,const B & b) { return ((R)a - (R)b);} };
-template<class R,class A=R,class B=A>
-struct Op2_mul: public binary_function<A,B,R> {
- static R f(const A & a,const B & b) {
- return ((R)a * (R)b);} };
-template<class R,class A=R,class B=A>
-struct Op2_div: public binary_function<A,B,R> {
- static R f(const A & a,const B & b) {
- if (b == B())
- {cout << a << "/" << b << " : " << typeid(A).name() << " " << typeid(B).name()
- << " " << typeid(R).name() << endl;ExecError(" Div by 0");}
- return ((R)a / (R)b);} };
-template<class R,class A=R,class B=A>
-struct Op2_mod: public binary_function<A,B,R> {
- static R f(const A & a,const B & b) { return ((R)a % (R)b);} };
-template<class A,class B=A>
-struct Op2_lt: public binary_function<A,B,bool> {
- static bool f(const A & a,const B & b) {
- return a < b;} };
-template<class A,class B=A>
-struct Op2_le: public binary_function<A,B,bool> {
- static bool f(const A & a,const B & b) { return a <= b;} };
-template<class A,class B=A>
-struct Op2_gt: public binary_function<A,B,bool> {
- static bool f(const A & a,const B & b) { return a > b;} };
-template<class A,class B=A>
-struct Op2_ge: public binary_function<A,B,bool> {
- static bool f(const A & a,const B & b) { return a >= b;} };
-template<class A,class B=A>
-struct Op2_eq: public binary_function<A,B,bool> {
- static bool f(const A & a,const B & b)
- {
- return a == b;} };
-template<class A,class B=A>
-struct Op2_ne: public binary_function<A,B,bool> {
- static bool f(const A & a,const B & b) { return a != b;} };
-struct Op2_and: public binary_function<bool,bool,bool> {
- static bool f(const bool & a,const bool & b) { return a && b;} };
-struct Op2_or: public binary_function<bool,bool,bool> {
- static bool f(const bool & a,const bool & b) { return a || b;} };
-template<class R,class A,class B>
-struct Op2_padd: public binary_function<A,B,R*> {
- static R * f(Stack s,const A & a,const B & b) {
- R* r= Add2StackOfPtr2Free(s,new R (*a + *b));
- return r;} };
-template<class A,class B=A>
-struct Op2_plt: public binary_function<A,B,bool> {
- static bool f(const A & a,const B & b) { bool r= *a < *b;
- return r;} };
-template<class A,class B=A>
-struct Op2_ple: public binary_function<A,B,bool> {
- static bool f(const A & a,const B & b) { bool r= *a <= *b;
- return r;} };
-template<class A,class B=A>
-struct Op2_pgt: public binary_function<A,B,bool> {
- static bool f(const A & a,const B & b) { bool r= *a > *b;
- return r;} };
-template<class A,class B=A>
-struct Op2_pge: public binary_function<A,B,bool> {
- static bool f(const A & a,const B & b) { bool r= *a >= *b;
- return r;} };
-template<class A,class B=A>
-struct Op2_peq: public binary_function<A,B,bool> {
- static bool f(const A & a,const B & b) { bool r= *a == *b;
- return r;} };
-template<class A,class B=A>
-struct Op2_pne: public binary_function<A,B,bool> {
- static bool f(const A & a,const B & b) { bool r=*a != *b;
- return r;} };
-template<class R,class A=R,class B=A>
-struct Op2_pow: public binary_function<A,B,R> {
- static R f(const A & a,const B & b) { return R(pow(a,b));}};
-template<class A>
-struct Op_Read : public binary_function<istream*,A*,istream*> {
- static istream * f(istream * const & f,A * const & a)
- {
- *f >> *a;
- return f;
- }
-};
-template<class A>
-struct Op_ReadP : public binary_function<istream*,A**,istream*> {
- static istream * f(istream * const & f,A ** const & a)
- {
- (static_cast<void> (0));
- if( ! *a) *a= new A ;
- *f >> **a;
- return f;
- }
-};
-template<class A>
-struct Op_ReadKN : public binary_function<istream*,KN<A>*,istream*> {
- static istream * f(istream * const & f,KN<A>* const & a)
- {
- if( !f || !*f) ExecError("Fatal Error: file not open in read array (Op_ReadKN)");
- int n;char c;
- *f >> n;
- if(!f->good()) ExecError("Fatal Error: file not good in read array (Op_ReadKN)");
- if(n !=a->N()) {
- cout << " length on the array " << a->N() << " != " << n << " length in file " << endl;
- ExecError("Fatal Error: incompatible length in read array (Op_ReadKN)");
- (static_cast<void> (0));
- }
- while (f->get(c) && (c!='\n' && c!='\r' ) ) ((void) 0);
- for (int i=0;i<n;i++)
- *f >> (*a)[i] ;
- return f;
- }
-};
-template<class A>
-struct Print: public binary_function<ostream*,A,ostream*> {
- static ostream* f(ostream* const & a,const A & b) { *a << b; return a;}
-};
-template<class A>
-struct set_eq: public binary_function<A*,A,A*> {
- static A* f(A* const & a,const A & b) { *a = b; return a;}
-};
-template<class A,class B>
-struct set_eqq: public binary_function<A,B,A> {
- static A f(const A & a,const B & b) {A aa(a); aa = b; return aa;}
-};
-template<class A,class B>
-struct set_eqq_add: public binary_function<A,B,A> {
- static A f(const A & a,const B & b) {A aa(a); aa += b; return aa;}
-};
-template<class A>
-struct set_eq_add: public binary_function<A*,A,A*> {
- static A* f(A* const & a,const A & b) { *a += b; return a;}
-};
-template<class A>
-struct set_eq_sub: public binary_function<A*,A,A*> {
- static A* f(A* const & a,const A & b) { *a -= b; return a;}
-};
-template<class A>
-struct set_eq_mul: public binary_function<A*,A,A*> {
- static A* f(A* const & a,const A & b) { *a *= b; return a;}
-};
-template<class A>
-struct set_eq_div: public binary_function<A*,A,A*> {
- static A* f(A* const & a,const A & b) { *a /= b; return a;}
-};
-template<class A>
-struct set_peq: public binary_function<A**,A*,A**> {
- static A** f(A** const & a, A * const & b) {
- if(*a != b )
- {
- delete *a;
- *a = new A(*b);
- }
- return a;}
-};
-template<class A,class B>
-struct set_eqarrayp: public binary_function<A*,B,A*> {
- static A* f(A* const & a, B const & b) { *a = *b; return a;}
-};
-template<class A,class B>
-struct set_eqarrayp_add: public binary_function<A*,B,A*> {
- static A* f(A* const & a, B const & b) { (static_cast<void> (0)); *a += *b; return a;}
-};
-template<class A,class B>
-struct set_eqarrayp_sub: public binary_function<A*,B,A*> {
- static A* f(A* const & a, B const & b) { (static_cast<void> (0)); *a -= *b; return a;}
-};
-template<class A,class B>
-struct set_eqarrayp_mul: public binary_function<A*,B,A*> {
- static A* f(A* const & a, B const & b) { (static_cast<void> (0)); *a *= *b; return a;}
-};
-template<class A,class B>
-struct set_eqarrayp_div: public binary_function<A*,B,A*> {
- static A* f(A* const & a, B const & b) { (static_cast<void> (0)); *a /= *b; return a;}
-};
-template<class A,class B>
-struct set_eqarraypd: public binary_function<A*,B,A*> {
- static A* f(A* const & a, B const & b) {(static_cast<void> (0)); *a = *b;
- delete b;
- return a;}
-};
-template<class A,class B>
-struct set_eqarraypd_add: public binary_function<A*,B,A*> {
- static A* f(A* const & a, B const & b) {(static_cast<void> (0)); *a += *b;
- delete b;
- return a;}
-};
-template<class A,class B>
-struct set_eqarraypd_sub: public binary_function<A*,B,A*> {
- static A* f(A* const & a, B const & b) {(static_cast<void> (0)); *a -= *b;
- delete b;
- return a;}
-};
-template<class A,class B>
-struct set_eqarraypd_mul: public binary_function<A*,B,A*> {
- static A* f(A* const & a, B const & b) {(static_cast<void> (0)); *a *= *b;
- delete b;
- return a;}
-};
-template<class A,class B>
-struct set_eqarraypd_div: public binary_function<A*,B,A*> {
- static A* f(A* const & a, B const & b) {(static_cast<void> (0)); *a /= *b;
- delete b;
- return a;}
-};
-template<class A,class B>
-struct set_eqarray: public binary_function<A*,B,A*> {
- static A* f(A* const & a, B const & b)
- { *a = b;
- return a;}
-};
-template<class A,class B>
-struct init_eqarray: public binary_function<A*,B,A*> {
- static A* f(A* const & a, B const & b)
- { a->init(); *a = b;
- return a;}
-};
-template<class A,class B>
-struct init_eqarraypd: public binary_function<A*,B,A*> {
- static A* f(A* const & a, B const & b) {a->init(); *a = *b;
- delete b;
- return a;}
-};
-template<class A,class B>
-struct init_eqarrayp: public binary_function<A*,B,A*> {
- static A* f(A* const & a, B const & b) { a->init(); *a = *b; return a;}
-};
-template<class A,class B>
-struct set_eqarray_add: public binary_function<A*,B,A*> {
- static A* f(A* const & a, B const & b) {(static_cast<void> (0)); *a += b; return a;}
-};
-template<class A,class B>
-struct set_eqarray_sub: public binary_function<A*,B,A*> {
- static A* f(A* const & a, B const & b) {(static_cast<void> (0)); *a -= b; return a;}
-};
-template<class A,class B>
-struct set_eqarray_mul: public binary_function<A*,B,A*> {
- static A* f(A* const & a, B const & b) {(static_cast<void> (0)); *a *= b; return a;}
-};
-template<class A,class B>
-struct set_eqarray_div: public binary_function<A*,B,A*> {
- static A* f(A* const & a, B const & b) {(static_cast<void> (0)); *a /= b; return a;}
-};
-template<class A,class B>
-struct set_eq_array: public binary_function<A,B,A> {
- static A f(const A & a, B const & b)
- { A aa=a;aa = b;
- return a;}
-};
-template<class A,class B>
-struct set_eq_array_add: public binary_function<A,B,A> {
- static A f(A const & a, B const & b) {(static_cast<void> (0)); A aa(a); aa += b; return a;}
-};
-template<class A,class B>
-struct set_eq_array_sub: public binary_function<A,B,A> {
- static A f(A const & a, B const & b) {(static_cast<void> (0)); A aa(a); aa -= b; return a;}
-};
-template<class A,class B>
-struct set_eq_array_mul: public binary_function<A,B,A> {
- static A f(A const & a, B const & b) {(static_cast<void> (0)); A aa(a); aa *= b; return a;}
-};
-template<class A,class B>
-struct set_eq_array_div: public binary_function<A,B,A> {
- static A f(A const & a, B const & b) {(static_cast<void> (0)); A aa(a); aa /= b; return a;}
-};
-template<class A,class B>
-struct set_eq_arrayp: public binary_function<A,B,A> {
- static A f(A const & a, B const & b) { A aa(a); aa = *b; return a;}
-};
-template<class A,class B>
-struct set_eq_arraypd: public binary_function<A,B,A> {
- static A f(A const & a, B const & b) {(static_cast<void> (0));A aa(a); aa = *b;
- delete b;
- return a;}
-};
-template<class A,class B>
-struct set_eq_arrayp_sub: public binary_function<A,B,A> {
- static A f(A const & a, B const & b) { (static_cast<void> (0)); A aa(a); aa -= *b; return a;}
-};
-template<class A,class B>
-struct set_eq_arrayp_mul: public binary_function<A,B,A> {
- static A f(A const & a, B const & b) { (static_cast<void> (0)); A aa(a); aa *= *b; return a;}
-};
-template<class A,class B>
-struct set_eq_arrayp_div: public binary_function<A,B,A> {
- static A f(A const & a, B const & b) { (static_cast<void> (0)); A aa(a); aa /= *b; return a;}
-};
-template<class A,class B>
-struct set_eq_arrayp_add: public binary_function<A,B,A> {
- static A f(A const & a, B const & b) { (static_cast<void> (0)); A aa(a); aa += *b; return a;}
-};
-template<class A,class B>
-struct set_eq_arraypd_add: public binary_function<A,B,A> {
- static A f(A const & a, B const & b) {(static_cast<void> (0)); A aa(a); aa += *b;
- delete b;
- return a;}
-};
-template<class A,class B>
-struct set_eq_arraypd_sub: public binary_function<A,B,A> {
- static A f(A const & a, B const & b) {(static_cast<void> (0)); A aa(a); aa -= *b;
- delete b;
- return a;}
-};
-template<class A,class B>
-struct set_eq_arraypd_mul: public binary_function<A,B,A> {
- static A f(A const & a, B const & b) {(static_cast<void> (0)); A aa(a); aa *= *b;
- delete b;
- return a;}
-};
-template<class A,class B>
-struct set_eq_arraypd_div: public binary_function<A,B,A> {
- static A f(A const & a, B const & b) {(static_cast<void> (0)); A aa(a); aa /= *b;
- delete b;
- return a;}
-};
-template<class A>
-struct PrintP: public binary_function<ostream*,A,ostream*> {
- static ostream* f(ostream* const & a,const A & b) { *a << *b;
- return a;}
-};
-template<class A>
-struct PrintPnd: public binary_function<ostream*,A,ostream*> {
- static ostream* f(ostream* const & a,const A & b)
- { *a << *b; return a;}
-};
-template<class R,class A> R * set_eqP(R* a,A b){
- if (*a != b) delete (*a) ;
- ( *a =b); return a;}
-template<class R,class A> R * set_eqdestroy(R* a,A b){
- if (*a != b) (**a).destroy() ;
- ( *a =b); return a;}
-template<class R,class A> R * set_eqdestroy_incr(R* a,A b){
- if(b) (*b).increment() ;
- if(*a) (**a).destroy() ;
- ( *a =b); return a;}
-template<class R> R * set_copy( R* const & a,const R & b){
- ( (void)0);
- memcpy(a,&b,sizeof(R)); return a;}
-template<class R> R * set_copyp( R* const & a,const R & b){
- ( (void)0);
- *a = b;
- return a;}
-template<class R> R ** set_copyp_new( R** a,R* b){
- ( (void)0);
- *a = new R(*b);
- return a;
- }
-template<class R> R ** set_copy_incr( R** const & a, R * const & b){
- *a=b;
- if(b) b->increment();
- return a;}
-template<class R,class A> R * set_init2( R* const & a,const A & b,const A & c){
- ( (void)0);
- a->init(b,c); return a;}
-template<class R,class A> R * set_init( R* const & a,const A & b){
- ( (void)0);
- a->init(b); return a;}
-template<class R,class A> R * set_initp( R* const & a,const A & b){
- ( (void)0);
- a->init(*b); return a;}
-template<class R,class A=R,class B=A>
-struct Op2_add0: public binary_function<A,B,R> {
- static R f(const A & a,const B & b) { return (a + b);} };
-template<class R,class A=R,class B=A>
-struct Op2_build: public binary_function<A,B,R> {
- static R f(const A & a,const B & b) { return R(a,b);} };
-template<class R,class A=R,class B=A>
-struct Op2_pbuild: public binary_function<A,B,R*> {
- static R *f(const A & a,const B & b) { return new R(a,b);} };
-template<class R,class A=R,class B=A>
-struct Op2_add__n: public binary_function<A,B,R*> {
- static R * f(const A & a,const B & b) { return new R(a + b);} };
-template<class R,class A=R,class B=A>
-struct Op2_addp_n: public binary_function<A,B,R*> {
- static R* f(const A & a,const B & b) { return new R(*a + b);} };
-template<class R,class A=R,class B=A>
-struct Op2_add_pn: public binary_function<A,B,R*> {
- static R* f(const A & a,const B & b) { return new R(a + *b);} };
-template<class R,class A=R,class B=A>
-struct Op2_sub0: public binary_function<A,B,R> {
- static R f(const A & a,const B & b) { return (a - b);} };
-template<class R,class A=R>
-struct Op1_subp: public unary_function<A,R> {
- static R f(const A & a) { return (- *a );} };
-template<class R,class A=R>
-struct Op1_sub: public unary_function<A,R> {
-static R f(const A & a) { return (- a );} };
-template<class R,class A=R,class B=A>
-struct Op2_mulcp: public binary_function<A,B,R> {
- static R f(const A & a,const B & b) { return (a * *b);} };
-template<class R,class A=R,class B=A>
-struct Op2_mulc: public binary_function<A,B,R> {
- static R f(const A & a,const B & b) { return (a * b);} };
-template<class R,class A=R,class B=A>
-struct Op2_mulpc: public binary_function<A,B,R> {
- static R f(const A & a,const B & b) { return (b * *a);} };
-template<class R,class A=R,class B=A>
-struct Op2_mulpcp: public binary_function<A,B,R> {
- static R f(const A & a,const B & b) { return (*a * *b);} };
-template<class R,class A=R,class B=A>
-struct Op2_sub__n: public binary_function<A,B,R*> {
- static R * f(const A & a,const B & b) { return new R(a - b);} };
-template<class R,class A=R,class B=A>
-struct Op2_subp_n: public binary_function<A,B,R*> {
- static R* f(const A & a,const B & b) { return new R(*a - b);} };
-template<class R,class A=R,class B=A>
-struct Op2_sub_pn: public binary_function<A,B,R*> {
- static R* f(const A & a,const B & b) { return new R(a - *b);} };
-template<class R,class A=R,class B=A,class C=A>
-struct Op3_p: public ternary_function<A,B,C,R*> {
- static R* f(Stack s,const A & a,const B & b,const C & c ) { return new R(a,b,c);} };
-template<class R,class A=R,class B=A>
-struct Op2_p: public binary_function<A,B,R*> {
- static R* f(const A & a,const B & b) { return new R(a,b);} };
-template<class T>
-class Transpose{ public:
- T t;
- Transpose( T v)
- : t(v) {}
- template<class TT> Transpose( TT v) : t(v) {}
- template<class TT> Transpose( TT * v) : t(*v) {}
- operator const T & () const {return t;}
-};
-extern void (*getcadre) (float &xmin,float &xmax, float &ymin, float &ymax) ;
-extern void (*GetScreenSize) (int &ix,int &iy) ;
-extern char (*Getxyc) (float &x,float &y) ;
-extern void (*ShowHelp) (const char * s,int k) ;
-extern void (*erreur) (char *s) ;
-extern void (*initgraphique) () ;
-extern void (*closegraphique) () ;
-extern void (*showgraphic) () ;
-extern void (*rattente) (int waitm) ;
-extern void (*cadre) (float xmin,float xmax, float ymin, float ymax) ;
-extern void (*cadreortho) (float centrex, float centrey, float rayon) ;
-extern void (*couleur) (int c) ;
-extern int (*LaCouleur) () ;
-extern void (*pointe) (float x, float y) ;
-extern int (*InPtScreen) (float x, float y) ;
-extern int (*InRecScreen) (float x1, float y1,float x2, float y2) ;
-extern void (*plotstring) (const char *s) ;
-extern void (*rmoveto) (float x, float y) ;
-extern void (*rlineto) (float x, float y) ;
-extern void (*penthickness) (int ) ;
-extern int (*execute) (const char* s) ;
-extern void (*reffecran) () ;
-extern void (*fillpoly) (int n, float *poly) ;
-extern void (*SetColorTable) (int nb) ;
-extern void (*SetColorTable1) (int nb,bool hsv,int nbcolors,float *colors) ;
-extern float (*GetHeigthFont) () ;
-extern void (*openPS) (const char * ) ;
-extern void (*closePS) (void) ;
-extern void (*coutmode) (short i) ;
-extern void (*myexit) (int err) ;
-extern void (*viderbuff) () ;
-extern void (*Commentaire) (const char *) ;
-extern void (*NoirEtBlanc) (int NB) ;
-extern void (*MettreDansPostScript) (int in) ;
-extern int (*getprog) (char* fn,int , char** argvptr) ;
-extern void (*setgrey) (bool ) ;
-extern int (*getgrey) ( ) ;
-void addInitFunct(int i,void (* f)()) ;
-void callInitsFunct() ;
-struct addingInitFunct {
- addingInitFunct(int i,void (* f)()) { addInitFunct(i,f);}
-} ;
-template<class T> struct Resize{ T *v;
- Resize( T * vv) : v(vv) {}
- };
-template<class T> T *resize1(const Resize<T> & t,const long &n)
- {
- t.v->resize(n);
- return t.v;
- }
-template<class T> T *resizeandclean1(const Resize<T> & t,const long &n)
- {
- int nn= t.v->N();
- for (int i=n;i<nn;i++) {delete (*t.v)[i];}
- t.v->resize(n);
- for (int i=nn;i<n;i++) {(*t.v)[i]=0;}
- return t.v;
- }
-template<class T> T *resize2(const Resize<T> & t,const long &n, const long & m)
- {
- t.v->resize(n,m);
- return t.v;
- }
-template<class T> Resize<T> to_Resize( T *v){ return Resize<T>(v);}
-template<class T>
-void HeapSort(T *c,long n)
-{
- long l,j,r,i;
- T crit;
- c--;
- if( n <= 1) return;
- l = n/2 + 1;
- r = n;
- while (1) {
- if(l <= 1 ) {
- crit = c[r];
- c[r--] = c[1];
- if ( r == 1 ) { c[1]=crit; return;}
- } else crit = c[--l];
- j=l;
- while (1) {
- i=j;
- j=2*j;
- if (j>r) {c[i]=crit;break;}
- if ((j<r) && (c[j] < c[j+1])) j++;
- if (crit < c[j]) c[i]=c[j];
- else {c[i]=crit;break;}
- }
- }
-}
-template<class K,class T>
-void HeapSort(K *k,T *t,long n)
-{
- long l,j,r,i;
- K kk;
- T tt;
- k--;t--;
- if( n <= 1) return;
- l = n/2 + 1;
- r = n;
- while (1) {
- if(l <= 1 ) {
- kk = k[r];
- tt = t[r];
- t[r]=t[1];
- k[r--] = k[1];
- if ( r == 1 ) { k[1]=kk;t[1]=tt; return;}
- } else {kk = k[--l];tt=t[l]; }
- j=l;
- while (1) {
- i=j;
- j=2*j;
- if (j>r) {k[i]=kk;t[i]=tt;break;}
- if ((j<r) && (k[j] < k[j+1])) j++;
- if (kk < k[j]) {k[i]=k[j];t[i]=t[j];}
- else {k[i]=kk;t[i]=tt;break;}
- }
- }
-}
-template <class T>
-struct affectation: binary_function<T, T, T>
-{
- T& operator()(T& x, const T& y) const {return (x=y);}
-};
-template <class T>
-struct affectation_add: binary_function<T, T, T>
-{
- T& operator()(T& x, const T& y) const {return (x=+y);}
-};
-template <class T>
-struct affectation_sub: binary_function<T, T, T>
-{
- T& operator()(T& x, const T& y) const {return (x=-y);}
-};
-extern Map_type_of_map map_type_of_map ;
-extern Map_type_of_map map_pair_of_type ;
-extern basicForEachType * typevarreal, * typevarcomplex;
-extern int TheCurrentLine;
-extern long mpisize,mpirank;
-template<class T> inline T Max (const T &a,const T & b){return a > b ? a : b;}
-template<class T> inline T Min (const T &a,const T & b){return a < b ? a : b;}
-template<class T> inline T Abs (const T &a){return a <0 ? -a : a;}
-template<class T> inline T Max (const T &a,const T & b,const T & c){return Max(Max(a,b),c);}
-template<class T> inline T Min (const T &a,const T & b,const T & c){return Min(Min(a,b),c);}
-template<class T> inline T Square (const T &a){return a*a;}
-template<class K>
-struct Op2_dotproduct: public binary_function<Transpose<KN_<K> >,KN<K> *,K> {
- static K f( Transpose<KN_<K> > const & a, KN<K> * const& b)
- { return (conj(a.t),*b);} };
-template<class K>
-struct Op2_dotproduct_: public binary_function<Transpose<KN_<K> >,KN_<K> ,K> {
- static K f( Transpose<KN_<K> > const & a, KN_<K> const& b)
- { return (conj(a.t),b);} };
-template<class A,class B> A Build(B b) { return A(b);}
-template<class T>
-void HeapSort(T *c,long n,long o)
-{
- long l,j,r,i;
- T crit;
- c-=o;
- if( n <= 1) return;
- l = (n/2 + 1)*o;
- r = n*o;
- while (1) {
- if(l <= o ) {
- crit = c[r];
- c[r] = c[o];
- r-=o;
- if ( r == o ) { c[o]=crit; return;}
- } else crit = c[l-=o];
- j=l;
- while (1) {
- i=j;
- j=2*j;
- if (j>r) {c[i]=crit;break;}
- if ((j<r) && (c[j] < c[j+o])) j+=o;
- if (crit < c[j]) c[i]=c[j];
- else {c[i]=crit;break;}
- }
- }
-}
-template<class R,class A> A SortKn(const A & ca)
-{
- A a(ca);
- HeapSort<R>(&a[0],a.n,a.step);
- return a;}
-template<class R,class RR,class A,class B> A SortKn(const A & ca,const B & cb)
-{
- cout << "SortKn " << endl;
- const A &a(ca);
- const B &b(cb);
- ((a.n == b.n) ? ( (void) 0) : throw(ErrorAssert("a.n == b.n","array_tlp.hpp", 139)));
- ((a.step == b.step && b.step ==1) ? ( (void) 0) : throw(ErrorAssert("a.step == b.step && b.step ==1","array_tlp.hpp", 140)));
- HeapSort<R,RR>(&a[0],&b[0],a.n);
- cout << b << endl;
-return a;}
-template<class R,class RR> KN<R> * SortpKn2( KN<R> * const & pa,KN<RR> * const & pb){
- KN<R> &a(*pa);
- KN<RR> &b(*pb);
- ((a.n == b.n) ? ( (void) 0) : throw(ErrorAssert("a.n == b.n","array_tlp.hpp", 149)));
- ((a.step == b.step && b.step ==1) ? ( (void) 0) : throw(ErrorAssert("a.step == b.step && b.step ==1","array_tlp.hpp", 150)));
- HeapSort<R,RR>(&a[0],&b[0],a.n);
- return pa;}
-template<class R> KN<R> * SortpKn( KN<R> * const & pa){
- KN<R> &a(*pa);
- HeapSort<R>(&a[0],a.n,a.step);
- return pa;}
-template<class R>
-class QuantileKN: public KN_<R> { public:
- QuantileKN(const KN_<R> &a): KN_<R>(a) {}
- QuantileKN(KN<R> * p): KN_<R>(*p) {}
- operator R *() const {return this->KN_<R>::operator R *() ;}
-};
-template<class R> R Quantile(QuantileKN<R> const & a,const double & q){
- KN<R> b(a);
- HeapSort<R>(b,b.n,b.step);
- long m=lrint(b.n*q);
- if( m >= b.n) m=b.n-1;
- if( m < 0) m=0;
- R qq=b[m];
- return qq;}
-inline void MyAssert(int i,char * ex,char * file,long line)
-{if (i) {
- cout << "CompileError assertion : " << ex << " in file " << file << " line = " << line << endl;
- CompileError();}
- }
-template<class K>
-inline K * get_element( MyMap<String,K> * const & a,string* const & b)
- { K * ret= &((*a)[*b]);
- return ret;}
-template<>
-inline string ** get_element<string*>( MyMap<String,string*> * const & a,string* const & b)
- { string** ret= &((*a)[*b]);
- if( *ret ==0) *ret = new string("");
- return ret;}
-inline string ** get_elements( MyMap<String,String> * const & a,string* const & b)
- { String* Sret= &((*a)[*b]);
- return Sret->getap();}
-template<class RR,class A,class B>
-RR * get_element_(const A & a,const B & b){
- if( b<0 || a.N() <= b)
- { cout << " Out of bound 0 <=" << b << " < " << a.N() << " array type = " << typeid(A).name() << endl;
- ExecError("Out of bound in operator []");}
- return &((a)[b]);}
-template<class RR,class A,class B>
-RR * get_elementp_(const A & a,const B & b){
- if( b<0 || a->N() <= b)
- { cout << " Out of bound 0 <=" << b << " < " << a->N() << " array type = " << typeid(A).name() << endl;
- ExecError("Out of bound in operator []");}
- return &((*a)[b]);}
-template<class K>
-KN_<K> fSubArray(const KN_<K> & a,const SubArray & b)
- { return a(b);}
-template<class K>
-KN_<K> fSubArrayp( KN<K> * const & a,const SubArray & b)
- { return (*a)(b);}
-template<class A>
-A fSubArrayc(const A & a,const char & b)
- { return a;}
-template<class RR,class A,class B,class C>
-RR * get_elementp2_(const A & a,const B & b,const C & c){
- if( b<0 || a->N() <= b || c<0 || a->M() <= c )
- { cout << " Out of bound 0 <=" << b << " < " << a->N() << " " << c << " < " << a->M()
- << " array type = " << typeid(A).name() << endl;
- ExecError("Out of bound in operator (,)");}
- return &((*a)(b,c));}
-template<class RR,class A,class B,class C>
-RR get_element_is(const A & a,const B & b,const C & c){
- return ((*a)(b,'.')(c));}
-template<class RR,class A,class B,class C>
-RR get_element_si(const A & a,const B & b,const C & c){
- return ((*a)('.',c)(b));}
-template<class RR,class A,class B,class C>
-RR get_element_lineorcol(const A & a,const B & b,const C & c){
- return ((*a)(b,c));}
-template<class RR,class A,class B,class C>
-RR get_element_is_(const A & a,const B & b,const C & c){
-return ((a)(b,'.')(c));}
-template<class RR,class A,class B,class C>
-RR get_element_si_(const A & a,const B & b,const C & c){
-return ((a)('.',c)(b));}
-template<class RR,class A,class B,class C>
-RR get_element_lineorcol_(const A & a,const B & b,const C & c){
-return ((a)(b,c));}
-template<class RR,class A,class B,class C>
-RR * get_elementp2__(const A & a,const B & b,const C & c){
- if( b<0 || a.N() <= b || c<0 || a.M() <= c )
- { cout << " Out of bound 0 <=" << b << " < " << a.N() << " " << c << " < " << a.M()
- << " array type = " << typeid(A).name() << endl;
- ExecError("Out of bound in operator (,)");}
-return &((a)(b,c));}
-template<class RR,bool isinit>
-class InitArrayfromArray : public OneOperator {
-public:
- typedef KN<RR> * A;
- typedef KN<RR> * R;
- typedef E_Array B;
- class CODE : public E_F0 { public:
- Expression a0;
- int N;
- Expression * tab;
- int * what;
- const bool mi;
- CODE(Expression a,const E_Array & tt)
- : a0(a),N(tt.size()),
- tab(new Expression [N]),
- what(new int[N]) ,
- mi(tt.MeshIndependent())
- {
- (static_cast<void> (0));
- for (int i=0;i<N;i++)
- if(atype<RR>()->CastingFrom(tt[i].right() ) )
- {
- tab[i]=atype<RR>()->CastTo(tt[i]);
- what[i]=0;
- }
- else if(atype<KN_<RR> >()->CastingFrom(tt[i].right() ) )
- {
- tab[i]=atype<KN_<RR> >()->CastTo(tt[i].RightExp());
- what[i]=1;
- }
- else
- CompileError(" we are waiting for scalar or vector of scalar");
- }
- AnyType operator()(Stack stack) const
- {
- extern void xxxx();
- xxxx();
- A a=GetAny<A>((*a0)(stack));
- KN<AnyType> v(N);
- KN<int> nn(N+1);
- for (int i=0;i<N;i++)
- v[i]= (*(tab[i]))(stack);
- int n=0;
- for (int i=0;i<N;i++)
- {
- if (what[i]==0) nn[i]=1;
- else if (what[i]==1) nn[i]=GetAny<KN_<RR> >(v[i]).size();
- n += nn[i];
- }
- if (isinit)
- a->init(n);
- else
- a->resize(n);
- for (int i=0,j=0 ;i<N; j += nn[i++])
- if (what[i]==0)
- (*a)[j]= GetAny<RR>(v[i]);
- else if (what[i]==1)
- (*a)(SubArray(nn[i],j)) = GetAny<KN_<RR> >(v[i]);
- return SetAny<R>(a);
- }
- bool MeshIndependent() const {return mi;}
- ~CODE() { delete [] tab; delete[] what;}
- operator aType () const { return atype<R>();}
- };
- public:
- E_F0 * code(const basicAC_F0 & args) const
- { return new CODE(t[0]->CastTo(args[0]),*dynamic_cast<const E_Array*>( t[1]->CastTo(args[1]).LeftValue()));}
- InitArrayfromArray(): OneOperator(atype<R>(),atype<A>(),atype<B>()) {}
-};
-template<class RR,bool isinit>
-class InitMatfromAArray : public OneOperator {
-public:
- typedef KNM<RR> * A;
- typedef KNM<RR> * R;
- typedef E_Array B;
- class CODE : public E_F0 { public:
- Expression a0;
- int N;
- int M;
- Expression ** tab;
- const bool mi;
- CODE(Expression a,const E_Array & tt)
- : a0(a),N(tt.size()),M(0),
- tab(new Expression* [N]),
- mi(tt.MeshIndependent())
- {
- (static_cast<void> (0));
- for (int i=0;i<N;i++)
- {
- const E_Array *li = dynamic_cast<const E_Array *>(tt[i].LeftValue());
- if (li)
- {
- const E_Array & lli = *li;
- if( i == 0) {
- M = lli.size(); ((M>0) ? ( (void) 0) : throw(ErrorAssert("M>0","array_tlp.hpp", 392)));
- for (int i=0;i<N;i++) tab[i] = new Expression [M];
- }
- else {
- if ( M != li->size() ) {
- cout << " line " << i << " the size of the column change " << M << " to " << li->size() << endl;
- CompileError(" Is not a matrix, M is not constant" ); } }
- for (int j=0;j<M;j++)
- tab[i][j]=atype<RR>()->CastTo( lli[j]);
- }
- else
- CompileError(" we are waiting for vector of scalar [ , , , ] ");
- }
- }
- AnyType operator()(Stack stack) const
- {
- A a=GetAny<A>((*a0)(stack));
- if (isinit)
- a->init(N,M);
- else
- a->resize(N,M);
- for (int i =0;i<N;++i)
- for (int j =0;j<M;++j)
- (*a)(i,j)= GetAny< RR >( (*(tab[i][j]))(stack)) ;
- return SetAny<R>(a);
- }
- bool MeshIndependent() const {return mi;}
- ~CODE() { for (int i=0;i<N;i++) delete [] tab[i]; delete [] tab; }
- operator aType () const { return atype<R>();}
- };
- public:
- E_F0 * code(const basicAC_F0 & args) const
- { return new CODE(t[0]->CastTo(args[0]),*dynamic_cast<const E_Array*>( t[1]->CastTo(args[1]).LeftValue()));}
- InitMatfromAArray(): OneOperator(atype<R>(),atype<A>(),atype<B>()) {}
-};
-template<typename RR>
-class SetArrayofKNfromKN : public OneOperator {
-public:
- typedef KN_<RR> A;
- typedef KN_<RR> R;
- typedef E_Array B;
- class CODE : public E_F0 { public:
- Expression a0;
- int N;
- Expression * tab;
- int * what;
- const bool mi;
- CODE(Expression a,const E_Array & tt)
- : a0(a),N(tt.size()),
- tab(new Expression [N]),
- what(new int[N]) ,
- mi(tt.MeshIndependent())
- {
- (static_cast<void> (0));
- for (int i=0;i<N;i++)
- if(atype<RR*>()->CastingFrom(tt[i].left() ) )
- {
- tab[i]=atype<RR*>()->CastTo(tt[i]);
- what[i]=0;
- }
- else if(atype<KN_<RR> >()->CastingFrom(tt[i].right() ) )
- {
- tab[i]=atype<KN_<RR> >()->CastTo(tt[i].RightExp());
- what[i]=1;
- }
- else
- CompileError(" we are waiting for scalar or vector of scalar");
- }
- AnyType operator()(Stack stack) const
- {
- A a=GetAny<A>((*a0)(stack));
- KN<AnyType> v(N);
- KN<int> nn(N+1);
- for (int i=0;i<N;i++)
- v[i]= (*(tab[i]))(stack);
- int n=0;
- for (int i=0;i<N;i++)
- {
- if (what[i]==0) nn[i]=1;
- else if (what[i]==1) nn[i]=GetAny<KN_<RR> >(v[i]).size();
- n += nn[i];
- }
- ((n == a.size()) ? ( (void) 0) : throw(ErrorAssert("n == a.size()","array_tlp.hpp", 487)));
- for (int i=0,j=0 ;i<N; j += nn[i++])
- if (what[i]==0)
- * GetAny<RR*>(v[i]) = a[j];
- else if (what[i]==1) {
- KN_<RR> tab(GetAny<KN_<RR> >(v[i]));
- tab =a(SubArray(nn[i],j));
- }
- return SetAny<R>(a);
- }
- bool MeshIndependent() const {return mi;}
- ~CODE() { delete [] tab; delete[] what;}
- operator aType () const { return atype<R>();}
- };
- public:
- E_F0 * code(const basicAC_F0 & args) const
- { return new CODE(t[1]->CastTo(args[1]),*dynamic_cast<const E_Array*>( t[0]->CastTo(args[0]).RightValue()));}
- SetArrayofKNfromKN(): OneOperator(atype<R>(),atype<B>(),atype<A>()) {}
-};
-template<class K> long get_n(KN<K> * p){ return p->N();}
-template<class K> long get_n(KNM<K> * p){ return p->N();}
-template<class K> long get_m(KNM<K> * p){ return p->M();}
-template<class K> K get_max(KN<K> * p){ return p->max();}
-template<class K> K get_min(KN<K> * p){ return p->min();}
-template<class K> K get_sum(KN<K> * p){ return p->sum();}
-template<class K> double get_l2(KN<K> * p){ return p->l2();}
-template<class K> double get_l1(KN<K> * p){ return p->l1();}
-template<class K> double get_linfty(KN<K> * p){ return p->linfty();}
-template<class K> K get_max(KNM<K> * p){ return p->max();}
-template<class K> K get_min(KNM<K> * p){ return p->min();}
-template<class K> K get_sum(KNM<K> * p){ return p->sum();}
-template<class K> double get_l2(KNM<K> * p){ return p->l2();}
-template<class K> double get_l1(KNM<K> * p){ return p->l1();}
-template<class K> double get_linfty(KNM<K> * p){ return p->linfty();}
-template<class K,class T > K get_sum0(const T & p){ return p.sum();}
-template<class K,class T > K get_max0(const T &p){ return p.max();}
-template<class K,class T > K get_min0(const T &p){ return p.min();}
-template<class K,class T> K get_l2_0(const T &p){ return p.l2();}
-template<class K,class T> K get_l1_0(const T &p){ return p.l1();}
-template<class K,class T> K get_linfty_0(const T &p){ return p.linfty();}
- class ostream_precis { public:
- ostream_precis(ostream * ff) :f(ff) {}
- ostream * f;
- operator long () const {return f->precision();}
- };
-template<class A,class B> B castto(const A & a){ return a;}
-template<typename K,typename KK>
-AnyType ClearReturnpKK(Stack stack, const AnyType & a)
-{
- KK * m = GetAny<KK * >(a);
- m->increment();
- Add2StackOfPtr2FreeRC(stack,m);
- if(verbosity>400)
- cout << "ClearReturnpKK:: increment + Add2StackOfPtr2FreeRC nb ref " << -m->next << endl;
- return m;
-}
-template<typename K,typename KK,typename KK_>
-AnyType ClearReturnpKK_(Stack stack, const AnyType & a)
-{
- KK_ * m = GetAny<KK_ * >(a);
- KK *cm=new KK(*m);
- Add2StackOfPtr2Free(stack,cm);
- if(verbosity>400)
- cout << "ClearReturnpKK_:: copie Add2StackOfPtr2Free " << endl;
- return (KK_ *) cm;
-}
-template<typename K,typename KK,typename KK_>
-AnyType ClearReturnKK_(Stack stack, const AnyType & a)
-{
- KK_ m = GetAny<KK_>(a);
- KK *cm=new KK(m);
- Add2StackOfPtr2Free(stack,cm);
- if(verbosity>400)
- cout << "ClearReturnKK_:: copie Add2StackOfPtr2Free " << endl;
- return SetAny<KK_>(*cm);
-}
-template<typename K,typename KK_,typename KK>
-AnyType CopieKK_pKK(Stack stack,const AnyType &a) {
- KK_ m = GetAny<KK_>(a);
- KK *cm=new KK(m);
- if(verbosity>400)
- cout << "CopieKK_pKK:: copie Add2StackOfPtr2Free "<< cm << endl;
- Add2StackOfPtr2Free(stack,cm);
-return cm;}
-template<typename KK,typename KK_>
-AnyType UnRefpKN(Stack,const AnyType &a) {
- KK_ a_(*PGetAny<KK >(a));
- return SetAny<KK_ >(a_);}
-template<class K>
-void ArrayDCL()
-{
- Dcl_TypeandPtr_<KN_<K> ,KN<K>* > (0,0,0,::Destroy<KN<K> >, ::ClearReturnKK_<K,KN<K>,KN_<K> >,::ClearReturnpKK<K,KN<K> >);
- Dcl_TypeandPtr_<KNM_<K> ,KNM<K>* > (0,0,0,::Destroy<KNM<K> >, ::ClearReturnKK_<K,KNM<K>,KNM_<K> >,::ClearReturnpKK<K,KNM<K> >);
- Dcl_Type< outProduct_KN_<K>* >();
- Dcl_Type< Transpose<KN_<K> > > ();
- Dcl_Type< Transpose< KNM<K> *> >();
- Dcl_Type<Add_KN_<K> >();
- Dcl_Type<DotStar_KN_<K> >();
- Dcl_Type<DotSlash_KN_<K> >();
- Dcl_Type<Sub_KN_<K> >();
- Dcl_Type<Mulc_KN_<K> >();
- Dcl_Type<Mul_KNM_KN_<K> >();
- Dcl_Type<Add_Mulc_KN_<K> *>();
- Dcl_Type<if_arth_KN_<K> *>();
- Dcl_Type<pair<KN_<K>,Inv_KN_long> *>();
- Dcl_Type<pair<KN_<K>,KN_<long> > *>();
- map_type[typeid(KN<K> * ).name()]->AddCast(
- new E_F1_funcT<KN<K>*,KN_<K> >(CopieKK_pKK<K,KN_<K>,KN<K> > )
- );
- map_type[typeid(KN_<K> ).name()]->AddCast(
- new E_F1_funcT<KN_<K>,KNM<K>* >(UnRef<KN_<K>,KNM<K> *> ));
- map_type[typeid(KN_<K> ).name()]->AddCast(
- new E_F1_funcT<KN_<K>,KN<K>*>(UnRefpKN<KN<K>,KN_<K> > )
- );
- map_type[typeid(KNM_<K> ).name()]->AddCast(
- new E_F1_funcT<KNM_<K>,KNM<K>*>(UnRefpKN<KNM<K>,KNM_<K> > )
- );
- map_type_of_map[make_pair(atype<long>(),atype<K>())]=atype<KN<K>*>();
- map_pair_of_type[make_pair(atype<long>(),atype<long>())] =atype<pair<long,long> >();
- map_type_of_map[make_pair(atype<pair<long,long> >(),atype<K>())]=atype<KNM<K>*>();
-}
-template<class A,class B> pair<A,B> * pBuild(const A & a,const B & b)
- { return new pair<A,B>(a,b);}
-template<class K,class L,class OP>
-struct set_A_BI: public binary_function<KN_<K>,pair<KN_<K>, KN_<L> > *,KN_<K> > {
- static KN_<K> f(const KN_<K> & a, pair<KN_<K>, KN_<L> > * const & b) {
- KN_<K> x(a);
- OP op;
- const KN_<K> & y(b->first);
- const KN_<L> & I(b->second);
- L N = x.N();
- L n = y.N();
- L maxI=I(SubArray(N)).max() ;
- L minI=I(SubArray(N)).min() ;
- if( maxI >= n || I.N() < N)
- { cout << " Out of Bound x=y(I) : 0 <= " << minI << " < "<< maxI << "< " << n << endl;
- cout << " or I.N() " << I.N() << " > " << N << endl;
- ExecError("Out of Bound error");
- }
- for(int i=0;i<N;i++)
- if(I[i]>=0)
- op(x(i),y(I[i]));
- delete b;
- return a;
- }
-};
-template<class K,class L,class OP>
-struct set_AI_B: public binary_function<pair<KN_<K>, KN_<L> > * ,KN_<K>, NothingType > {
- static NothingType f( pair<KN_<K>, KN_<L> > * const & b,const KN_<K> & a) {
- KN_<K> x(a);
- OP op;
- const KN_<K> & y(b->first);
- const KN_<L> & I(b->second);
- L N = I.N();
- L n = y.N();
- L maxI=I(SubArray(N)).max() ;
- L minI=I(SubArray(N)).min() ;
- if( maxI >= n || x.N() < N )
- { cout << " Out of Bound x(I)=y : 0 <= " << minI << " < "<< maxI << "< " << n << endl;
- cout << " or x.N() " << I.N() << " > " << N << endl;
- ExecError("Out of Bound error");
- }
- for(int i=0;i<N;i++)
- if(I[i] >=0)
- op(y(I[i]),x[i]);
- delete b;
- return NothingType();
- }
-};
-template<class K>
-struct Op3_paac: public ternary_function<KN_<K>,KN_<K>,K,if_arth_KN_<K>*> {
-static if_arth_KN_<K>* f(Stack s,const KN_<K> & a,const KN_<K> & b,const K & c ) {
- KN_<K> kc(new(NewAllocTmp(s,sizeof(c))) K(c),1,0);
- return new if_arth_KN_<K>(a,b,kc);}
-};
-template<class K>
-struct Op3_paca: public ternary_function<KN_<K>,K,KN_<K>,if_arth_KN_<K>*> {
- static if_arth_KN_<K>* f(Stack s,const KN_<K> & a,const K & b,const KN_<K> & c ) {
- KN_<K> kb(new(NewAllocTmp(s,sizeof(b))) K(b),1,0);
- return new if_arth_KN_<K>(a,kb,c);}
-};
-template<class K>
-struct Op3_pacc: public ternary_function<KN_<K>,K,K,if_arth_KN_<K>*> {
- static if_arth_KN_<K>* f(Stack s,const KN_<K> & a,const K & b,const K & c ) {
- K cc(c),bb(b);
- KN_<K> kc(new(NewAllocTmp(s,sizeof(c))) K(c),1,0),
- kb(new(NewAllocTmp(s,sizeof(b))) K(b),1,0);
- return new if_arth_KN_<K>(a,kb,kc);}
-};
-template<class K>
-struct SetArray2: public binary_function<K,K,SetArray<K> > {
- static SetArray<K> f(const K & a,const K & b) {
- long n= long(abs((b-a)));
- ((n) ? ( (void) 0) : throw(ErrorAssert("n","array_tlp.hpp", 770)));
- K s= (b-a)/K(n);
- n++;
- if(verbosity>100)
- cout << " SetArray " << n << " " << a << " " << s << endl;
- return SetArray<K>(n,a,s);} };
-template<class K>
-struct SetArray3: public ternary_function<K,K,K,SetArray<K> > {
- static SetArray<K> f(Stack s,const K & a,const K &b,const K & c) {
- long n= long(1+abs((c-a)/b));
- if(verbosity>100)
- cout << " SetArray " << n << " : " << " " << a << " " << b << " " << c << endl;
- return SetArray<K>(n,a,b);} };
-template<class R,class A> R * set_init_array( R* const & a,const A & b){
- ( (void)0);
- a->init(b.size());
- *a=b;
-return a;}
-template<class R,class A> R * set_array( R* const & a,const A & b){
- ( (void)0);
- a->resize(b.size());
- *a=b;
-return a;}
-template<class R,class A> R * set_arrayp( R* const & a,const A & b){
- ( (void)0);
- a->resize(b->size());
- *a=*b;
-return a;}
-template<class R,class A> R set_array_( R const & a,const A & b){
- ( (void)0);
- ((a.N()==b.size()) ? ( (void) 0) : throw(ErrorAssert("a.N()==b.size()","array_tlp.hpp", 804)));
- R aa=a;
- aa=b;
-return a;}
-template<class K> KNM<K> * set_initmat_t(KNM<K> * a,Transpose<KNM<K> * > b ){
- KNM_<K> tb=b.t->t(); ;
- a->init(tb.N(),tb.M());
- *a=tb;
- return a;}
-template<class K> KNM<K> * set_initmat(KNM<K> * a,KNM<K> * b ){
- a->init(b->N(),b->M());
- *a=*b;
- return a;}
-template<class K> KNM<K> * set_mat_t(KNM<K> * a,Transpose<KNM<K> * > b ){
- KNM_<K> tb=b.t->t(); ;
- a->resize(tb.N(),tb.M());
- *a=tb;
- return a;}
-template<class K> KNM<K> * set_mat(KNM<K> * a,KNM<K> * b ){
- a->resize(b->N(),b->M());
- *a=*b;
- return a;}
-template<class K>
-class OneOperator_2KN_ : public OneOperator {public:
- class Op : public E_F0 {
- public:
- int N;
- Expression *tab;
- Op( const E_Array &bb) : N(bb.size()), tab(new Expression[N])
- {
- for(int i=0;i<N;++i)
- tab[i]=atype<K>()->CastTo( bb[i]);
- }
- AnyType operator()(Stack s) const {
- K * p = Add2StackOfPtr2FreeA<K>(s,new K[N]);
- KN<K> A(N, p);
- for(int i=0;i<N;++i)
- A[i]= GetAny<K>( (*tab[i])(s));
- return SetAny<KN_<K> >(A);}
- };
- E_F0 * code(const basicAC_F0 & a) const
- { const E_Array * b = dynamic_cast<const E_Array *>(a[0].LeftValue());
- ((b) ? ( (void) 0) : throw(ErrorAssert("b","array_tlp.hpp", 851)));
- return new Op(*b);}
- OneOperator_2KN_<K>(): OneOperator(atype<KN_<K> >(),atype<E_Array>()) { pref=-1;}
-};
-extern aType aaaa_knlp;
-template<class K,class Z>
-void ArrayOperator()
-{
- Dcl_Type< Resize<KN<K> > > ();
- Dcl_Type< Resize<KNM<K> > > ();
- aType knrp = atype<KN<K> *>();
- aType knr_ = atype<KN_<K> >();
- aType knlp= aaaa_knlp ;
- atype<KN<K>* >()->Add("[","",new OneOperator2_<K*,KN<K>*,Z >(get_elementp_<K,KN<K>*,Z>));
- atype<KN<K>* >()->Add("(","",new OneOperator2_<K*,KN<K>*,Z >(get_elementp_<K,KN<K>*,Z>));
- atype<KN_<K> >()->Add("(","",new OneOperator2_<KN_<K>,KN_<K>,char >(fSubArrayc<KN_<K> >));
- atype<KN_<K> >()->Add("(","",new OneOperator2_<KN_<K>,KN_<K>,SubArray>(fSubArray<K> ));
- atype<KN<K>*>()->Add("(","",new OneOperator2_<KN_<K>,KN<K>*,SubArray>(fSubArrayp<K> ));
- atype<KN<K>* >()->Add("(","",new OneOperator2_<KN<K>*,KN<K>*,char >(fSubArrayc<KN<K>* >));
- atype<KN_<K> >()->Add("[","",new OneOperator2_<K*,KN_<K>,Z >(get_element_<K,KN_<K>,Z>));
- atype<KN_<K> >()->Add("(","",new OneOperator2_<K*,KN_<K>,Z >(get_element_<K,KN_<K>,Z>));
- atype<KNM<K>* >()->Add("(","",new OneOperator3_<KN_<K>,KNM<K>*,Z,SubArray >(get_element_is<KN_<K>,KNM<K>*,Z,SubArray>));
- atype<KNM<K>* >()->Add("(","",new OneOperator3_<KN_<K>,KNM<K>*,SubArray,Z >(get_element_si<KN_<K>,KNM<K>*,SubArray,Z>));
- atype<KNM<K>* >()->Add("(","",new OneOperator3_<KN_<K>,KNM<K>*,Z,char >(get_element_lineorcol<KN_<K>,KNM<K>*,Z,char>));
- atype<KNM<K>* >()->Add("(","",new OneOperator3_<KN_<K>,KNM<K>*,char,Z >(get_element_lineorcol<KN_<K>,KNM<K>*,char,Z>));
- atype<KNM<K>* >()->Add("(","",new OneOperator3_<K*,KNM<K>*,Z,Z >(get_elementp2_<K,KNM<K>*,Z,Z>));
- atype<KNM_<K> >()->Add("(","",new OneOperator3_<KN_<K>,KNM_<K>,Z,SubArray >(get_element_is_<KN_<K>,KNM_<K>,Z,SubArray>));
- atype<KNM_<K> >()->Add("(","",new OneOperator3_<KN_<K>,KNM_<K>,SubArray,Z >(get_element_si_<KN_<K>,KNM_<K>,SubArray,Z>));
- atype<KNM_<K> >()->Add("(","",new OneOperator3_<KN_<K>,KNM_<K>,Z,char >(get_element_lineorcol_<KN_<K>,KNM_<K>,Z,char>));
- atype<KNM_<K> >()->Add("(","",new OneOperator3_<KN_<K>,KNM_<K>,char,Z >(get_element_lineorcol_<KN_<K>,KNM_<K>,char,Z>));
- atype<KNM_<K> >()->Add("(","",new OneOperator3_<K*,KNM_<K>,Z,Z >(get_elementp2__<K,KNM_<K>,Z,Z>));
- Add<KN<K> *>("sum",".",new OneOperator1<K,KN<K> *>(get_sum));
- Add<KN<K> *>("min",".",new OneOperator1<K,KN<K> *>(get_min));
- Add<KN<K> *>("max",".",new OneOperator1<K,KN<K> *>(get_max));
- Add<KN<K> *>("l2",".",new OneOperator1<double,KN<K> *>(get_l2));
- Add<KN<K> *>("l1",".",new OneOperator1<double,KN<K> *>(get_l1));
- Add<KN<K> *>("linfty",".",new OneOperator1<double,KN<K> *>(get_linfty));
- Add<KNM<K> *>("sum",".",new OneOperator1<K,KNM<K> *>(get_sum));
- Add<KNM<K> *>("min",".",new OneOperator1<K,KNM<K> *>(get_min));
- Add<KNM<K> *>("max",".",new OneOperator1<K,KNM<K> *>(get_max));
- Add<KNM<K> *>("l2",".",new OneOperator1<double,KNM<K> *>(get_l2));
- Add<KNM<K> *>("l1",".",new OneOperator1<double,KNM<K> *>(get_l1));
- Add<KNM<K> *>("linfty",".",new OneOperator1<double,KNM<K> *>(get_linfty));
- Add<KN_<K> >("sum",".",new OneOperator1_<K,KN_<K> >(get_sum0<K,KN_<K> >));
- Add<KN_<K> >("min",".",new OneOperator1_<K,KN_<K> >(get_min0<K,KN_<K> >));
- Add<KN_<K> >("max",".",new OneOperator1_<K,KN_<K> >(get_max0<K,KN_<K> >));
- Add<KN_<K> >("l2",".",new OneOperator1_<double,KN_<K> >(get_l2_0<double,KN_<K> >));
- Add<KN_<K> >("l1",".",new OneOperator1_<double,KN_<K> >(get_l1_0<double,KN_<K> >));
- Add<KN_<K> >("linfty",".",new OneOperator1_<double,KN_<K> >(get_linfty_0<double,KN_<K> >));
- Add<KNM_<K> >("sum",".",new OneOperator1_<K,KNM_<K> >(get_sum0<K,KNM_<K> >));
- Add<KNM_<K> >("min",".",new OneOperator1_<K,KNM_<K> >(get_min0<K,KNM_<K> >));
- Add<KNM_<K> >("max",".",new OneOperator1_<K,KNM_<K> >(get_max0<K,KNM_<K> >));
- Add<KNM_<K> >("l2",".",new OneOperator1_<double,KNM_<K> >(get_l2_0<double,KNM_<K> >));
- Add<KNM_<K> >("l1",".",new OneOperator1_<double,KNM_<K> >(get_l1_0<double,KNM_<K> >));
- Add<KNM_<K> >("linfty",".",new OneOperator1_<double,KNM_<K> >(get_linfty_0<double,KNM_<K> >));
- Add<KN<K> *>("resize",".",new OneOperator1< Resize<KN<K> >,KN<K> *>(to_Resize));
- Add<KNM<K> *>("resize",".",new OneOperator1< Resize<KNM<K> >,KNM<K> *>(to_Resize));
- Add<Resize<KN<K> > >("(","",new OneOperator2_<KN<K> *,Resize<KN<K> > , Z >(resize1));
- Add<Resize<KNM<K> > >("(","",new OneOperator3_<KNM<K> *,Resize<KNM<K> > , Z, Z >(resize2));
- TheOperators->Add("<-",
- new OneOperator2_<KN<K> *,KN<K> *,Z>(&set_init),
- new InitArrayfromArray<K,true>
- );
- TheOperators->Add("<-",
- new OneOperator3_<KNM<K> *,KNM<K> *,Z,Z>(&set_init2),
- new InitMatfromAArray<K,true>
- );
- Add<KN<K> *>("<-","(",new OneOperator2_<KN<K> *,KN<K> *,Z>(&set_init));
- Add<KNM<K> *>("<-","(",new OneOperator3_<KNM<K> *,KNM<K> *,Z,Z>(&set_init2));
- TheOperators->Add("<-",new OneOperator2<KNM<K> *,KNM<K> *,Transpose<KNM<K> * > >(&set_initmat_t));
- TheOperators->Add("=",new OneOperator2<KNM<K> *,KNM<K> *,Transpose<KNM<K> * > >(&set_mat_t));
- Add<KN<K> *>("<-","(",new InitArrayfromArray<K,true>);
- Add<KNM<K> *>("<-","(",new InitMatfromAArray<K,true>);
- Add<KN<K> *>("n",".",new OneOperator1<Z,KN<K> *>(get_n));
- Add<KNM<K> *>("n",".",new OneOperator1<Z,KNM<K> *>(get_n));
- Add<KNM<K> *>("m",".",new OneOperator1<Z,KNM<K> *>(get_m));
- TheOperators->Add("=", new InitArrayfromArray<K,false>
- );
- TheOperators->Add("=", new InitMatfromAArray<K,false>
- );
- TheOperators->Add("=", new SetArrayofKNfromKN<K>
- );
- if(0)
- TheOperators->Add("=",
- new OneBinaryOperator<set_eqarray<KN<K> ,K > > ,
- new OneBinaryOperator<set_eqarray<KN<K> ,Add_KN_<K> > > ,
- new OneBinaryOperator<set_eqarray<KN<K> ,DotStar_KN_<K> > > ,
- new OneBinaryOperator<set_eqarray<KN<K> ,DotSlash_KN_<K> > > ,
- new OneBinaryOperator<set_eqarray<KN<K> ,Sub_KN_<K> > > ,
- new OneBinaryOperator<set_eqarray<KN<K> ,Mulc_KN_<K> > > ,
- new OneBinaryOperator<set_eqarray<KN<K> ,Mul_KNM_KN_<K> > > ,
- new OneBinaryOperator<set_eqarray<KN<K> ,KN_<K> > > ,
- new OneBinaryOperator<set_eqarraypd<KN<K> ,Add_Mulc_KN_<K>* > > ,
- new OneBinaryOperator<set_eqarraypd<KN<K> ,if_arth_KN_<K>* > >
- );
- TheOperators->Add("<-",
- new OneBinaryOperator<init_eqarray<KN<K> ,Add_KN_<K> > > ,
- new OneBinaryOperator<init_eqarray<KN<K> ,DotStar_KN_<K> > > ,
- new OneBinaryOperator<init_eqarray<KN<K> ,DotSlash_KN_<K> > > ,
- new OneBinaryOperator<init_eqarray<KN<K> ,Sub_KN_<K> > > ,
- new OneBinaryOperator<init_eqarray<KN<K> ,Mulc_KN_<K> > > ,
- new OneBinaryOperator<init_eqarray<KN<K> ,Mul_KNM_KN_<K> > > ,
- new OneBinaryOperator<init_eqarray<KN<K> ,KN_<K> > > ,
- new OneBinaryOperator<init_eqarraypd<KN<K> ,Add_Mulc_KN_<K>* > > ,
- new OneBinaryOperator<init_eqarraypd<KN<K> ,if_arth_KN_<K>* > >
- );
- TheOperators->Add("=",
- new OneBinaryOperator<set_eqarray<KNM<K> ,K > > ,
- new OneBinaryOperator<set_eqarrayp<KNM<K> , KNM<K> * > >
- );
- TheOperators->Add("=",
- new OneBinaryOperator<set_eq_array<KN_<K> ,K > > ,
- new OneBinaryOperator<set_eq_array<KN_<K> ,Add_KN_<K> > > ,
- new OneBinaryOperator<set_eq_array<KN_<K> ,DotStar_KN_<K> > > ,
- new OneBinaryOperator<set_eq_array<KN_<K> ,DotSlash_KN_<K> > > ,
- new OneBinaryOperator<set_eq_array<KN_<K> ,Sub_KN_<K> > > ,
- new OneBinaryOperator<set_eq_array<KN_<K> ,Mulc_KN_<K> > > ,
- new OneBinaryOperator<set_eq_array<KN_<K> ,Mul_KNM_KN_<K> > > ,
- new OneBinaryOperator<set_eq_arraypd<KN_<K> ,if_arth_KN_<K>* > > ,
- new OneBinaryOperator<set_eq_arraypd<KN_<K> ,Add_Mulc_KN_<K>* > > ,
- new OneBinaryOperator<set_eq_array<KN_<K> ,KN_<K> > >,
- new OneBinaryOperator<set_eq_arraypd<KN_<K> ,KN<K>* > >
- );
- TheOperators->Add("<-",
- new OneBinaryOperator<init_eqarray<KNM<K> ,KNM_<K> > >
- );
- TheOperators->Add("=",
- new OneBinaryOperator<set_eqarray<KNM<K> ,KNM_<K> > >
- );
- TheOperators->Add("+=",
- new OneBinaryOperator<set_eq_array_add<KN_<K> ,K > > ,
- new OneBinaryOperator<set_eq_array_add<KN_<K> ,Add_KN_<K> > > ,
- new OneBinaryOperator<set_eq_array_add<KN_<K> ,DotStar_KN_<K> > > ,
- new OneBinaryOperator<set_eq_array_add<KN_<K> ,DotSlash_KN_<K> > > ,
- new OneBinaryOperator<set_eq_array_add<KN_<K> ,Sub_KN_<K> > > ,
- new OneBinaryOperator<set_eq_array_add<KN_<K> ,Mulc_KN_<K> > > ,
- new OneBinaryOperator<set_eq_array_add<KN_<K> ,Mul_KNM_KN_<K> > > ,
- new OneBinaryOperator<set_eq_arraypd_add<KN_<K> ,Add_Mulc_KN_<K>* > > ,
- new OneBinaryOperator<set_eq_arraypd_add<KN_<K> ,if_arth_KN_<K>* > > ,
- new OneBinaryOperator<set_eq_array_add<KN_<K> ,KN_<K> > >
- );
- TheOperators->Add("-=",
- new OneBinaryOperator<set_eq_array_sub<KN_<K> ,K > > ,
- new OneBinaryOperator<set_eq_array_sub<KN_<K> ,Add_KN_<K> > > ,
- new OneBinaryOperator<set_eq_array_sub<KN_<K> ,DotStar_KN_<K> > > ,
- new OneBinaryOperator<set_eq_array_sub<KN_<K> ,DotSlash_KN_<K> > > ,
- new OneBinaryOperator<set_eq_array_sub<KN_<K> ,Sub_KN_<K> > > ,
- new OneBinaryOperator<set_eq_array_sub<KN_<K> ,Mulc_KN_<K> > > ,
- new OneBinaryOperator<set_eq_array_sub<KN_<K> ,Mul_KNM_KN_<K> > > ,
- new OneBinaryOperator<set_eq_arraypd_sub<KN_<K> ,Add_Mulc_KN_<K>* > > ,
- new OneBinaryOperator<set_eq_arraypd_sub<KN_<K> ,if_arth_KN_<K>* > > ,
- new OneBinaryOperator<set_eq_array_sub<KN_<K> ,KN_<K> > >
- );
- TheOperators->Add("*=",
- new OneBinaryOperator<set_eq_array_mul<KN_<K> ,K > > ,
- new OneBinaryOperator<set_eq_array_mul<KN_<K> ,Add_KN_<K> > > ,
- new OneBinaryOperator<set_eq_array_mul<KN_<K> ,Sub_KN_<K> > > ,
- new OneBinaryOperator<set_eq_array_mul<KN_<K> ,Mulc_KN_<K> > > ,
- new OneBinaryOperator<set_eq_array_mul<KN_<K> ,Mul_KNM_KN_<K> > > ,
- new OneBinaryOperator<set_eq_arraypd_mul<KN_<K> ,Add_Mulc_KN_<K>* > > ,
- new OneBinaryOperator<set_eq_array_mul<KN_<K> ,KN_<K> > >
- );
- TheOperators->Add("/=",
- new OneBinaryOperator<set_eq_array_div<KN_<K> ,K > > ,
- new OneBinaryOperator<set_eq_array_div<KN_<K> ,Add_KN_<K> > > ,
- new OneBinaryOperator<set_eq_array_div<KN_<K> ,Sub_KN_<K> > > ,
- new OneBinaryOperator<set_eq_array_div<KN_<K> ,Mulc_KN_<K> > > ,
- new OneBinaryOperator<set_eq_array_div<KN_<K> ,Mul_KNM_KN_<K> > > ,
- new OneBinaryOperator<set_eq_arraypd_div<KN_<K> ,Add_Mulc_KN_<K>* > > ,
- new OneBinaryOperator<set_eq_array_div<KN_<K> ,KN_<K> > >
- );
- TheOperators->Add("+",
- new OneBinaryOperator<Op2_add0<Add_KN_<K>,KN_<K>,KN_<K> > >,
- new OneBinaryOperator<Op2_add__n<Add_Mulc_KN_<K>,Mulc_KN_<K>,Mulc_KN_<K> > >,
- new OneBinaryOperator<Op2_add__n<Add_Mulc_KN_<K>,KN_<K>,Mulc_KN_<K> > >,
- new OneBinaryOperator<Op2_add__n<Add_Mulc_KN_<K>,Mulc_KN_<K> ,KN_<K> > >
- );
- TheOperators->Add("-",
- new OneBinaryOperator<Op2_sub0<Sub_KN_<K>,KN_<K> ,KN_<K> > >,
- new OneUnaryOperator<Op1_sub<Mulc_KN_<K>,KN_<K> > >,
- new OneBinaryOperator<Op2_sub__n<Add_Mulc_KN_<K>,Mulc_KN_<K>,Mulc_KN_<K> > >,
- new OneBinaryOperator<Op2_sub__n<Add_Mulc_KN_<K>,KN_<K>,Mulc_KN_<K> > >,
- new OneBinaryOperator<Op2_sub__n<Add_Mulc_KN_<K>,Mulc_KN_<K> ,KN_<K> > >
- );
- TheOperators->Add("*",
- new OneBinaryOperator<Op2_mulc<Mulc_KN_<K>,KN_<K>,K> >,
- new OneBinaryOperator<Op2_mulc<Mulc_KN_<K>,K,KN_<K> > >,
- new OneBinaryOperator<Op2_mulpcp<Mul_KNM_KN_<K>,KNM<K>*,KN<K>*> >,
- new OneBinaryOperator<Op2_dotproduct_<K> >
- ,new OneBinaryOperator<Op2_pbuild<outProduct_KN_<K>,KN_<K>,Transpose<KN_<K> > > >
- ,new OneBinaryOperator<Op2_pbuild<outProduct_KN_<K>,Mulc_KN_<K>,Transpose<KN_<K> > > >
- );
- TheOperators->Add("+=",
- new OneBinaryOperator<set_eqarraypd_add<KNM<K> ,outProduct_KN_<K>* > >
- );
- TheOperators->Add("-=",
- new OneBinaryOperator<set_eqarraypd_sub<KNM<K> ,outProduct_KN_<K>* > >
- );
- TheOperators->Add("=",
- new OneBinaryOperator<set_eqarraypd<KNM<K> ,outProduct_KN_<K>* > >
- );
- TheOperators->Add("?:",
- new OneTernaryOperator3<Op3_p<if_arth_KN_<K>, KN_<K> > > ,
- new OneTernaryOperator3<Op3_paac<K > > ,
- new OneTernaryOperator3<Op3_pacc<K > > ,
- new OneTernaryOperator3<Op3_paca<K > >
- );
- atype<KN_<K> >()->Add("(","",new OneOperator2_< pair<KN_<K>,KN_<long> > * ,KN_<K> , KN_<long> >(pBuild< KN_<K> , KN_<long> >,atype<KN_<K> >(), atype<KN_<long> >() ));
- atype<KN<K> *>()->Add("(","",new OneOperator2_< pair<KN_<K>,KN_<long> > * ,KN_<K> , KN_<long> >(pBuild< KN_<K> , KN_<long> >,atype<KN<K> * >(), atype<KN_<long> >() ));
- TheOperators->Add("=",
- new OneBinaryOperator<set_A_BI< K,Z,affectation<K> > > ,
- new OneBinaryOperator<set_AI_B< K,Z,affectation<K> > >
- );
- TheOperators->Add("+=",
- new OneBinaryOperator<set_A_BI< K,Z,affectation_add<K> > > ,
- new OneBinaryOperator<set_AI_B< K,Z,affectation_add<K> > >
- );
- TheOperators->Add("-=",
- new OneBinaryOperator<set_A_BI< K,Z,affectation_sub<K> > > ,
- new OneBinaryOperator<set_AI_B< K,Z,affectation_sub<K> > >
- );
- TheOperators->Add("\'",
- new OneOperator1<Transpose<KN_<K> >,KN_<K> >(&Build<Transpose<KN_<K> >,KN_<K> >),
- new OneOperator1<Transpose<KNM<K> * >, KNM<K> * >(&Build<Transpose<KNM<K> * >,KNM<K> * >)
- );
- TheOperators->Add(".*",
- new OneBinaryOperator<Op2_build<DotStar_KN_<K>,KN_<K>,KN_<K> > >
- );
- TheOperators->Add("./",
- new OneBinaryOperator<Op2_build<DotSlash_KN_<K>,KN_<K>,KN_<K> > >
- );
- TheOperators->Add("<<",
- new OneBinaryOperator<Print<KNM_<K> > >,
- new OneBinaryOperator<Print<KN_<K> > >
- );
- TheOperators->Add(">>",
- new OneBinaryOperator<Op_ReadKN<K> >
- );
- map_type[typeid(MyMap<String,K>*).name()] = new ForEachType<MyMap<String,K>*>(Initialize<MyMap<String,K> >,Delete<MyMap<String,K> >) ;
- map_type_of_map[make_pair(atype<string*>(),atype<K>())]=atype<MyMap<String,K>*>();
- atype<MyMap<String,K>*>()->Add("[","",new OneOperator2_<K*,MyMap<String,K>*,string*>(get_element<K>));
- Dcl_Type<SetArray<K> >();
- TheOperators->Add("::",
- new OneBinaryOperator<SetArray2<K> >,
- new OneTernaryOperator3<SetArray3<K> >);
- TheOperators->Add("<-",
- new OneOperator2_<KN<K> *,KN<K> *,SetArray<K> >(&set_init_array));
- TheOperators->Add("=",
- new OneOperator2_<KN<K> *,KN<K> *,SetArray<K> >(&set_array),
- new OneOperator2_<KN<K> *,KN<K> *,KN<K> * >(&set_arrayp),
- new OneOperator2_<KN_<K> ,KN_<K> ,SetArray<K> >(-1,&set_array_)
- );
-}
-template<class R,class A,class B=A,class BB=B>
-class OneOperator1F_KN_ : public OneOperator {
- aType r;
- typedef A (*func)( B ) ;
- func f;
- public:
- E_F0 * code(const basicAC_F0 & args) const
- { return new Op(f,t[0]->CastTo(args[0]));}
- OneOperator1F_KN_(func ff):
- OneOperator(map_type[typeid(R).name()],map_type[typeid(BB).name()]),f(ff){}
- class Op :public E_F0 { public:
- typedef A (*func)(B ) ;
- func f;
- Expression a;
- Op(func ff,Expression aa) : f(ff),a(aa) {}
- AnyType operator()(Stack s) const {return SetAny<R>( R(f, GetAny<BB>( (*a)(s)) ) );}
- bool EvaluableWithOutStack() const
- {return a->EvaluableWithOutStack() ;}
- bool MeshIndependent() const
- {return a->MeshIndependent();}
-};
-};
-template<class K,class KK>
-void ArrayOperatorF()
-{
- Dcl_Type<F_KN_<K,K,KK> >();
- Global.Add("exp","(",new OneOperator1F_KN_<F_KN_<K,K,KK>,K,KK,KN_<K> >(exp));
- Global.Add("log","(",new OneOperator1F_KN_<F_KN_<K,K,KK>,K,KK,KN_<K> >(log));
- Global.Add("log10","(",new OneOperator1F_KN_<F_KN_<K,K,KK>,K,KK,KN_<K> >(log10));
- Global.Add("sqrt","(",new OneOperator1F_KN_<F_KN_<K,K,KK>,K,KK,KN_<K> >(sqrt));
- Global.Add("sin","(",new OneOperator1F_KN_<F_KN_<K,K,KK>,K,KK,KN_<K> >(sin));
- Global.Add("cos","(",new OneOperator1F_KN_<F_KN_<K,K,KK>,K,KK,KN_<K> >(cos));
- Global.Add("tan","(",new OneOperator1F_KN_<F_KN_<K,K,KK>,K,KK,KN_<K> >(tan));
- Global.Add("cosh","(",new OneOperator1F_KN_<F_KN_<K,K,KK>,K,KK,KN_<K> >(cosh));
- Global.Add("sinh","(",new OneOperator1F_KN_<F_KN_<K,K,KK>,K,KK,KN_<K> >(sinh));
- Global.Add("tanh","(",new OneOperator1F_KN_<F_KN_<K,K,KK>,K,KK,KN_<K> >(tanh));
- TheOperators->Add("=",new OneBinaryOperator<set_eq_array<KN_<K> ,F_KN_<K,K,KK> > > );
- TheOperators->Add("+=",new OneBinaryOperator<set_eq_array_add<KN_<K> ,F_KN_<K,K,KK> > > );
- TheOperators->Add("-=",new OneBinaryOperator<set_eq_array_sub<KN_<K> ,F_KN_<K,K,KK> > > );
- TheOperators->Add("/=",new OneBinaryOperator<set_eq_array_div<KN_<K> ,F_KN_<K,K,KK> > > );
- TheOperators->Add("*=",new OneBinaryOperator<set_eq_array_mul<KN_<K> ,F_KN_<K,K,KK> > > );
-}
-void initArrayDCLComplex();
-void initArrayOperatorComplex();
-void initArrayDCLdouble();
-void initArrayOperatordouble();
-void initArrayDCLlong();
-void initArrayOperatorlong();
-void initStringOperator();
-const basicForEachType *aatypeknlongp;
- aType aaaa_knlp;
-void initArrayDCLlong()
-{
- Dcl_Type<Inv_KN_long>();
- ArrayDCL<long>();
- aaaa_knlp = atype<KN<long>*>();
-}
-class OneBinaryOperatorInv_KN_long : public OneOperator { public:
- OneBinaryOperatorInv_KN_long(basicForEachType * ti) : OneOperator(atype<Inv_KN_long >(), ti ,atype<long>()) {}
- E_F0 * code(const basicAC_F0 & args) const
- { Expression p=args[1];
- if ( ! p->EvaluableWithOutStack() )
- {
- bool bb=p->EvaluableWithOutStack();
- cout << bb << " " << * p << endl;
- CompileError("Inverse: int[int] I, array, with I^p, The p must be a constant == -1, sorry");}
- long pv = GetAny<long>((*p)(0));
- if (pv !=-1)
- { char buf[100];
- sprintf(buf,"Inverse: int[int] I, array, I^%ld, The pow must be == -1, sorry",pv);
- CompileError(buf);}
- return new E_F_F0<Inv_KN_long,KN_<long> >(Build<Inv_KN_long,KN_<long> >,to< KN_<long> >(args[0]));
- }
-};
-template<class R> R * set_init_init( R* const & a,const long & n){
- ( (void)0);
- a->init(n);
- for (int i=0;i<n;i++)
- (*a)[i].init();
- return a;}
-inline string ** get_elements( KN<String> * const & a,long const & b)
-{ ((a && b >=0 && b < a->size()) ? ( (void) 0) : throw(ErrorAssert("a && b >=0 && b < a->size()","array_long.cpp", 84)));
- String & Sret = (*a)[b];
- return Sret.getap();}
-template<class A> inline AnyType Destroy_KN(Stack,const AnyType &x){
- KN<A> * a=GetAny<KN<A>*>(x);
- for (int i=0;i<a->N(); i++)
- (a)[i].destroy();
- a->destroy();
- return Nothing;
-}
-template<class A,class B>
-struct set_Inv_KN_long: public binary_function<A,B,A> {
- static A f(const A & a, B const & b)
- {
- int n=a.N();
- KN_<long> I(b.t);
- for(int i=0;i<I.N();++i)
- {
- int j=I[i];
- if(j>=0 && j<n)
- a[j]=i;
- }
- return a;}
-};
-template<class A,class B>
-struct set_Inv_pKN_longI: public binary_function<A,B,A> {
- static A f(const A & a, B const & b)
- {
- KN_<long> I(b.t);
- int n=I.max()+1;
- a->init(n);
- (*a)=-1;
- for(int i=0;i<I.N();++i)
- {
- int j=I[i];
- if(j>=0 && j<n)
- (*a)[j]=i;
- }
- return a;}
-};
-void initArrayOperatorlong()
-{
- typedef long K;
- ArrayOperator<long,long>();
- TheOperators->Add("^", new OneBinaryOperatorInv_KN_long(atype<KN_<long> >() ));
- aatypeknlongp= atype<KN<long>*>();
- Add<KN_<long> >("sort",".",new OneOperator1_<KN_<K>,KN_<K> >(SortKn<K, KN_<K> >));
- Dcl_TypeandPtr_<KN_<String>,KN<String> *>(0,0,0,::Destroy<KN<String> >, ::ClearReturnKK_<K,KN<String>,KN_<String> >,::ClearReturnpKK<String,KN<String> >);
- atype<KN<String>* >()->Add("[","",new OneOperator2_<string**,KN<String>*,long >(get_elements));
- TheOperators->Add("<-",
- new OneOperator2_<KN<String> *,KN<String> *,long>(&set_init_init));
- map_type_of_map[make_pair(atype<long>(),atype<string*>())]=atype<KN<String>*>();
- Add<KN<String> *>("n",".",new OneOperator1<long,KN<String> *>(get_n));
- extern KN<String> *pkarg;
- Global.New("ARGV",CPValue<KN<String> >(*pkarg));
- Global.Add("toZarray","(",new OneOperator_2KN_<long>);
- TheOperators->Add("=",
- new OneBinaryOperator<set_Inv_KN_long<KN_<long> ,Inv_KN_long > > );
- TheOperators->Add("<-",
- new OneBinaryOperator<set_Inv_pKN_longI<KN<long>*,Inv_KN_long > > );
-}
- void xxxx() {
-}
--
FreeFem++ packaging
More information about the debian-science-commits
mailing list