public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/9798: g++: Internal error: Segmentation fault (program cc1plus)
@ 2003-02-22 2:36 michael
0 siblings, 0 replies; only message in thread
From: michael @ 2003-02-22 2:36 UTC (permalink / raw)
To: gcc-gnats
>Number: 9798
>Category: c++
>Synopsis: g++: Internal error: Segmentation fault (program cc1plus)
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Feb 22 02:36:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Michael Cook
>Release: gcc-3.2.2
>Organization:
>Environment:
>Description:
>How-To-Repeat:
g++ -fmessage-length=0 -g -Werror -Wall -Wconversion -W -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wsign-compare -fPIC -c -o derived/x86-stlport/util/src/Logger.o Logger.ii
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="Logger.ii"
Content-Disposition: inline; filename="Logger.ii"
namespace std { }
namespace __std_alias = std;
namespace _STL { }
namespace stlport = _STL;
typedef int ptrdiff_t;
typedef unsigned int size_t;
namespace std
{
using ::ptrdiff_t;
using ::size_t;
}
namespace _STL {
using __std_alias::ptrdiff_t;
using __std_alias::size_t;
}
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__));
extern int atoi (__const char *__nptr) throw () __attribute__ ((__pure__));
extern long int atol (__const char *__nptr) throw () __attribute__ ((__pure__));
__extension__ extern long long int atoll (__const char *__nptr)
throw () __attribute__ ((__pure__));
extern double strtod (__const char *__restrict __nptr,
char **__restrict __endptr) throw ();
extern float strtof (__const char *__restrict __nptr,
char **__restrict __endptr) throw ();
extern long double strtold (__const char *__restrict __nptr,
char **__restrict __endptr) throw ();
extern long int strtol (__const char *__restrict __nptr,
char **__restrict __endptr, int __base) throw ();
extern unsigned long int strtoul (__const char *__restrict __nptr,
char **__restrict __endptr, int __base)
throw ();
__extension__
extern long long int strtoq (__const char *__restrict __nptr,
char **__restrict __endptr, int __base) throw ();
__extension__
extern unsigned long long int strtouq (__const char *__restrict __nptr,
char **__restrict __endptr, int __base)
throw ();
__extension__
extern long long int strtoll (__const char *__restrict __nptr,
char **__restrict __endptr, int __base) throw ();
__extension__
extern unsigned long long int strtoull (__const char *__restrict __nptr,
char **__restrict __endptr, int __base)
throw ();
typedef struct __locale_struct
{
struct locale_data *__locales[13];
const unsigned short int *__ctype_b;
const int *__ctype_tolower;
const int *__ctype_toupper;
} *__locale_t;
extern long int __strtol_l (__const char *__restrict __nptr,
char **__restrict __endptr, int __base,
__locale_t __loc) throw ();
extern unsigned long int __strtoul_l (__const char *__restrict __nptr,
char **__restrict __endptr,
int __base, __locale_t __loc) throw ();
__extension__
extern long long int __strtoll_l (__const char *__restrict __nptr,
char **__restrict __endptr, int __base,
__locale_t __loc) throw ();
__extension__
extern unsigned long long int __strtoull_l (__const char *__restrict __nptr,
char **__restrict __endptr,
int __base, __locale_t __loc)
throw ();
extern double __strtod_l (__const char *__restrict __nptr,
char **__restrict __endptr, __locale_t __loc)
throw ();
extern float __strtof_l (__const char *__restrict __nptr,
char **__restrict __endptr, __locale_t __loc) throw ();
extern long double __strtold_l (__const char *__restrict __nptr,
char **__restrict __endptr,
__locale_t __loc) throw ();
extern double __strtod_internal (__const char *__restrict __nptr,
char **__restrict __endptr, int __group)
throw ();
extern float __strtof_internal (__const char *__restrict __nptr,
char **__restrict __endptr, int __group)
throw ();
extern long double __strtold_internal (__const char *__restrict __nptr,
char **__restrict __endptr,
int __group) throw ();
extern long int __strtol_internal (__const char *__restrict __nptr,
char **__restrict __endptr,
int __base, int __group) throw ();
extern unsigned long int __strtoul_internal (__const char *__restrict __nptr,
char **__restrict __endptr,
int __base, int __group) throw ();
__extension__
extern long long int __strtoll_internal (__const char *__restrict __nptr,
char **__restrict __endptr,
int __base, int __group) throw ();
__extension__
extern unsigned long long int __strtoull_internal (__const char *
__restrict __nptr,
char **__restrict __endptr,
int __base, int __group)
throw ();
extern char *l64a (long int __n) throw ();
extern long int a64l (__const char *__s) throw () __attribute__ ((__pure__));
extern "C" {
typedef unsigned char __u_char;
typedef unsigned short __u_short;
typedef unsigned int __u_int;
typedef unsigned long __u_long;
__extension__ typedef unsigned long long int __u_quad_t;
__extension__ typedef long long int __quad_t;
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;
__extension__ typedef signed long long int __int64_t;
__extension__ typedef unsigned long long int __uint64_t;
typedef __quad_t *__qaddr_t;
typedef __u_quad_t __dev_t;
typedef __u_int __uid_t;
typedef __u_int __gid_t;
typedef __u_long __ino_t;
typedef __u_int __mode_t;
typedef __u_int __nlink_t;
typedef long int __off_t;
typedef __quad_t __loff_t;
typedef int __pid_t;
typedef int __ssize_t;
typedef __u_long __rlim_t;
typedef __u_quad_t __rlim64_t;
typedef __u_int __id_t;
typedef struct
{
int __val[2];
} __fsid_t;
typedef int __daddr_t;
typedef char *__caddr_t;
typedef long int __time_t;
typedef unsigned int __useconds_t;
typedef long int __suseconds_t;
typedef long int __swblk_t;
typedef long int __clock_t;
typedef int __clockid_t;
typedef int __timer_t;
typedef int __key_t;
typedef unsigned short int __ipc_pid_t;
typedef long int __blksize_t;
typedef long int __blkcnt_t;
typedef __quad_t __blkcnt64_t;
typedef __u_long __fsblkcnt_t;
typedef __u_quad_t __fsblkcnt64_t;
typedef __u_long __fsfilcnt_t;
typedef __u_quad_t __fsfilcnt64_t;
typedef __u_quad_t __ino64_t;
typedef __loff_t __off64_t;
typedef long int __t_scalar_t;
typedef unsigned long int __t_uscalar_t;
typedef int __intptr_t;
typedef unsigned int __socklen_t;
struct __sched_param
{
int __sched_priority;
};
struct _pthread_fastlock
{
long int __status;
int __spinlock;
};
typedef struct _pthread_descr_struct *_pthread_descr;
typedef struct __pthread_attr_s
{
int __detachstate;
int __schedpolicy;
struct __sched_param __schedparam;
int __inheritsched;
int __scope;
size_t __guardsize;
int __stackaddr_set;
void *__stackaddr;
size_t __stacksize;
} pthread_attr_t;
typedef struct
{
struct _pthread_fastlock __c_lock;
_pthread_descr __c_waiting;
} pthread_cond_t;
typedef struct
{
int __dummy;
} pthread_condattr_t;
typedef unsigned int pthread_key_t;
typedef struct
{
int __m_reserved;
int __m_count;
_pthread_descr __m_owner;
int __m_kind;
struct _pthread_fastlock __m_lock;
} pthread_mutex_t;
typedef struct
{
int __mutexkind;
} pthread_mutexattr_t;
typedef int pthread_once_t;
typedef struct _pthread_rwlock_t
{
struct _pthread_fastlock __rw_lock;
int __rw_readers;
_pthread_descr __rw_writer;
_pthread_descr __rw_read_waiting;
_pthread_descr __rw_write_waiting;
int __rw_kind;
int __rw_pshared;
} pthread_rwlock_t;
typedef struct
{
int __lockkind;
int __pshared;
} pthread_rwlockattr_t;
typedef volatile int pthread_spinlock_t;
typedef struct {
struct _pthread_fastlock __ba_lock;
int __ba_required;
int __ba_present;
_pthread_descr __ba_waiting;
} pthread_barrier_t;
typedef struct {
int __pshared;
} pthread_barrierattr_t;
typedef unsigned long int pthread_t;
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 __gid_t gid_t;
typedef __mode_t mode_t;
typedef __nlink_t nlink_t;
typedef __uid_t uid_t;
typedef __off_t off_t;
typedef __off64_t off64_t;
typedef __pid_t pid_t;
typedef __id_t id_t;
typedef __ssize_t ssize_t;
typedef __daddr_t daddr_t;
typedef __caddr_t caddr_t;
typedef __key_t key_t;
typedef __clock_t clock_t;
typedef __time_t time_t;
typedef __clockid_t clockid_t;
typedef __timer_t timer_t;
typedef __useconds_t useconds_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 timespec
{
__time_t tv_sec;
long int tv_nsec;
};
struct timeval
{
__time_t tv_sec;
__suseconds_t tv_usec;
};
typedef long int __fd_mask;
typedef struct
{
__fd_mask fds_bits[1024 / (8 * 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) throw ();
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) throw ();
}
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 ();
extern char *setstate (char *__statebuf) throw ();
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 ();
extern int srandom_r (unsigned int __seed, struct random_data *__buf) throw ();
extern int initstate_r (unsigned int __seed, char *__restrict __statebuf,
size_t __statelen,
struct random_data *__restrict __buf) throw ();
extern int setstate_r (char *__restrict __statebuf,
struct random_data *__restrict __buf) throw ();
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 ();
extern long int lrand48 (void) throw ();
extern long int nrand48 (unsigned short int __xsubi[3]) throw ();
extern long int mrand48 (void) throw ();
extern long int jrand48 (unsigned short int __xsubi[3]) throw ();
extern void srand48 (long int __seedval) throw ();
extern unsigned short int *seed48 (unsigned short int __seed16v[3]) throw ();
extern void lcong48 (unsigned short int __param[7]) throw ();
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 ();
extern int erand48_r (unsigned short int __xsubi[3],
struct drand48_data *__restrict __buffer,
double *__restrict __result) throw ();
extern int lrand48_r (struct drand48_data *__restrict __buffer,
long int *__restrict __result) throw ();
extern int nrand48_r (unsigned short int __xsubi[3],
struct drand48_data *__restrict __buffer,
long int *__restrict __result) throw ();
extern int mrand48_r (struct drand48_data *__restrict __buffer,
long int *__restrict __result) throw ();
extern int jrand48_r (unsigned short int __xsubi[3],
struct drand48_data *__restrict __buffer,
long int *__restrict __result) throw ();
extern int srand48_r (long int __seedval, struct drand48_data *__buffer)
throw ();
extern int seed48_r (unsigned short int __seed16v[3],
struct drand48_data *__buffer) throw ();
extern int lcong48_r (unsigned short int __param[7],
struct drand48_data *__buffer) throw ();
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__ ((__malloc__));
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__ ((__malloc__));
extern void abort (void) throw () __attribute__ ((__noreturn__));
extern int atexit (void (*__func) (void)) throw ();
extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg)
throw ();
extern void exit (int __status) throw () __attribute__ ((__noreturn__));
extern void _Exit (int __status) throw () __attribute__ ((__noreturn__));
extern char *getenv (__const char *__name) throw ();
extern char *__secure_getenv (__const char *__name) throw ();
extern int putenv (char *__string) throw ();
extern int setenv (__const char *__name, __const char *__value, int __replace)
throw ();
extern int unsetenv (__const char *__name) throw ();
extern int clearenv (void) throw ();
extern char *mktemp (char *__template) throw ();
extern int mkstemp (char *__template) throw ();
extern int mkstemp64 (char *__template) throw ();
extern char *mkdtemp (char *__template) throw ();
extern int system (__const char *__command) throw ();
extern char *canonicalize_file_name (__const char *__name) throw ();
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;
extern void *bsearch (__const void *__key, __const void *__base,
size_t __nmemb, size_t __size, __compar_fn_t __compar);
extern void qsort (void *__base, size_t __nmemb, size_t __size,
__compar_fn_t __compar);
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 ();
extern char *fcvt (double __value, int __ndigit, int *__restrict __decpt,
int *__restrict __sign) throw ();
extern char *gcvt (double __value, int __ndigit, char *__buf) throw ();
extern char *qecvt (long double __value, int __ndigit,
int *__restrict __decpt, int *__restrict __sign) throw ();
extern char *qfcvt (long double __value, int __ndigit,
int *__restrict __decpt, int *__restrict __sign) throw ();
extern char *qgcvt (long double __value, int __ndigit, char *__buf) throw ();
extern int ecvt_r (double __value, int __ndigit, int *__restrict __decpt,
int *__restrict __sign, char *__restrict __buf,
size_t __len) throw ();
extern int fcvt_r (double __value, int __ndigit, int *__restrict __decpt,
int *__restrict __sign, char *__restrict __buf,
size_t __len) throw ();
extern int qecvt_r (long double __value, int __ndigit,
int *__restrict __decpt, int *__restrict __sign,
char *__restrict __buf, size_t __len) throw ();
extern int qfcvt_r (long double __value, int __ndigit,
int *__restrict __decpt, int *__restrict __sign,
char *__restrict __buf, size_t __len) throw ();
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 ();
extern int getsubopt (char **__restrict __optionp,
char *__const *__restrict __tokens,
char **__restrict __valuep) throw ();
extern void setkey (__const char *__key) throw ();
extern int posix_openpt (int __oflag) throw ();
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 ();
extern int getpt (void) throw ();
extern int getloadavg (double __loadavg[], int __nelem) throw ();
}
namespace std
{
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
{
using ::lldiv_t;
using ::_Exit;
inline long long
abs(long long __x) { return __x >= 0 ? __x : -__x; }
inline long long
llabs(long long __x) { return __x >= 0 ? __x : -__x; }
inline lldiv_t
div(long long __n, long long __d)
{ lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
inline lldiv_t
lldiv(long long __n, long long __d)
{ lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
using ::atoll;
using ::strtof;
using ::strtoll;
using ::strtoull;
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 _STL {
using __std_alias::div_t;
using __std_alias::ldiv_t;
using __std_alias::size_t;
using __std_alias::abort;
using __std_alias::atexit;
using __std_alias::exit;
using __std_alias::getenv;
using __std_alias::calloc;
using __std_alias::free;
using __std_alias::malloc;
using __std_alias::realloc;
using __std_alias::atof;
using __std_alias::atoi;
using __std_alias::atol;
using __std_alias::mblen;
using __std_alias::mbstowcs;
using __std_alias::mbtowc;
using __std_alias::strtod;
using __std_alias::strtol;
using __std_alias::strtoul;
using __std_alias::system;
using __std_alias::bsearch;
using __std_alias::qsort;
using __std_alias::abs;
using __std_alias::div;
using __std_alias::labs;
using __std_alias::ldiv;
using __std_alias::rand;
using __std_alias::srand;
}
namespace _STL {
}
extern "C" {
extern void *memcpy (void *__restrict __dest,
__const void *__restrict __src, size_t __n) throw ();
extern void *memmove (void *__dest, __const void *__src, size_t __n)
throw ();
extern void *memccpy (void *__restrict __dest, __const void *__restrict __src,
int __c, size_t __n)
throw ();
extern void *memset (void *__s, int __c, size_t __n) throw ();
extern int memcmp (__const void *__s1, __const void *__s2, size_t __n)
throw () __attribute__ ((__pure__));
extern void *memchr (__const void *__s, int __c, size_t __n)
throw () __attribute__ ((__pure__));
extern void *rawmemchr (__const void *__s, int __c) throw () __attribute__ ((__pure__));
extern void *memrchr (__const void *__s, int __c, size_t __n)
throw () __attribute__ ((__pure__));
extern char *strcpy (char *__restrict __dest, __const char *__restrict __src)
throw ();
extern char *strncpy (char *__restrict __dest,
__const char *__restrict __src, size_t __n) throw ();
extern char *strcat (char *__restrict __dest, __const char *__restrict __src)
throw ();
extern char *strncat (char *__restrict __dest, __const char *__restrict __src,
size_t __n) throw ();
extern int strcmp (__const char *__s1, __const char *__s2)
throw () __attribute__ ((__pure__));
extern int strncmp (__const char *__s1, __const char *__s2, size_t __n)
throw () __attribute__ ((__pure__));
extern int strcoll (__const char *__s1, __const char *__s2)
throw () __attribute__ ((__pure__));
extern size_t strxfrm (char *__restrict __dest,
__const char *__restrict __src, size_t __n) throw ();
extern int __strcoll_l (__const char *__s1, __const char *__s2, __locale_t __l)
throw () __attribute__ ((__pure__));
extern size_t __strxfrm_l (char *__dest, __const char *__src, size_t __n,
__locale_t __l) throw ();
extern char *strdup (__const char *__s) throw () __attribute__ ((__malloc__));
extern char *strndup (__const char *__string, size_t __n)
throw () __attribute__ ((__malloc__));
extern char *strchr (__const char *__s, int __c) throw () __attribute__ ((__pure__));
extern char *strrchr (__const char *__s, int __c) throw () __attribute__ ((__pure__));
extern char *strchrnul (__const char *__s, int __c) throw () __attribute__ ((__pure__));
extern size_t strcspn (__const char *__s, __const char *__reject)
throw () __attribute__ ((__pure__));
extern size_t strspn (__const char *__s, __const char *__accept)
throw () __attribute__ ((__pure__));
extern char *strpbrk (__const char *__s, __const char *__accept)
throw () __attribute__ ((__pure__));
extern char *strstr (__const char *__haystack, __const char *__needle)
throw () __attribute__ ((__pure__));
extern char *strcasestr (__const char *__haystack, __const char *__needle)
throw () __attribute__ ((__pure__));
extern char *strtok (char *__restrict __s, __const char *__restrict __delim)
throw ();
extern char *__strtok_r (char *__restrict __s,
__const char *__restrict __delim,
char **__restrict __save_ptr) throw ();
extern char *strtok_r (char *__restrict __s, __const char *__restrict __delim,
char **__restrict __save_ptr) throw ();
extern void *memmem (__const void *__haystack, size_t __haystacklen,
__const void *__needle, size_t __needlelen)
throw () __attribute__ ((__pure__));
extern void *__mempcpy (void *__restrict __dest,
__const void *__restrict __src, size_t __n) throw ();
extern void *mempcpy (void *__restrict __dest,
__const void *__restrict __src, size_t __n) throw ();
extern size_t strlen (__const char *__s) throw () __attribute__ ((__pure__));
extern size_t strnlen (__const char *__string, size_t __maxlen)
throw () __attribute__ ((__pure__));
extern char *strerror (int __errnum) throw ();
extern char *strerror_r (int __errnum, char *__buf, size_t __buflen) throw ();
extern void __bzero (void *__s, size_t __n) throw ();
extern void bcopy (__const void *__src, void *__dest, size_t __n) throw ();
extern void bzero (void *__s, size_t __n) throw ();
extern int bcmp (__const void *__s1, __const void *__s2, size_t __n)
throw () __attribute__ ((__pure__));
extern char *index (__const char *__s, int __c) throw () __attribute__ ((__pure__));
extern char *rindex (__const char *__s, int __c) throw () __attribute__ ((__pure__));
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__));
extern int strncasecmp (__const char *__s1, __const char *__s2, size_t __n)
throw () __attribute__ ((__pure__));
extern int __strcasecmp_l (__const char *__s1, __const char *__s2,
__locale_t __loc) throw () __attribute__ ((__pure__));
extern int __strncasecmp_l (__const char *__s1, __const char *__s2,
size_t __n, __locale_t __loc)
throw () __attribute__ ((__pure__));
extern char *strsep (char **__restrict __stringp,
__const char *__restrict __delim) throw ();
extern int strverscmp (__const char *__s1, __const char *__s2)
throw () __attribute__ ((__pure__));
extern char *strsignal (int __sig) throw ();
extern char *__stpcpy (char *__restrict __dest, __const char *__restrict __src)
throw ();
extern char *stpcpy (char *__restrict __dest, __const char *__restrict __src)
throw ();
extern char *__stpncpy (char *__restrict __dest,
__const char *__restrict __src, size_t __n) throw ();
extern char *stpncpy (char *__restrict __dest,
__const char *__restrict __src, size_t __n) throw ();
extern char *strfry (char *__string) throw ();
extern void *memfrob (void *__s, size_t __n) throw ();
extern char *basename (__const char *__filename) throw ();
}
namespace std
{
using ::memcpy;
using ::memmove;
using ::strcpy;
using ::strncpy;
using ::strcat;
using ::strncat;
using ::memcmp;
using ::strcmp;
using ::strcoll;
using ::strncmp;
using ::strxfrm;
using ::strcspn;
using ::strspn;
using ::strtok;
using ::memset;
using ::strerror;
using ::strlen;
using ::memchr;
inline void*
memchr(void* __p, int __c, size_t __n)
{ return memchr(const_cast<const void*>(__p), __c, __n); }
using ::strchr;
inline char*
strchr(char* __s1, int __n)
{ return __builtin_strchr(const_cast<const char*>(__s1), __n); }
using ::strpbrk;
inline char*
strpbrk(char* __s1, const char* __s2)
{ return __builtin_strpbrk(const_cast<const char*>(__s1), __s2); }
using ::strrchr;
inline char*
strrchr(char* __s1, int __n)
{ return __builtin_strrchr(const_cast<const char*>(__s1), __n); }
using ::strstr;
inline char*
strstr(char* __s1, const char* __s2)
{ return __builtin_strstr(const_cast<const char*>(__s1), __s2); }
}
namespace _STL {
using __std_alias::size_t;
using __std_alias::memmove;
using __std_alias::memcpy;
using __std_alias::memchr;
using __std_alias::strchr;
using __std_alias::strpbrk;
using __std_alias::strrchr;
using __std_alias::strstr;
using __std_alias::memcmp;
using __std_alias::memset;
using __std_alias::strcat;
using __std_alias::strcmp;
using __std_alias::strcoll;
using __std_alias::strcpy;
using __std_alias::strcspn;
using __std_alias::strerror;
using __std_alias::strlen;
using __std_alias::strncat;
using __std_alias::strncmp;
using __std_alias::strncpy;
using __std_alias::strspn;
using __std_alias::strtok;
using __std_alias::strxfrm;
}
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();
};
typedef void (*terminate_handler) ();
typedef void (*unexpected_handler) ();
terminate_handler set_terminate(terminate_handler) throw();
void terminate() __attribute__ ((__noreturn__));
unexpected_handler set_unexpected(unexpected_handler) throw();
void unexpected() __attribute__ ((__noreturn__));
bool uncaught_exception() throw();
}
namespace __gnu_cxx
{
void __verbose_terminate_handler ();
}
}
namespace _STL {
using __std_alias::exception;
using __std_alias::bad_exception;
using __std_alias::unexpected;
using __std_alias::unexpected_handler;
using __std_alias::set_unexpected;
using __std_alias::terminate;
using __std_alias::terminate_handler;
using __std_alias::set_terminate;
}
extern "C++" {
namespace std
{
class bad_alloc : public exception
{
public:
bad_alloc() throw() { }
virtual ~bad_alloc() 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() { };
}
namespace _STL {
using __std_alias::bad_alloc;
using __std_alias::nothrow_t;
using __std_alias::nothrow;
using __std_alias::new_handler;
using __std_alias::set_new_handler;
}
namespace _STL {
inline void* __stl_new(size_t __n) { return ::operator new(__n); }
inline void __stl_delete(void* __p) { ::operator delete(__p); }
}
using namespace __std_alias;
typedef size_t __stl_atomic_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 "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 "C" {
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 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) throw ();
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) throw ();
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) throw ();
extern int getdate_r (__const char *__restrict __string,
struct tm *__restrict __resbufp) throw ();
}
extern "C" {
}
extern "C" {
enum
{
PTHREAD_CREATE_JOINABLE,
PTHREAD_CREATE_DETACHED
};
enum
{
PTHREAD_INHERIT_SCHED,
PTHREAD_EXPLICIT_SCHED
};
enum
{
PTHREAD_SCOPE_SYSTEM,
PTHREAD_SCOPE_PROCESS
};
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_ADAPTIVE_NP
};
enum
{
PTHREAD_PROCESS_PRIVATE,
PTHREAD_PROCESS_SHARED
};
enum
{
PTHREAD_RWLOCK_PREFER_READER_NP,
PTHREAD_RWLOCK_PREFER_WRITER_NP,
PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,
PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_WRITER_NP
};
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 int pthread_create (pthread_t *__restrict __thread,
__const pthread_attr_t *__restrict __attr,
void *(*__start_routine) (void *),
void *__restrict __arg) throw ();
extern pthread_t pthread_self (void) throw ();
extern int pthread_equal (pthread_t __thread1, pthread_t __thread2) throw ();
extern void pthread_exit (void *__retval)
throw () __attribute__ ((__noreturn__));
extern int pthread_join (pthread_t __th, void **__thread_return) throw ();
extern int pthread_detach (pthread_t __th) throw ();
extern int pthread_attr_init (pthread_attr_t *__attr) throw ();
extern int pthread_attr_destroy (pthread_attr_t *__attr) throw ();
extern int pthread_attr_setdetachstate (pthread_attr_t *__attr,
int __detachstate) throw ();
extern int pthread_attr_getdetachstate (__const pthread_attr_t *__attr,
int *__detachstate) throw ();
extern int pthread_attr_setschedparam (pthread_attr_t *__restrict __attr,
__const struct sched_param *__restrict
__param) throw ();
extern int pthread_attr_getschedparam (__const pthread_attr_t *__restrict
__attr,
struct sched_param *__restrict __param)
throw ();
extern int pthread_attr_setschedpolicy (pthread_attr_t *__attr, int __policy)
throw ();
extern int pthread_attr_getschedpolicy (__const pthread_attr_t *__restrict
__attr, int *__restrict __policy)
throw ();
extern int pthread_attr_setinheritsched (pthread_attr_t *__attr,
int __inherit) throw ();
extern int pthread_attr_getinheritsched (__const pthread_attr_t *__restrict
__attr, int *__restrict __inherit)
throw ();
extern int pthread_attr_setscope (pthread_attr_t *__attr, int __scope)
throw ();
extern int pthread_attr_getscope (__const pthread_attr_t *__restrict __attr,
int *__restrict __scope) throw ();
extern int pthread_attr_setguardsize (pthread_attr_t *__attr,
size_t __guardsize) throw ();
extern int pthread_attr_getguardsize (__const pthread_attr_t *__restrict
__attr, size_t *__restrict __guardsize)
throw ();
extern int pthread_attr_setstackaddr (pthread_attr_t *__attr,
void *__stackaddr) throw ();
extern int pthread_attr_getstackaddr (__const pthread_attr_t *__restrict
__attr, void **__restrict __stackaddr)
throw ();
extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
size_t __stacksize) throw ();
extern int pthread_attr_getstack (__const pthread_attr_t *__restrict __attr,
void **__restrict __stackaddr,
size_t *__restrict __stacksize) throw ();
extern int pthread_attr_setstacksize (pthread_attr_t *__attr,
size_t __stacksize) throw ();
extern int pthread_attr_getstacksize (__const pthread_attr_t *__restrict
__attr, size_t *__restrict __stacksize)
throw ();
extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr) throw ();
extern int pthread_setschedparam (pthread_t __target_thread, int __policy,
__const struct sched_param *__param)
throw ();
extern int pthread_getschedparam (pthread_t __target_thread,
int *__restrict __policy,
struct sched_param *__restrict __param)
throw ();
extern int pthread_getconcurrency (void) throw ();
extern int pthread_setconcurrency (int __level) throw ();
extern int pthread_yield (void) throw ();
extern int pthread_mutex_init (pthread_mutex_t *__restrict __mutex,
__const pthread_mutexattr_t *__restrict
__mutex_attr) throw ();
extern int pthread_mutex_destroy (pthread_mutex_t *__mutex) throw ();
extern int pthread_mutex_trylock (pthread_mutex_t *__mutex) throw ();
extern int pthread_mutex_lock (pthread_mutex_t *__mutex) throw ();
extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,
__const struct timespec *__restrict
__abstime) throw ();
extern int pthread_mutex_unlock (pthread_mutex_t *__mutex) throw ();
extern int pthread_mutexattr_init (pthread_mutexattr_t *__attr) throw ();
extern int pthread_mutexattr_destroy (pthread_mutexattr_t *__attr) throw ();
extern int pthread_mutexattr_getpshared (__const pthread_mutexattr_t *
__restrict __attr,
int *__restrict __pshared) throw ();
extern int pthread_mutexattr_setpshared (pthread_mutexattr_t *__attr,
int __pshared) throw ();
extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind)
throw ();
extern int pthread_mutexattr_gettype (__const pthread_mutexattr_t *__restrict
__attr, int *__restrict __kind) throw ();
extern int pthread_cond_init (pthread_cond_t *__restrict __cond,
__const pthread_condattr_t *__restrict
__cond_attr) throw ();
extern int pthread_cond_destroy (pthread_cond_t *__cond) throw ();
extern int pthread_cond_signal (pthread_cond_t *__cond) throw ();
extern int pthread_cond_broadcast (pthread_cond_t *__cond) throw ();
extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
pthread_mutex_t *__restrict __mutex) throw ();
extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
pthread_mutex_t *__restrict __mutex,
__const struct timespec *__restrict
__abstime) throw ();
extern int pthread_condattr_init (pthread_condattr_t *__attr) throw ();
extern int pthread_condattr_destroy (pthread_condattr_t *__attr) throw ();
extern int pthread_condattr_getpshared (__const pthread_condattr_t *
__restrict __attr,
int *__restrict __pshared) throw ();
extern int pthread_condattr_setpshared (pthread_condattr_t *__attr,
int __pshared) throw ();
extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
__const pthread_rwlockattr_t *__restrict
__attr) throw ();
extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock) throw ();
extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock) throw ();
extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock) throw ();
extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,
__const struct timespec *__restrict
__abstime) throw ();
extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock) throw ();
extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock) throw ();
extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,
__const struct timespec *__restrict
__abstime) throw ();
extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock) throw ();
extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr) throw ();
extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr) throw ();
extern int pthread_rwlockattr_getpshared (__const pthread_rwlockattr_t *
__restrict __attr,
int *__restrict __pshared) throw ();
extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *__attr,
int __pshared) throw ();
extern int pthread_rwlockattr_getkind_np (__const pthread_rwlockattr_t *__attr,
int *__pref) throw ();
extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr,
int __pref) throw ();
extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared)
throw ();
extern int pthread_spin_destroy (pthread_spinlock_t *__lock) throw ();
extern int pthread_spin_lock (pthread_spinlock_t *__lock) throw ();
extern int pthread_spin_trylock (pthread_spinlock_t *__lock) throw ();
extern int pthread_spin_unlock (pthread_spinlock_t *__lock) throw ();
extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier,
__const pthread_barrierattr_t *__restrict
__attr, unsigned int __count) throw ();
extern int pthread_barrier_destroy (pthread_barrier_t *__barrier) throw ();
extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr) throw ();
extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr) throw ();
extern int pthread_barrierattr_getpshared (__const pthread_barrierattr_t *
__restrict __attr,
int *__restrict __pshared) throw ();
extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr,
int __pshared) throw ();
extern int pthread_barrier_wait (pthread_barrier_t *__barrier) throw ();
extern int pthread_key_create (pthread_key_t *__key,
void (*__destr_function) (void *)) throw ();
extern int pthread_key_delete (pthread_key_t __key) throw ();
extern int pthread_setspecific (pthread_key_t __key,
__const void *__pointer) throw ();
extern void *pthread_getspecific (pthread_key_t __key) throw ();
extern int pthread_once (pthread_once_t *__once_control,
void (*__init_routine) (void)) throw ();
extern int pthread_setcancelstate (int __state, int *__oldstate) throw ();
extern int pthread_setcanceltype (int __type, int *__oldtype) throw ();
extern int pthread_cancel (pthread_t __thread) throw ();
extern void pthread_testcancel (void) throw ();
extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *__buffer,
void (*__routine) (void *),
void *__arg) throw ();
extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *__buffer,
int __execute) throw ();
extern void _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *__buffer,
void (*__routine) (void *),
void *__arg) throw ();
extern void _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *__buffer,
int __execute) throw ();
extern int pthread_getcpuclockid (pthread_t __thread_id,
clockid_t *__clock_id) throw ();
extern int pthread_sigmask (int __how,
__const __sigset_t *__restrict __newmask,
__sigset_t *__restrict __oldmask)throw ();
extern int pthread_kill (pthread_t __thread, int __signo) throw ();
extern int pthread_atfork (void (*__prepare) (void),
void (*__parent) (void),
void (*__child) (void)) throw ();
extern void pthread_kill_other_threads_np (void) throw ();
}
namespace _STL {
template <int __inst>
struct _STLP_mutex_spin {
enum { __low_max = 30, __high_max = 1000 };
static unsigned __max;
static unsigned __last;
static void _M_do_lock(volatile __stl_atomic_t* __lock);
static void _S_nsec_sleep(int __log_nsec);
};
struct _STLP_mutex_base
{
inline void _M_initialize() {}
inline void _M_destroy() {}
inline void _M_acquire_lock() {}
inline void _M_release_lock() {}
};
struct _STLP_mutex_indirect
{
void* _M_lock;
inline void _M_initialize() {
_M_lock = (void*)__std_alias::calloc(1,sizeof(pthread_mutex_t));
pthread_mutex_init((pthread_mutex_t*)_M_lock,0);
}
inline void _M_destroy() {
pthread_mutex_destroy((pthread_mutex_t*)_M_lock);
free((char*)_M_lock);
}
inline void _M_acquire_lock() {
pthread_mutex_lock((pthread_mutex_t*)_M_lock);
}
inline void _M_release_lock() { pthread_mutex_unlock((pthread_mutex_t*)_M_lock); }
};
struct _STLP_mutex : public _STLP_mutex_indirect {
inline _STLP_mutex () {
_M_initialize();
}
inline ~_STLP_mutex () {
_M_destroy();
}
private:
_STLP_mutex(const _STLP_mutex&);
void operator=(const _STLP_mutex&);
};
struct _Refcount_Base
{
volatile __stl_atomic_t _M_ref_count;
_STLP_mutex _M_mutex;
_Refcount_Base(__stl_atomic_t __n) : _M_ref_count(__n) {}
void _M_incr() { ++_M_ref_count; }
void _M_decr() { --_M_ref_count; }
};
template<int __dummy>
struct _Swap_lock_struct {
static _STLP_mutex_base _S_swap_lock;
};
inline __stl_atomic_t _Atomic_swap(volatile __stl_atomic_t * __p, __stl_atomic_t __q) {
_Swap_lock_struct<0>::_S_swap_lock._M_acquire_lock();
__stl_atomic_t __result = *__p;
*__p = __q;
_Swap_lock_struct<0>::_S_swap_lock._M_release_lock();
return __result;
}
struct _STLP_auto_lock
{
_STLP_mutex_base& _M_lock;
_STLP_auto_lock(_STLP_mutex_base& __lock) : _M_lock(__lock)
{ _M_lock._M_acquire_lock(); }
~_STLP_auto_lock() { _M_lock._M_release_lock(); }
private:
void operator=(const _STLP_auto_lock&);
_STLP_auto_lock(const _STLP_auto_lock&);
};
struct _STLP_mutex_lock
{
_STLP_mutex_indirect& _M_lock;
_STLP_mutex_lock(_STLP_mutex_indirect& __lock) : _M_lock(__lock)
{ _M_lock._M_acquire_lock(); }
~_STLP_mutex_lock() { _M_lock._M_release_lock(); }
private:
void operator=(const _STLP_mutex_lock&);
_STLP_mutex_lock(const _STLP_mutex_lock&);
};
}
namespace _STL {
using namespace __std_alias;
}
namespace _STL {
struct __true_type {};
struct __false_type {};
template <int _Is> struct __bool2type {
typedef __false_type _Ret;
};
template<>
struct __bool2type<1> { typedef __true_type _Ret; };
template<>
struct __bool2type<0> { typedef __false_type _Ret; };
template <class _P1, class _P2, class _P3>
struct _Land3 {
typedef __false_type _Ret;
};
template<>
struct _Land3<__true_type, __true_type, __true_type> {
typedef __true_type _Ret;
};
template <class _Tp> struct __type_traits;
template <int _IsPOD> struct __type_traits_aux {
typedef __false_type has_trivial_default_constructor;
typedef __false_type has_trivial_copy_constructor;
typedef __false_type has_trivial_assignment_operator;
typedef __false_type has_trivial_destructor;
typedef __false_type is_POD_type;
};
template<>
struct __type_traits_aux<0> {
typedef __false_type has_trivial_default_constructor;
typedef __false_type has_trivial_copy_constructor;
typedef __false_type has_trivial_assignment_operator;
typedef __false_type has_trivial_destructor;
typedef __false_type is_POD_type;
};
template<>
struct __type_traits_aux<1> {
typedef __true_type has_trivial_default_constructor;
typedef __true_type has_trivial_copy_constructor;
typedef __true_type has_trivial_assignment_operator;
typedef __true_type has_trivial_destructor;
typedef __true_type is_POD_type;
};
template <class _Tp>
struct __type_traits {
typedef __true_type this_dummy_member_must_be_first;
typedef __false_type has_trivial_default_constructor;
typedef __false_type has_trivial_copy_constructor;
typedef __false_type has_trivial_assignment_operator;
typedef __false_type has_trivial_destructor;
typedef __false_type is_POD_type;
};
template <class _Tp> struct _IsPtr { enum { _Ret = 0 }; };
template <class _Tp> struct _IsPtrType {
static __false_type _Ret() { return __false_type();}
};
template <class _Tp1, class _Tp2> struct _BothPtrType {
static __false_type _Ret() { return __false_type();}
};
template <class _Tp1, class _Tp2>
struct _IsSame { enum { _Ret = 0 }; };
template <class _Tp> struct _IsPtr<_Tp*> { enum { _Ret = 1 }; };
template <class _Tp> struct _IsPtrType<_Tp*> {
static __true_type _Ret() { return __true_type();}
};
template <class _Tp1, class _Tp2> struct _BothPtrType<_Tp1*, _Tp2*> {
static __true_type _Ret() { return __true_type();}
};
template <class _Tp>
struct _IsSame<_Tp, _Tp> { enum { _Ret = 1 }; };
template<> struct __type_traits<bool> : __type_traits_aux<1> {};
template<> struct __type_traits<char> : __type_traits_aux<1> {};
template<> struct __type_traits<signed char> : __type_traits_aux<1> {};
template<> struct __type_traits<unsigned char> : __type_traits_aux<1> {};
template<> struct __type_traits<wchar_t> : __type_traits_aux<1> {};
template<> struct __type_traits<short> : __type_traits_aux<1> {};
template<> struct __type_traits<unsigned short> : __type_traits_aux<1> {};
template<> struct __type_traits<int> : __type_traits_aux<1> {};
template<> struct __type_traits<unsigned int> : __type_traits_aux<1> {};
template<> struct __type_traits<long> : __type_traits_aux<1> {};
template<> struct __type_traits<unsigned long> : __type_traits_aux<1> {};
template<> struct __type_traits<long long> : __type_traits_aux<1> {};
template<> struct __type_traits<unsigned long long> : __type_traits_aux<1> {};
template<> struct __type_traits<float> : __type_traits_aux<1> {};
template<> struct __type_traits<double> : __type_traits_aux<1> {};
template<> struct __type_traits<long double> : __type_traits_aux<1> {};
template <class _Tp> struct __type_traits<_Tp*> : __type_traits_aux<1> {};
template <class _Tp> struct _Is_integer {
typedef __false_type _Integral;
};
template<> struct _Is_integer<bool> {
typedef __true_type _Integral;
};
template<> struct _Is_integer<char> {
typedef __true_type _Integral;
};
template<> struct _Is_integer<signed char> {
typedef __true_type _Integral;
};
template<> struct _Is_integer<unsigned char> {
typedef __true_type _Integral;
};
template<> struct _Is_integer<wchar_t> {
typedef __true_type _Integral;
};
template<> struct _Is_integer<short> {
typedef __true_type _Integral;
};
template<> struct _Is_integer<unsigned short> {
typedef __true_type _Integral;
};
template<> struct _Is_integer<int> {
typedef __true_type _Integral;
};
template<> struct _Is_integer<unsigned int> {
typedef __true_type _Integral;
};
template<> struct _Is_integer<long> {
typedef __true_type _Integral;
};
template<> struct _Is_integer<unsigned long> {
typedef __true_type _Integral;
};
template<> struct _Is_integer<long long> {
typedef __true_type _Integral;
};
template<> struct _Is_integer<unsigned long long> {
typedef __true_type _Integral;
};
template <class _Tp1, class _Tp2>
struct _OKToMemCpy {
enum { _Same = _IsSame<_Tp1,_Tp2>::_Ret } ;
typedef typename __type_traits<_Tp1>::has_trivial_assignment_operator _Tr1;
typedef typename __type_traits<_Tp2>::has_trivial_assignment_operator _Tr2;
typedef typename __bool2type< _Same >::_Ret _Tr3;
typedef typename _Land3<_Tr1, _Tr2, _Tr3>::_Ret _Type;
static _Type _Ret() { return _Type(); }
};
template <class _Tp1, class _Tp2>
inline _OKToMemCpy<_Tp1, _Tp2> _IsOKToMemCpy(_Tp1*, _Tp2*) {
return _OKToMemCpy<_Tp1, _Tp2>();
}
template <class _Tp>
struct _IsPOD {
typedef typename __type_traits<_Tp>::is_POD_type _Type;
static _Type _Ret() { return _Type(); }
};
template <class _Tp>
inline _IsPOD<_Tp> _Is_POD (_Tp*) { return _IsPOD<_Tp>(); }
}
namespace _STL {
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 <class _Category, class _Tp, class _Distance = ptrdiff_t,
class _Pointer = _Tp*, class _Reference = _Tp& >
struct iterator {
typedef _Category iterator_category;
typedef _Tp value_type;
typedef _Distance difference_type;
typedef _Pointer pointer;
typedef _Reference reference;
};
template<>
struct iterator<output_iterator_tag, void, void, void, void> {
typedef output_iterator_tag iterator_category;
typedef void value_type;
typedef void difference_type;
typedef void pointer;
typedef void reference;
};
template <class _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 <class _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 <class _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 <class _Iter>
inline typename iterator_traits<_Iter>::iterator_category __iterator_category(const _Iter&) {
typedef typename iterator_traits<_Iter>::iterator_category _Category;
return _Category();
}
template <class _Iter>
inline typename iterator_traits<_Iter>::difference_type* __distance_type(const _Iter&) {
typedef typename iterator_traits<_Iter>::difference_type _diff_type;
return static_cast<_diff_type*>(0);
}
template <class _Iter>
inline typename iterator_traits<_Iter>::value_type* __value_type(const _Iter&) {
typedef typename iterator_traits<_Iter>::value_type _value_type;
return static_cast<_value_type*>(0);
}
template <class _Tp, class _Distance> struct input_iterator :
public iterator <input_iterator_tag, _Tp, _Distance, _Tp*, _Tp&> {};
struct output_iterator : public iterator <output_iterator_tag, void, void, void, void> {};
template <class _Tp, class _Distance> struct forward_iterator :
public iterator<forward_iterator_tag, _Tp, _Distance, _Tp*, _Tp&> {};
template <class _Tp, class _Distance> struct bidirectional_iterator :
public iterator<bidirectional_iterator_tag, _Tp, _Distance, _Tp*, _Tp&> {};
template <class _Tp, class _Distance> struct random_access_iterator :
public iterator<random_access_iterator_tag, _Tp, _Distance, _Tp*, _Tp&> {};
template <class _InputIterator, class _Distance>
inline void __distance(const _InputIterator& __first, const _InputIterator& __last,
_Distance& __n, const input_iterator_tag &) {
_InputIterator __it(__first);
while (__it != __last) { ++__it; ++__n; }
}
template <class _RandomAccessIterator, class _Distance>
inline void __distance(const _RandomAccessIterator& __first,
const _RandomAccessIterator& __last,
_Distance& __n, const random_access_iterator_tag &) {
__n += __last - __first;
}
template <class _InputIterator, class _Distance>
inline void distance(const _InputIterator& __first,
const _InputIterator& __last, _Distance& __n) {
__distance(__first, __last, __n, typename iterator_traits< _InputIterator >::iterator_category());
}
template <class _InputIterator>
inline typename iterator_traits<_InputIterator>::difference_type
__distance(const _InputIterator& __first, const _InputIterator& __last, const input_iterator_tag &) {
typename iterator_traits<_InputIterator>::difference_type __n = 0;
_InputIterator __it(__first);
while (__it != __last) {
++__it; ++__n;
}
return __n;
}
template <class _RandomAccessIterator>
inline typename iterator_traits<_RandomAccessIterator>::difference_type
__distance(const _RandomAccessIterator& __first, const _RandomAccessIterator& __last,
const random_access_iterator_tag &) {
return __last - __first;
}
template <class _InputIterator>
inline typename iterator_traits<_InputIterator>::difference_type
distance(const _InputIterator& __first, const _InputIterator& __last) {
return __distance(__first, __last, typename iterator_traits< _InputIterator >::iterator_category());
}
template <class _Tp>
struct _Nonconst_traits;
template <class _Tp>
struct _Const_traits {
typedef _Tp value_type;
typedef const _Tp& reference;
typedef const _Tp* pointer;
typedef _Nonconst_traits<_Tp> _Non_const_traits;
};
template <class _Tp>
struct _Nonconst_traits {
typedef _Tp value_type;
typedef _Tp& reference;
typedef _Tp* pointer;
typedef _Nonconst_traits<_Tp> _Non_const_traits;
};
template <class _InputIter, class _Distance>
inline void __advance(_InputIter& __i, _Distance __n, const input_iterator_tag &) {
while (__n--) ++__i;
}
template <class _InputIter, class _Distance>
inline void __advance(_InputIter& __i, _Distance __n, const output_iterator_tag &) {
while (__n--) ++__i;
}
template <class _BidirectionalIterator, class _Distance>
inline void __advance(_BidirectionalIterator& __i, _Distance __n,
const bidirectional_iterator_tag &) {
if (__n > 0)
while (__n--) ++__i;
else
while (__n++) --__i;
}
template <class _RandomAccessIterator, class _Distance>
inline void __advance(_RandomAccessIterator& __i, _Distance __n,
const random_access_iterator_tag &) {
__i += __n;
}
template <class _InputIterator, class _Distance>
inline void advance(_InputIterator& __i, _Distance __n) {
__advance(__i, __n, typename iterator_traits< _InputIterator >::iterator_category());
}
}
namespace _STL {
template <class _Tp>
inline void _Destroy(_Tp* __pointer) {
__pointer->~_Tp();
}
template <class _T1, class _T2>
inline void _Construct(_T1* __p, const _T2& __val) {
new (__p) _T1(__val);
}
template <class _T1>
inline void _Construct(_T1* __p) {
new (__p) _T1();
}
template <class _ForwardIterator>
inline void
__destroy_aux(_ForwardIterator __first, _ForwardIterator __last, const __false_type&) {
for ( ; __first != __last; ++__first)
_Destroy(&*__first);
}
template <class _ForwardIterator>
inline void __destroy_aux(_ForwardIterator, _ForwardIterator, const __true_type&) {}
template <class _ForwardIterator, class _Tp>
inline void
__destroy(_ForwardIterator __first, _ForwardIterator __last, _Tp*) {
typedef typename __type_traits<_Tp>::has_trivial_destructor _Trivial_destructor;
__destroy_aux(__first, __last, _Trivial_destructor());
}
template <class _ForwardIterator>
inline void _Destroy(_ForwardIterator __first, _ForwardIterator __last) {
__destroy(__first, __last, (typename iterator_traits< _ForwardIterator >::value_type*)0);
}
inline void _Destroy(char*, char*) {}
inline void _Destroy(wchar_t*, wchar_t*) {}
inline void _Destroy(const wchar_t*, const wchar_t*) {}
template <class _T1, class _T2>
inline void construct(_T1* __p, const _T2& __val) {_Construct(__p, __val); }
template <class _T1>
inline void construct(_T1* __p) { _Construct(__p); }
template <class _Tp>
inline void destroy(_Tp* __pointer) { _Destroy(__pointer); }
template <class _ForwardIterator>
inline void destroy(_ForwardIterator __first, _ForwardIterator __last) { _Destroy(__first, __last); }
}
namespace _STL {
typedef void (* __oom_handler_type)();
template <int __inst>
class __malloc_alloc {
private:
static void* _S_oom_malloc(size_t);
static __oom_handler_type __oom_handler;
public:
typedef char value_type;
static void* allocate(size_t __n) {
void* __result = malloc(__n);
if (0 == __result) __result = _S_oom_malloc(__n);
return __result;
}
static void deallocate(void* __p, size_t ) { free((char*)__p); }
static __oom_handler_type set_malloc_handler(__oom_handler_type __f) {
__oom_handler_type __old = __oom_handler;
__oom_handler = __f;
return(__old);
}
};
class __new_alloc {
public:
typedef char value_type;
static void* allocate(size_t __n) { return __stl_new(__n); }
static void deallocate(void* __p, size_t) { __stl_delete(__p); }
};
template <class _Alloc>
class __debug_alloc : public _Alloc {
public:
typedef _Alloc __allocator_type;
typedef typename _Alloc::value_type value_type;
private:
struct __alloc_header {
size_t __magic: 16;
size_t __type_size:16;
unsigned long _M_size;
};
enum { __pad=8, __magic=0xdeba, __deleted_magic = 0xdebd,
__shred_byte= 0xA3
};
enum { __extra_before = 16, __extra_after = 8 };
static size_t __extra_before_chunk() {
return (long)__extra_before/sizeof(value_type)+
(size_t)((long)__extra_before%sizeof(value_type)>0);
}
static size_t __extra_after_chunk() {
return (long)__extra_after/sizeof(value_type)+
(size_t)((long)__extra_after%sizeof(value_type)>0);
}
public:
__debug_alloc() {}
~__debug_alloc() {}
static void * allocate(size_t);
static void deallocate(void *, size_t);
};
enum {_ALIGN = 8, _ALIGN_SHIFT=3, _MAX_BYTES = 128};
class _Node_alloc_obj {
public:
_Node_alloc_obj * _M_free_list_link;
};
template <bool __threads, int __inst>
class __node_alloc {
public:
static inline size_t _S_round_up(size_t __bytes) { return (((__bytes) + (size_t)_ALIGN-1) & ~((size_t)_ALIGN - 1)); }
typedef _Node_alloc_obj _Obj;
private:
static void* _S_refill(size_t __n);
static char* _S_chunk_alloc(size_t __p_size, int& __nobjs);
static _Node_alloc_obj * _S_free_list[16];
static char* _S_start_free;
static char* _S_end_free;
static size_t _S_heap_size;
static void * _M_allocate(size_t __n);
static void _M_deallocate(void *__p, size_t __n);
public:
typedef char value_type;
static void * allocate(size_t __n) { return (__n > (size_t)_MAX_BYTES) ? __stl_new(__n) : _M_allocate(__n); }
static void deallocate(void *__p, size_t __n) { if (__n > (size_t)_MAX_BYTES) __stl_delete(__p); else _M_deallocate(__p, __n); }
};
typedef __node_alloc<true, 0> _Node_alloc;
typedef _Node_alloc __sgi_alloc;
typedef __node_alloc<false, 0> __single_client_alloc;
typedef __node_alloc<true, 0> __multithreaded_alloc;
template <class _Tp>
class allocator {
public:
typedef _Tp value_type;
typedef value_type * pointer;
typedef const _Tp* const_pointer;
typedef _Tp& reference;
typedef const _Tp& const_reference;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
template <class _Tp1> struct rebind {
typedef allocator<_Tp1> other;
};
allocator() {}
template <class _Tp1> allocator(const allocator<_Tp1>&) {}
allocator(const allocator<_Tp>&) {}
~allocator() {}
pointer address(reference __x) { return &__x; }
const_pointer address(const_reference __x) const { return &__x; }
_Tp* allocate(size_type __n, const void* = 0) const {
return __n != 0 ? reinterpret_cast<value_type*>(__sgi_alloc::allocate(__n * sizeof(value_type))) : 0;
}
void deallocate(pointer __p, size_type __n) const {
if (__p != 0) __sgi_alloc::deallocate((void*)__p, __n * sizeof(value_type));
}
void deallocate(pointer __p) const { if (__p != 0) __sgi_alloc::deallocate((void*)__p, sizeof(value_type)); }
size_type max_size() const { return size_t(-1) / sizeof(value_type); }
void construct(pointer __p, const _Tp& __val) const { _STL::_Construct(__p, __val); }
void destroy(pointer __p) const { _STL::_Destroy(__p); }
};
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 <class _Tp1> struct rebind {
typedef allocator<_Tp1> other;
};
};
template <class _T1, class _T2> inline bool operator==(const allocator<_T1>&, const allocator<_T2>&) { return true; }
template <class _T1, class _T2> inline bool operator!=(const allocator<_T1>&, const allocator<_T2>&) { return false; }
template <class _Tp, class _Allocator>
struct _Alloc_traits
{
typedef _Allocator _Orig;
typedef typename _Allocator:: rebind<_Tp> _Rebind_type;
typedef typename _Rebind_type::other allocator_type;
static allocator_type create_allocator(const _Orig& __a) { return allocator_type(__a); }
};
template <class _Tp, class _Alloc>
inline typename _Alloc_traits<_Tp, _Alloc>::allocator_type
__stl_alloc_create(const _Alloc& __a, const _Tp*) {
typedef typename _Alloc:: rebind<_Tp>::other _Rebound_type;
return _Rebound_type(__a);
}
template <class _Value, class _Tp, class _MaybeReboundAlloc>
class _STLP_alloc_proxy : public _MaybeReboundAlloc {
private:
typedef _MaybeReboundAlloc _Base;
typedef _STLP_alloc_proxy<_Value, _Tp, _MaybeReboundAlloc> _Self;
public:
_Value _M_data;
inline _STLP_alloc_proxy(const _MaybeReboundAlloc& __a, _Value __p) : _MaybeReboundAlloc(__a), _M_data(__p) {}
};
}
namespace _STL {
template <class _T1, class _T2>
struct pair {
typedef _T1 first_type;
typedef _T2 second_type;
_T1 first;
_T2 second;
pair() : first(_T1()), second(_T2()) {}
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) {}
pair(const pair<_T1,_T2>& __o) : first(__o.first), second(__o.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, int _Sz>
inline pair<_T1, _T2 const*> make_pair(_T1 const& __x,
_T2 const (&__y)[_Sz])
{
return pair<_T1, _T2 const*>(__x, static_cast<_T2 const*>(__y));
}
template <class _T1, class _T2, int _Sz>
inline pair<_T1 const*, _T2> make_pair(_T1 const (&__x)[_Sz],
_T2 const& __y)
{
return pair<_T1 const*, _T2>(static_cast<_T1 const*>(__x), __y);
}
template <class _T1, class _T2, int _Sz1, int _Sz2>
inline pair<_T1 const*, _T2 const*> make_pair(_T1 const (&__x)[_Sz1],
_T2 const (&__y)[_Sz2])
{
return pair<_T1 const*, _T2 const*>(static_cast<_T1 const*>(__x),
static_cast<_T2 const*>(__y));
}
template <class _T1, class _T2>
inline pair<_T1, _T2> make_pair(const _T1& __x, const _T2& __y)
{
return pair<_T1, _T2>(__x, __y);
}
}
namespace _STL { 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 _STL {
template <class _Tp>
inline void swap(_Tp& __a, _Tp& __b) {
_Tp __tmp = __a;
__a = __b;
__b = __tmp;
}
template <class _ForwardIter1, class _ForwardIter2>
inline void iter_swap(_ForwardIter1 __i1, _ForwardIter2 __i2) {
swap(*__i1, *__i2);
}
template <class _Tp>
inline const _Tp& (min)(const _Tp& __a, const _Tp& __b) { return __b < __a ? __b : __a; }
template <class _Tp>
inline const _Tp& (max)(const _Tp& __a, const _Tp& __b) { return __a < __b ? __b : __a; }
template <class _Tp, class _Compare>
inline const _Tp& (min)(const _Tp& __a, const _Tp& __b, _Compare __comp) {
return __comp(__b, __a) ? __b : __a;
}
template <class _Tp, class _Compare>
inline const _Tp& (max)(const _Tp& __a, const _Tp& __b, _Compare __comp) {
return __comp(__a, __b) ? __b : __a;
}
template <class _InputIter, class _OutputIter, class _Distance>
inline _OutputIter __copy(_InputIter __first, _InputIter __last,
_OutputIter __result,
const input_iterator_tag &, _Distance*) {
for ( ; __first != __last; ++__result, ++__first)
*__result = *__first;
return __result;
}
template <class _RandomAccessIter, class _OutputIter, class _Distance>
inline _OutputIter
__copy(_RandomAccessIter __first, _RandomAccessIter __last,
_OutputIter __result, const random_access_iterator_tag &, _Distance*) {
for (_Distance __n = __last - __first; __n > 0; --__n) {
*__result = *__first;
++__first;
++__result;
}
return __result;
}
inline void*
__copy_trivial(const void* __first, const void* __last, void* __result) {
return (__last == __first) ? __result :
((char*)memmove(__result, __first, ((const char*)__last - (const char*)__first))) +
((const char*)__last - (const char*)__first);
}
template <class _BidirectionalIter1, class _BidirectionalIter2,
class _Distance>
inline _BidirectionalIter2 __copy_backward(_BidirectionalIter1 __first,
_BidirectionalIter1 __last,
_BidirectionalIter2 __result,
const bidirectional_iterator_tag &,
_Distance*)
{
while (__first != __last)
*--__result = *--__last;
return __result;
}
template <class _RandomAccessIter, class _BidirectionalIter, class _Distance>
inline _BidirectionalIter __copy_backward(_RandomAccessIter __first,
_RandomAccessIter __last,
_BidirectionalIter __result,
const random_access_iterator_tag &,
_Distance*)
{
for (_Distance __n = __last - __first; __n > 0; --__n)
*--__result = *--__last;
return __result;
}
inline void*
__copy_trivial_backward(const void* __first, const void* __last, void* __result) {
const ptrdiff_t _Num = (const char*)__last - (const char*)__first;
return (_Num > 0) ? memmove((char*)__result - _Num, __first, _Num) : __result ;
}
template <class _InputIter, class _OutputIter>
inline _OutputIter __copy_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result, const __false_type&) {
return __copy(__first, __last, __result,
typename iterator_traits< _InputIter >::iterator_category(),
(typename iterator_traits< _InputIter >::difference_type*)0);
}
template <class _InputIter, class _OutputIter>
inline _OutputIter __copy_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result, const __true_type&) {
return (_OutputIter)__copy_trivial(__first, __last, __result);
}
template <class _InputIter, class _OutputIter>
inline _OutputIter __copy_aux(_InputIter __first, _InputIter __last, _OutputIter __result, const __true_type&) {
return __copy_ptrs(__first, __last, __result,
_IsOKToMemCpy((typename iterator_traits< _InputIter >::value_type*)0,
(typename iterator_traits< _OutputIter >::value_type*)0)._Ret());
}
template <class _InputIter, class _OutputIter>
inline _OutputIter __copy_aux(_InputIter __first, _InputIter __last, _OutputIter __result, const __false_type&) {
return __copy(__first, __last, __result,
typename iterator_traits< _InputIter >::iterator_category(), (typename iterator_traits< _InputIter >::difference_type*)0);
}
template <class _InputIter, class _OutputIter>
inline _OutputIter copy(_InputIter __first, _InputIter __last, _OutputIter __result) {
return __copy_aux(__first, __last, __result, _BothPtrType< _InputIter, _OutputIter> :: _Ret());
}
template <class _InputIter, class _OutputIter>
inline _OutputIter __copy_backward_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result, const __false_type&) {
return __copy_backward(__first, __last, __result, typename iterator_traits< _InputIter >::iterator_category(), (typename iterator_traits< _InputIter >::difference_type*)0);
}
template <class _InputIter, class _OutputIter>
inline _OutputIter __copy_backward_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result, const __true_type&) {
return (_OutputIter)__copy_trivial_backward(__first, __last, __result);
}
template <class _InputIter, class _OutputIter>
inline _OutputIter __copy_backward_aux(_InputIter __first, _InputIter __last, _OutputIter __result, const __false_type&) {
return __copy_backward(__first, __last, __result, typename iterator_traits< _InputIter >::iterator_category(), (typename iterator_traits< _InputIter >::difference_type*)0);
}
template <class _InputIter, class _OutputIter>
inline _OutputIter __copy_backward_aux(_InputIter __first, _InputIter __last, _OutputIter __result, const __true_type&) {
return __copy_backward_ptrs(__first, __last, __result,
_IsOKToMemCpy((typename iterator_traits< _InputIter >::value_type*)0,
(typename iterator_traits< _OutputIter >::value_type*)0)._Ret());
}
template <class _InputIter, class _OutputIter>
inline _OutputIter copy_backward(_InputIter __first, _InputIter __last, _OutputIter __result) {
return __copy_backward_aux(__first, __last, __result, _BothPtrType< _InputIter, _OutputIter> :: _Ret() );
}
template <class _InputIter, class _Size, class _OutputIter>
inline
pair<_InputIter, _OutputIter> __copy_n(_InputIter __first, _Size __count,
_OutputIter __result,
const input_iterator_tag &) {
for ( ; __count > 0; --__count) {
*__result = *__first;
++__first;
++__result;
}
return pair<_InputIter, _OutputIter>(__first, __result);
}
template <class _RAIter, class _Size, class _OutputIter>
inline pair<_RAIter, _OutputIter>
__copy_n(_RAIter __first, _Size __count,
_OutputIter __result,
const random_access_iterator_tag &) {
_RAIter __last = __first + __count;
return pair<_RAIter, _OutputIter>(__last, copy(__first, __last, __result));
}
template <class _InputIter, class _Size, class _OutputIter>
inline pair<_InputIter, _OutputIter>
__copy_n(_InputIter __first, _Size __count, _OutputIter __result) {
return __copy_n(__first, __count, __result, typename iterator_traits< _InputIter >::iterator_category());
}
template <class _InputIter, class _Size, class _OutputIter>
inline pair<_InputIter, _OutputIter>
copy_n(_InputIter __first, _Size __count, _OutputIter __result) {
return __copy_n(__first, __count, __result, typename iterator_traits< _InputIter >::iterator_category());
}
template <class _ForwardIter, class _Tp>
inline
void fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __val) {
for ( ; __first != __last; ++__first)
*__first = __val;
}
template <class _OutputIter, class _Size, class _Tp>
inline
_OutputIter fill_n(_OutputIter __first, _Size __n, const _Tp& __val) {
for ( ; __n > 0; --__n, ++__first)
*__first = __val;
return __first;
}
inline void fill(unsigned char* __first, unsigned char* __last,
const unsigned char& __val) {
unsigned char __tmp = __val;
memset(__first, __tmp, __last - __first);
}
inline void fill(signed char* __first, signed char* __last,
const signed char& __val) {
signed char __tmp = __val;
memset(__first, static_cast<unsigned char>(__tmp), __last - __first);
}
inline void fill(char* __first, char* __last, const char& __val) {
char __tmp = __val;
memset(__first, static_cast<unsigned char>(__tmp), __last - __first);
}
template <class _Size>
inline unsigned char* fill_n(unsigned char* __first, _Size __n,
const unsigned char& __val) {
fill(__first, __first + __n, __val);
return __first + __n;
}
template <class _Size>
inline signed char* fill_n(char* __first, _Size __n,
const signed char& __val) {
fill(__first, __first + __n, __val);
return __first + __n;
}
template <class _Size>
inline char* fill_n(char* __first, _Size __n, const char& __val) {
fill(__first, __first + __n, __val);
return __first + __n;
}
template <class _InputIter1, class _InputIter2>
inline
pair<_InputIter1, _InputIter2> mismatch(_InputIter1 __first1,
_InputIter1 __last1,
_InputIter2 __first2) {
while (__first1 != __last1 && *__first1 == *__first2) {
++__first1;
++__first2;
}
return pair<_InputIter1, _InputIter2>(__first1, __first2);
}
template <class _InputIter1, class _InputIter2, class _BinaryPredicate>
inline
pair<_InputIter1, _InputIter2> mismatch(_InputIter1 __first1,
_InputIter1 __last1,
_InputIter2 __first2,
_BinaryPredicate __binary_pred) {
while (__first1 != __last1 && __binary_pred(*__first1, *__first2)) {
++__first1;
++__first2;
}
return pair<_InputIter1, _InputIter2>(__first1, __first2);
}
template <class _InputIter1, class _InputIter2>
inline
bool equal(_InputIter1 __first1, _InputIter1 __last1,
_InputIter2 __first2) {
for ( ; __first1 != __last1; ++__first1, ++__first2)
if (!(*__first1 == *__first2))
return false;
return true;
}
template <class _InputIter1, class _InputIter2, class _BinaryPredicate>
inline
bool equal(_InputIter1 __first1, _InputIter1 __last1,
_InputIter2 __first2, _BinaryPredicate __binary_pred) {
for ( ; __first1 != __last1; ++__first1, ++__first2)
if (!__binary_pred(*__first1, *__first2))
return false;
return true;
}
template <class _InputIter1, class _InputIter2>
bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1,
_InputIter2 __first2, _InputIter2 __last2);
template <class _InputIter1, class _InputIter2, class _Compare>
bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1,
_InputIter2 __first2, _InputIter2 __last2,
_Compare __comp);
inline bool
lexicographical_compare(const unsigned char* __first1,
const unsigned char* __last1,
const unsigned char* __first2,
const unsigned char* __last2)
{
const size_t __len1 = __last1 - __first1;
const size_t __len2 = __last2 - __first2;
const int __result = memcmp(__first1, __first2, (min) (__len1, __len2));
return __result != 0 ? (__result < 0) : (__len1 < __len2);
}
template <class _InputIter1, class _InputIter2>
int __lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,
_InputIter2 __first2, _InputIter2 __last2);
inline int
__lexicographical_compare_3way(const unsigned char* __first1,
const unsigned char* __last1,
const unsigned char* __first2,
const unsigned char* __last2)
{
const ptrdiff_t __len1 = __last1 - __first1;
const ptrdiff_t __len2 = __last2 - __first2;
const int __result = memcmp(__first1, __first2, (min) (__len1, __len2));
return __result != 0 ? __result
: (__len1 == __len2 ? 0 : (__len1 < __len2 ? -1 : 1));
}
template <class _InputIter1, class _InputIter2>
int lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,
_InputIter2 __first2, _InputIter2 __last2);
template <class _InputIter, class _Tp>
inline typename iterator_traits<_InputIter>::difference_type
count(_InputIter __first, _InputIter __last, const _Tp& __val) {
typename iterator_traits<_InputIter>::difference_type __n = 0;
for ( ; __first != __last; ++__first)
if (*__first == __val)
++__n;
return __n;
}
template <class _InputIter, class _Tp>
_InputIter find(_InputIter __first, _InputIter __last, const _Tp& __val);
template <class _InputIter, class _Predicate>
_InputIter find_if(_InputIter __first, _InputIter __last, _Predicate __pred);
template <class _ForwardIter1, class _ForwardIter2, class _BinaryPred>
_ForwardIter1 search(_ForwardIter1 __first1, _ForwardIter1 __last1,
_ForwardIter2 __first2, _ForwardIter2 __last2, _BinaryPred __predicate);
template <class _InputIter, class _ForwardIter, class _BinaryPredicate>
_InputIter __find_first_of(_InputIter __first1, _InputIter __last1,
_ForwardIter __first2, _ForwardIter __last2,
_BinaryPredicate __comp);
template <class _ForwardIter1, class _ForwardIter2,
class _BinaryPredicate>
_ForwardIter1
find_end(_ForwardIter1 __first1, _ForwardIter1 __last1,
_ForwardIter2 __first2, _ForwardIter2 __last2,
_BinaryPredicate __comp);
template <class _ForwardIter, class _Tp>
inline void
replace(_ForwardIter __first, _ForwardIter __last,
const _Tp& __old_value, const _Tp& __new_value) {
for ( ; __first != __last; ++__first)
if (*__first == __old_value)
*__first = __new_value;
}
template <class _ForwardIter, class _Tp, class _Compare, class _Distance>
_ForwardIter __lower_bound(_ForwardIter __first, _ForwardIter __last,
const _Tp& __val, _Compare __comp, _Distance*);
}
namespace _STL {
template <class _InputIter1, class _InputIter2>
bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1,
_InputIter2 __first2, _InputIter2 __last2) {
for ( ; __first1 != __last1 && __first2 != __last2
; ++__first1, ++__first2) {
if (*__first1 < *__first2)
return true;
if (*__first2 < *__first1)
return false;
}
return __first1 == __last1 && __first2 != __last2;
}
template <class _InputIter1, class _InputIter2, class _Compare>
bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1,
_InputIter2 __first2, _InputIter2 __last2,
_Compare __comp) {
for ( ; __first1 != __last1 && __first2 != __last2
; ++__first1, ++__first2) {
if (__comp(*__first1, *__first2))
return true;
if (__comp(*__first2, *__first1))
return false;
}
return __first1 == __last1 && __first2 != __last2;
}
template <class _InputIter1, class _InputIter2>
int __lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,
_InputIter2 __first2, _InputIter2 __last2)
{
while (__first1 != __last1 && __first2 != __last2) {
if (*__first1 < *__first2)
return -1;
if (*__first2 < *__first1)
return 1;
++__first1;
++__first2;
}
if (__first2 == __last2) {
return !(__first1 == __last1);
}
else {
return -1;
}
}
template <class _InputIter1, class _InputIter2>
int lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,
_InputIter2 __first2, _InputIter2 __last2)
{
return __lexicographical_compare_3way(__first1, __last1, __first2, __last2);
}
template <class _RandomAccessIter, class _Tp>
inline _RandomAccessIter __find(_RandomAccessIter __first, _RandomAccessIter __last,
const _Tp& __val,
const random_access_iterator_tag &)
{
typename iterator_traits<_RandomAccessIter>::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 <class _RandomAccessIter, class _Predicate>
inline _RandomAccessIter __find_if(_RandomAccessIter __first, _RandomAccessIter __last,
_Predicate __pred,
const random_access_iterator_tag &)
{
typename iterator_traits<_RandomAccessIter>::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;
case 0:
default:
return __last;
}
}
template <class _InputIter, class _Tp>
inline _InputIter __find(_InputIter __first, _InputIter __last,
const _Tp& __val,
const input_iterator_tag &)
{
while (__first != __last && !(*__first == __val))
++__first;
return __first;
}
template <class _InputIter, class _Predicate>
inline _InputIter __find_if(_InputIter __first, _InputIter __last,
_Predicate __pred,
const input_iterator_tag &)
{
while (__first != __last && !__pred(*__first))
++__first;
return __first;
}
template <class _InputIter, class _Predicate>
_InputIter find_if(_InputIter __first, _InputIter __last,
_Predicate __pred) {
return __find_if(__first, __last, __pred, typename iterator_traits< _InputIter >::iterator_category());
}
template <class _InputIter, class _Tp>
_InputIter find(_InputIter __first, _InputIter __last, const _Tp& __val)
{
return __find(__first, __last, __val, typename iterator_traits< _InputIter >::iterator_category());
}
template <class _ForwardIter1, class _ForwardIter2, class _BinaryPred>
_ForwardIter1 search(_ForwardIter1 __first1, _ForwardIter1 __last1,
_ForwardIter2 __first2, _ForwardIter2 __last2,
_BinaryPred __predicate)
{
if (__first1 == __last1 || __first2 == __last2)
return __first1;
_ForwardIter2 __tmp(__first2);
++__tmp;
if (__tmp == __last2) {
while (__first1 != __last1 && !__predicate(*__first1, *__first2))
++__first1;
return __first1;
}
_ForwardIter2 __p1, __p;
__p1 = __first2; ++__p1;
while (__first1 != __last1) {
while (__first1 != __last1) {
if (__predicate(*__first1, *__first2))
break;
++__first1;
}
while (__first1 != __last1 && !__predicate(*__first1, *__first2))
++__first1;
if (__first1 == __last1)
return __last1;
__p = __p1;
_ForwardIter1 __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 <class _InputIter, class _ForwardIter, class _BinaryPredicate>
_InputIter __find_first_of(_InputIter __first1, _InputIter __last1,
_ForwardIter __first2, _ForwardIter __last2,
_BinaryPredicate __comp) {
for ( ; __first1 != __last1; ++__first1)
for (_ForwardIter __iter = __first2; __iter != __last2; ++__iter)
if (__comp(*__first1, *__iter))
return __first1;
return __last1;
}
template <class _ForwardIter1, class _ForwardIter2,
class _BinaryPredicate>
_ForwardIter1 __find_end(_ForwardIter1 __first1, _ForwardIter1 __last1,
_ForwardIter2 __first2, _ForwardIter2 __last2,
const forward_iterator_tag &, const forward_iterator_tag &,
_BinaryPredicate __comp)
{
if (__first2 == __last2)
return __last1;
else {
_ForwardIter1 __result = __last1;
while (1) {
_ForwardIter1 __new_result
= search(__first1, __last1, __first2, __last2, __comp);
if (__new_result == __last1)
return __result;
else {
__result = __new_result;
__first1 = __new_result;
++__first1;
}
}
}
}
}
namespace _STL {
template <class _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 reverse_iterator<_Iterator> _Self;
public:
typedef typename iterator_traits<_Iterator>::iterator_category iterator_category;
typedef typename iterator_traits<_Iterator>::value_type value_type;
typedef typename iterator_traits<_Iterator>::difference_type difference_type;
typedef typename iterator_traits<_Iterator>::pointer pointer;
typedef typename iterator_traits<_Iterator>::reference reference;
typedef _Iterator iterator_type;
public:
reverse_iterator() {}
explicit reverse_iterator(iterator_type __x) : current(__x) {}
reverse_iterator(const _Self& __x) : current(__x.current) {}
_Self& operator = (const _Self& __x) { current = __x.base(); return *this; }
template <class _Iter>
reverse_iterator(const reverse_iterator<_Iter>& __x) : current(__x.base()) {}
template <class _Iter>
_Self& operator = (const reverse_iterator<_Iter>& __x) { current = __x.base(); return *this; }
iterator_type base() const { return current; }
reference operator*() const {
_Iterator __tmp = current;
return *--__tmp;
}
pointer operator->() const { return &(operator*()); }
_Self& operator++() {
--current;
return *this;
}
_Self operator++(int) {
_Self __tmp = *this;
--current;
return __tmp;
}
_Self& operator--() {
++current;
return *this;
}
_Self operator--(int) {
_Self __tmp = *this;
++current;
return __tmp;
}
_Self operator+(difference_type __n) const {
return _Self(current - __n);
}
_Self& operator+=(difference_type __n) {
current -= __n;
return *this;
}
_Self operator-(difference_type __n) const {
return _Self(current + __n);
}
_Self& operator-=(difference_type __n) {
current += __n;
return *this;
}
reference operator[](difference_type __n) const { return *(*this + __n); }
};
template <class _Iterator>
inline bool operator==(const reverse_iterator<_Iterator>& __x,
const reverse_iterator<_Iterator>& __y) {
return __x.base() == __y.base();
}
template <class _Iterator>
inline bool operator<(const reverse_iterator<_Iterator>& __x,
const reverse_iterator<_Iterator>& __y) {
return __y.base() < __x.base();
}
template <class _Iterator>
inline bool operator!=(const reverse_iterator<_Iterator>& __x,
const reverse_iterator<_Iterator>& __y) {
return !(__x == __y);
}
template <class _Iterator>
inline bool operator>(const reverse_iterator<_Iterator>& __x,
const reverse_iterator<_Iterator>& __y) {
return __y < __x;
}
template <class _Iterator>
inline bool operator<=(const reverse_iterator<_Iterator>& __x,
const reverse_iterator<_Iterator>& __y) {
return !(__y < __x);
}
template <class _Iterator>
inline bool operator>=(const reverse_iterator<_Iterator>& __x,
const reverse_iterator<_Iterator>& __y) {
return !(__x < __y);
}
template <class _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 <class _Iterator, class _DifferenceType>
inline reverse_iterator<_Iterator>
operator+(_DifferenceType n,const reverse_iterator<_Iterator>& x) {
return x.operator+(n);
}
template <class _Container>
class back_insert_iterator
: public iterator<output_iterator_tag,void,void,void,void>
{
protected:
_Container* container;
public:
typedef _Container container_type;
typedef output_iterator_tag iterator_category;
explicit back_insert_iterator(_Container& __x) : container(&__x) {}
back_insert_iterator<_Container>&
operator=(const typename _Container::value_type& __val) {
container->push_back(__val);
return *this;
}
back_insert_iterator<_Container>& operator*() { return *this; }
back_insert_iterator<_Container>& operator++() { return *this; }
back_insert_iterator<_Container>& operator++(int) { return *this; }
};
template <class _Container>
inline back_insert_iterator<_Container> back_inserter(_Container& __x) {
return back_insert_iterator<_Container>(__x);
}
template <class _Container>
class front_insert_iterator
: public iterator<output_iterator_tag,void,void,void,void>
{
protected:
_Container* container;
public:
typedef _Container container_type;
typedef output_iterator_tag iterator_category;
explicit front_insert_iterator(_Container& __x) : container(&__x) {}
front_insert_iterator<_Container>&
operator=(const typename _Container::value_type& __val) {
container->push_front(__val);
return *this;
}
front_insert_iterator<_Container>& operator*() { return *this; }
front_insert_iterator<_Container>& operator++() { return *this; }
front_insert_iterator<_Container>& operator++(int) { return *this; }
};
template <class _Container>
inline front_insert_iterator<_Container> front_inserter(_Container& __x) {
return front_insert_iterator<_Container>(__x);
}
template <class _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;
typedef output_iterator_tag iterator_category;
insert_iterator(_Container& __x, typename _Container::iterator __i)
: container(&__x), iter(__i) {}
insert_iterator<_Container>&
operator=(const typename _Container::value_type& __val) {
iter = container->insert(iter, __val);
++iter;
return *this;
}
insert_iterator<_Container>& operator*() { return *this; }
insert_iterator<_Container>& operator++() { return *this; }
insert_iterator<_Container>& operator++(int) { return *this; }
};
template <class _Container, class _Iterator>
inline insert_iterator<_Container>
inserter(_Container& __x, _Iterator __i)
{
typedef typename _Container::iterator __iter;
return insert_iterator<_Container>(__x, __iter(__i));
}
}
namespace _STL {
template <class _BidirectionalIter1, class _BidirectionalIter2,
class _BinaryPredicate>
_BidirectionalIter1
__find_end(_BidirectionalIter1 __first1, _BidirectionalIter1 __last1,
_BidirectionalIter2 __first2, _BidirectionalIter2 __last2,
const bidirectional_iterator_tag &, const bidirectional_iterator_tag &,
_BinaryPredicate __comp)
{
typedef reverse_iterator<_BidirectionalIter1> _RevIter1;
typedef reverse_iterator<_BidirectionalIter2> _RevIter2;
_RevIter1 __rlast1(__first1);
_RevIter2 __rlast2(__first2);
_RevIter1 __rresult = search(_RevIter1(__last1), __rlast1,
_RevIter2(__last2), __rlast2,
__comp);
if (__rresult == __rlast1)
return __last1;
else {
_BidirectionalIter1 __result = __rresult.base();
advance(__result, -distance(__first2, __last2));
return __result;
}
}
template <class _ForwardIter1, class _ForwardIter2,
class _BinaryPredicate>
_ForwardIter1
find_end(_ForwardIter1 __first1, _ForwardIter1 __last1,
_ForwardIter2 __first2, _ForwardIter2 __last2,
_BinaryPredicate __comp)
{
return __find_end(__first1, __last1, __first2, __last2,
typename iterator_traits< _ForwardIter1 >::iterator_category(),
typename iterator_traits< _ForwardIter2 >::iterator_category(),
__comp);
}
template <class _ForwardIter, class _Tp, class _Compare, class _Distance>
_ForwardIter __lower_bound(_ForwardIter __first, _ForwardIter __last,
const _Tp& __val, _Compare __comp, _Distance*)
{
_Distance __len = distance(__first, __last);
_Distance __half;
_ForwardIter __middle;
while (__len > 0) {
__half = __len >> 1;
__middle = __first;
advance(__middle, __half);
if (__comp(*__middle, __val)) {
__first = __middle;
++__first;
__len = __len - __half - 1;
}
else
__len = __half;
}
return __first;
}
}
namespace _STL {
template <class _InputIter, class _ForwardIter>
inline _ForwardIter
__uninitialized_copy(_InputIter __first, _InputIter __last, _ForwardIter __result,
const __true_type&) {
return __copy_aux(__first, __last, __result, _BothPtrType< _InputIter, _ForwardIter> :: _Ret());
}
template <class _InputIter, class _ForwardIter>
inline
_ForwardIter
__uninitialized_copy(_InputIter __first, _InputIter __last, _ForwardIter __result,
const __false_type&)
{
_ForwardIter __cur = __result;
try {
for ( ; __first != __last; ++__first, ++__cur)
_Construct(&*__cur, *__first);
return __cur;
}
catch(...) { _Destroy(__result, __cur); throw; };
}
template <class _InputIter, class _ForwardIter>
inline _ForwardIter
uninitialized_copy(_InputIter __first, _InputIter __last, _ForwardIter __result) {
return __uninitialized_copy(__first, __last, __result, typename __type_traits< typename iterator_traits< _ForwardIter >::value_type >::is_POD_type());
}
inline char*
uninitialized_copy(const char* __first, const char* __last, char* __result) {
return (char*)__copy_trivial (__first, __last, __result);
}
inline wchar_t*
uninitialized_copy(const wchar_t* __first, const wchar_t* __last, wchar_t* __result) {
return (wchar_t*)__copy_trivial (__first, __last, __result);
}
template <class _InputIter, class _Size, class _ForwardIter>
inline
pair<_InputIter, _ForwardIter>
__uninitialized_copy_n(_InputIter __first, _Size __count,
_ForwardIter __result,
const input_iterator_tag &)
{
_ForwardIter __cur = __result;
try {
for ( ; __count > 0 ; --__count, ++__first, ++__cur)
_Construct(&*__cur, *__first);
return pair<_InputIter, _ForwardIter>(__first, __cur);
}
catch(...) { _Destroy(__result, __cur); throw; };
}
template <class _RandomAccessIter, class _Size, class _ForwardIter>
inline pair<_RandomAccessIter, _ForwardIter>
__uninitialized_copy_n(_RandomAccessIter __first, _Size __count, _ForwardIter __result, const random_access_iterator_tag &) {
_RandomAccessIter __last = __first + __count;
return pair<_RandomAccessIter, _ForwardIter>( __last, __uninitialized_copy(__first, __last, __result,
typename __type_traits< typename iterator_traits< _ForwardIter >::value_type >::is_POD_type()));
}
template <class _InputIter, class _Size, class _ForwardIter>
inline pair<_InputIter, _ForwardIter>
uninitialized_copy_n(_InputIter __first, _Size __count,
_ForwardIter __result) {
return __uninitialized_copy_n(__first, __count, __result, typename iterator_traits< _InputIter >::iterator_category());
}
template <class _ForwardIter, class _Tp>
inline void
__uninitialized_fill(_ForwardIter __first, _ForwardIter __last,
const _Tp& __x, const __true_type&) {
_STL::fill(__first, __last, __x);
}
template <class _ForwardIter, class _Tp>
inline void
__uninitialized_fill(_ForwardIter __first, _ForwardIter __last,
const _Tp& __x, const __false_type&)
{
_ForwardIter __cur = __first;
try {
for ( ; __cur != __last; ++__cur)
_Construct(&*__cur, __x);
}
catch(...) { _Destroy(__first, __cur); throw; };
}
template <class _ForwardIter, class _Tp>
inline void uninitialized_fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __x) {
__uninitialized_fill(__first, __last, __x, typename __type_traits< typename iterator_traits< _ForwardIter >::value_type >::is_POD_type());
}
template <class _ForwardIter, class _Size, class _Tp>
inline _ForwardIter
__uninitialized_fill_n(_ForwardIter __first, _Size __n,
const _Tp& __x, const __true_type&) {
return _STL::fill_n(__first, __n, __x);
}
template <class _ForwardIter, class _Size, class _Tp>
inline _ForwardIter
__uninitialized_fill_n(_ForwardIter __first, _Size __n,
const _Tp& __x, const __false_type&)
{
_ForwardIter __cur = __first;
try {
for ( ; __n > 0; --__n, ++__cur)
_Construct(&*__cur, __x);
return __cur;
}
catch(...) { _Destroy(__first, __cur); throw; };
}
template <class _ForwardIter, class _Size, class _Tp>
inline _ForwardIter
uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp& __x) {
return __uninitialized_fill_n(__first, __n, __x, typename __type_traits< typename iterator_traits< _ForwardIter >::value_type >::is_POD_type());
}
template <class _InputIter1, class _InputIter2, class _ForwardIter>
inline _ForwardIter
__uninitialized_copy_copy(_InputIter1 __first1, _InputIter1 __last1,
_InputIter2 __first2, _InputIter2 __last2,
_ForwardIter __result, __true_type)
{
return __uninitialized_copy(__first2, __last2,
__uninitialized_copy(__first1, __last1, __result, __true_type()), __true_type());
}
template <class _InputIter1, class _InputIter2, class _ForwardIter>
inline _ForwardIter
__uninitialized_copy_copy(_InputIter1 __first1, _InputIter1 __last1,
_InputIter2 __first2, _InputIter2 __last2,
_ForwardIter __result, __false_type)
{
_ForwardIter __mid = __uninitialized_copy(__first1, __last1, __result, typename __type_traits< typename iterator_traits< _ForwardIter >::value_type >::is_POD_type());
try {
return __uninitialized_copy(__first2, __last2, __mid , typename __type_traits< typename iterator_traits< _ForwardIter >::value_type >::is_POD_type());
}
catch(...) { _Destroy(__result, __mid); throw; };
}
template <class _ForwardIter, class _Tp, class _InputIter>
inline _ForwardIter
__uninitialized_fill_copy(_ForwardIter __result, _ForwardIter __mid, const _Tp& __x,
_InputIter __first, _InputIter __last)
{
typedef typename __type_traits<_Tp>::is_POD_type _I_POD;
__uninitialized_fill(__result, __mid, __x, _I_POD());
try {
return __uninitialized_copy(__first, __last, __mid, _I_POD());
}
catch(...) { _Destroy(__result, __mid); throw; };
}
template <class _InputIter, class _ForwardIter, class _Tp>
inline void
__uninitialized_copy_fill(_InputIter __first1, _InputIter __last1,
_ForwardIter __first2, _ForwardIter __last2,
const _Tp& __x)
{
typedef typename __type_traits<_Tp>::is_POD_type _I_POD;
_ForwardIter __mid2 = __uninitialized_copy(__first1, __last1, __first2, _I_POD());
try {
__uninitialized_fill(__mid2, __last2, __x, _I_POD());
}
catch(...) { _Destroy(__first2, __mid2); throw; };
}
}
namespace _STL {
template <class _Tp>
pair<_Tp*, ptrdiff_t>
__get_temporary_buffer(ptrdiff_t __len, _Tp*);
template <class _Tp>
inline pair<_Tp*, ptrdiff_t> get_temporary_buffer(ptrdiff_t __len) {
return __get_temporary_buffer(__len, (_Tp*) 0);
}
template <class _Tp>
inline pair<_Tp*, ptrdiff_t>
get_temporary_buffer(ptrdiff_t __len, _Tp*) {
return __get_temporary_buffer(__len, (_Tp*) 0);
}
template <class _Tp>
inline void return_temporary_buffer(_Tp* __p) {
free((char*)__p);
}
template <class _ForwardIterator, class _Tp>
class _Temporary_buffer {
private:
ptrdiff_t _M_original_len;
ptrdiff_t _M_len;
_Tp* _M_buffer;
void _M_allocate_buffer() {
_M_original_len = _M_len;
_M_buffer = 0;
if (_M_len > (ptrdiff_t)(2147483647 / sizeof(_Tp)))
_M_len = 2147483647 / sizeof(_Tp);
while (_M_len > 0) {
_M_buffer = (_Tp*) malloc(_M_len * sizeof(_Tp));
if (_M_buffer)
break;
_M_len /= 2;
}
}
void _M_initialize_buffer(const _Tp&, const __true_type&) {}
void _M_initialize_buffer(const _Tp& val, const __false_type&) {
uninitialized_fill_n(_M_buffer, _M_len, val);
}
public:
ptrdiff_t size() const { return _M_len; }
ptrdiff_t requested_size() const { return _M_original_len; }
_Tp* begin() { return _M_buffer; }
_Tp* end() { return _M_buffer + _M_len; }
_Temporary_buffer(_ForwardIterator __first, _ForwardIterator __last) {
typedef typename __type_traits<_Tp>::has_trivial_default_constructor _Trivial;
try {
_M_len = distance(__first, __last);
_M_allocate_buffer();
if (_M_len > 0)
_M_initialize_buffer(*__first, _Trivial());
}
catch(...) { free(_M_buffer); _M_buffer = 0; _M_len = 0; throw; };
}
~_Temporary_buffer() {
_Destroy(_M_buffer, _M_buffer + _M_len);
free(_M_buffer);
}
private:
_Temporary_buffer(const _Temporary_buffer<_ForwardIterator, _Tp>&) {}
void operator=(const _Temporary_buffer<_ForwardIterator, _Tp>&) {}
};
template <class _ForwardIterator,
class _Tp
= typename iterator_traits<_ForwardIterator>::value_type
>
struct temporary_buffer : public _Temporary_buffer<_ForwardIterator, _Tp>
{
temporary_buffer(_ForwardIterator __first, _ForwardIterator __last)
: _Temporary_buffer<_ForwardIterator, _Tp>(__first, __last) {}
~temporary_buffer() {}
};
}
namespace _STL {
template <class _Tp>
pair<_Tp*, ptrdiff_t>
__get_temporary_buffer(ptrdiff_t __len, _Tp*)
{
if (__len > ptrdiff_t(2147483647 / sizeof(_Tp)))
__len = 2147483647 / sizeof(_Tp);
while (__len > 0) {
_Tp* __tmp = (_Tp*) malloc((size_t)__len * sizeof(_Tp));
if (__tmp != 0)
return pair<_Tp*, ptrdiff_t>(__tmp, __len);
__len /= 2;
}
return pair<_Tp*, ptrdiff_t>((_Tp*)0, 0);
}
}
namespace _STL {
template <class _ForwardIterator, class _Tp>
class raw_storage_iterator
{
protected:
_ForwardIterator _M_iter;
public:
typedef output_iterator_tag iterator_category;
typedef void value_type;
typedef void difference_type;
typedef void pointer;
typedef void reference;
explicit raw_storage_iterator(_ForwardIterator __x) : _M_iter(__x) {}
raw_storage_iterator<_ForwardIterator, _Tp>& operator*() { return *this; }
raw_storage_iterator<_ForwardIterator, _Tp>& operator=(const _Tp& __element) {
_Construct(&*_M_iter, __element);
return *this;
}
raw_storage_iterator<_ForwardIterator, _Tp>& operator++() {
++_M_iter;
return *this;
}
raw_storage_iterator<_ForwardIterator, _Tp> operator++(int) {
raw_storage_iterator<_ForwardIterator, _Tp> __tmp = *this;
++_M_iter;
return __tmp;
}
};
}
namespace _STL {
class __ptr_base {
public:
void* _M_p;
void __set(const void* p) { _M_p = const_cast<void*>(p); }
void __set(void* p) { _M_p = p; }
};
template <class _Tp> class auto_ptr_ref {
public:
__ptr_base& _M_r;
_Tp* const _M_p;
auto_ptr_ref(__ptr_base& __r, _Tp* __p) : _M_r(__r), _M_p(__p) { }
_Tp* release() const { _M_r.__set((void*)0); return _M_p; }
};
template<class _Tp> class auto_ptr : public __ptr_base {
public:
typedef _Tp element_type;
typedef auto_ptr<_Tp> _Self;
_Tp* release() {
_Tp* __px = this->get();
this->_M_p = 0;
return __px;
}
void reset(_Tp* __px=0) {
_Tp* __pt = this->get();
if (__px != __pt)
delete __pt;
this->__set(__px);
}
_Tp* get() const { return reinterpret_cast<_Tp*>(const_cast<void*>(_M_p)); }
_Tp* operator->() const {
return get();
}
_Tp& operator*() const {
return *get();
}
auto_ptr() { this->_M_p = 0; }
explicit auto_ptr(_Tp* __px) { this->__set(__px); }
template<class _Tp1> auto_ptr(auto_ptr<_Tp1>& __r) {
_Tp* __conversionCheck = __r.release();
this->__set(__conversionCheck);
}
template<class _Tp1> auto_ptr<_Tp>& operator=(auto_ptr<_Tp1>& __r) {
_Tp* __conversionCheck = __r.release();
reset(__conversionCheck);
return *this;
}
auto_ptr(_Self& __r) { this->__set(__r.release()); }
_Self& operator=(_Self& __r) {
reset(__r.release());
return *this;
}
~auto_ptr() { delete this->get(); }
auto_ptr(auto_ptr_ref<_Tp> __r) {
this->__set(__r.release());
}
_Self& operator=(auto_ptr_ref<_Tp> __r) {
reset(__r.release());
return *this;
}
template<class _Tp1> operator auto_ptr_ref<_Tp1>() {
return auto_ptr_ref<_Tp1>(*this, this->get());
}
template<class _Tp1> operator auto_ptr<_Tp1>() {
return auto_ptr<_Tp1>(release());
}
};
}
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;
extern __const __int32_t *__ctype_tolower;
extern __const __int32_t *__ctype_toupper;
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 isblank (int) throw ();
extern int tolower (int __c) throw ();
extern int toupper (int __c) 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 __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 _STL {
using __std_alias::isalnum;
using __std_alias::isalpha;
using __std_alias::iscntrl;
using __std_alias::isdigit;
using __std_alias::isgraph;
using __std_alias::islower;
using __std_alias::isprint;
using __std_alias::ispunct;
using __std_alias::isspace;
using __std_alias::isupper;
using __std_alias::isxdigit;
using __std_alias::tolower;
using __std_alias::toupper;
}
namespace std
{
using ::clock_t;
using ::time_t;
using ::tm;
using ::clock;
using ::difftime;
using ::mktime;
using ::time;
using ::asctime;
using ::ctime;
using ::gmtime;
using ::localtime;
using ::strftime;
}
namespace _STL {
using __std_alias::size_t;
using __std_alias::clock_t;
using __std_alias::time_t;
using __std_alias::tm;
using __std_alias::clock;
using __std_alias::asctime;
using __std_alias::ctime;
using __std_alias::gmtime;
using __std_alias::difftime;
using __std_alias::mktime;
using __std_alias::localtime;
using __std_alias::strftime;
using __std_alias::time;
}
typedef struct _IO_FILE FILE;
typedef struct _IO_FILE __FILE;
typedef __builtin_va_list __gnuc_va_list;
typedef unsigned int wint_t;
typedef struct
{
int __count;
union
{
wint_t __wch;
char __wchb[4];
} __value;
} __mbstate_t;
typedef __mbstate_t mbstate_t;
struct tm;
extern "C" {
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 ();
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 wchar_t *wcschr (__const wchar_t *__wcs, wchar_t __wc)
throw () __attribute__ ((__pure__));
extern wchar_t *wcsrchr (__const wchar_t *__wcs, wchar_t __wc)
throw () __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 wchar_t *wcspbrk (__const wchar_t *__wcs, __const wchar_t *__accept)
throw () __attribute__ ((__pure__));
extern wchar_t *wcsstr (__const wchar_t *__haystack, __const wchar_t *__needle)
throw () __attribute__ ((__pure__));
extern wchar_t *wcswcs (__const wchar_t *__haystack, __const wchar_t *__needle)
throw () __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 size_t wcsnlen (__const wchar_t *__s, size_t __maxlen)
throw () __attribute__ ((__pure__));
extern wchar_t *wmemchr (__const wchar_t *__s, wchar_t __c, size_t __n)
throw () __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 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 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 ();
__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 ();
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 double __wcstod_internal (__const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr, int __group)
throw ();
extern float __wcstof_internal (__const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr, int __group)
throw ();
extern long double __wcstold_internal (__const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr,
int __group) throw ();
extern long int __wcstol_internal (__const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr,
int __base, int __group) throw ();
extern unsigned long int __wcstoul_internal (__const wchar_t *__restrict __npt,
wchar_t **__restrict __endptr,
int __base, int __group) throw ();
__extension__
extern long long int __wcstoll_internal (__const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr,
int __base, int __group) throw ();
__extension__
extern unsigned long long int __wcstoull_internal (__const wchar_t *
__restrict __nptr,
wchar_t **
__restrict __endptr,
int __base,
int __group) throw ();
extern wchar_t *wcpcpy (wchar_t *__dest, __const wchar_t *__src) throw ();
extern wchar_t *wcpncpy (wchar_t *__dest, __const wchar_t *__src, size_t __n)
throw ();
extern int fwide (__FILE *__fp, int __mode) throw ();
extern int fwprintf (__FILE *__restrict __stream,
__const wchar_t *__restrict __format, ...)
throw () ;
extern int wprintf (__const wchar_t *__restrict __format, ...)
throw () ;
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)
throw () ;
extern int vwprintf (__const wchar_t *__restrict __format,
__gnuc_va_list __arg)
throw () ;
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, ...)
throw () ;
extern int wscanf (__const wchar_t *__restrict __format, ...)
throw () ;
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)
throw () ;
extern int vwscanf (__const wchar_t *__restrict __format,
__gnuc_va_list __arg)
throw () ;
extern int vswscanf (__const wchar_t *__restrict __s,
__const wchar_t *__restrict __format,
__gnuc_va_list __arg)
throw () ;
extern wint_t fgetwc (__FILE *__stream) throw ();
extern wint_t getwc (__FILE *__stream) throw ();
extern wint_t getwchar (void) throw ();
extern wint_t fputwc (wchar_t __wc, __FILE *__stream) throw ();
extern wint_t putwc (wchar_t __wc, __FILE *__stream) throw ();
extern wint_t putwchar (wchar_t __wc) throw ();
extern wchar_t *fgetws (wchar_t *__restrict __ws, int __n,
__FILE *__restrict __stream) throw ();
extern int fputws (__const wchar_t *__restrict __ws,
__FILE *__restrict __stream) throw ();
extern wint_t ungetwc (wint_t __wc, __FILE *__stream) throw ();
extern wint_t getwc_unlocked (__FILE *__stream) throw ();
extern wint_t getwchar_unlocked (void) throw ();
extern wint_t fgetwc_unlocked (__FILE *__stream) throw ();
extern wint_t fputwc_unlocked (wchar_t __wc, __FILE *__stream) throw ();
extern wint_t putwc_unlocked (wchar_t __wc, __FILE *__stream) throw ();
extern wint_t putwchar_unlocked (wchar_t __wc) throw ();
extern wchar_t *fgetws_unlocked (wchar_t *__restrict __ws, int __n,
__FILE *__restrict __stream) throw ();
extern int fputws_unlocked (__const wchar_t *__restrict __ws,
__FILE *__restrict __stream) throw ();
extern size_t wcsftime (wchar_t *__restrict __s, size_t __maxsize,
__const wchar_t *__restrict __format,
__const struct tm *__restrict __tp) throw ();
}
namespace std
{
using ::mbstate_t;
}
namespace std
{
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;
inline wchar_t*
wcschr(wchar_t* __p, wchar_t __c)
{ return wcschr(const_cast<const wchar_t*>(__p), __c); }
using ::wcspbrk;
inline wchar_t*
wcspbrk(wchar_t* __s1, wchar_t* __s2)
{ return wcspbrk(const_cast<const wchar_t*>(__s1), __s2); }
using ::wcsrchr;
inline wchar_t*
wcsrchr(wchar_t* __p, wchar_t __c)
{ return wcsrchr(const_cast<const wchar_t*>(__p), __c); }
using ::wcsstr;
inline wchar_t*
wcsstr(wchar_t* __s1, wchar_t* __s2)
{ return wcsstr(const_cast<const wchar_t*>(__s1), __s2); }
using ::wmemchr;
inline wchar_t*
wmemchr(wchar_t* __p, wchar_t __c, size_t __n)
{ return wmemchr(const_cast<const wchar_t*>(__p), __c, __n); }
}
namespace __gnu_cxx
{
using ::wcstold;
using ::wcstoll;
using ::wcstoull;
}
namespace std
{
using __gnu_cxx::wcstold;
using __gnu_cxx::wcstoll;
using __gnu_cxx::wcstoull;
}
namespace _STL {
using namespace __std_alias;
}
namespace _STL {
using __std_alias::wint_t;
using __std_alias::size_t;
using __std_alias::mbstate_t;
}
namespace _STL {
template <class _Tp> class allocator;
typedef long streamoff;
typedef ptrdiff_t streamsize;
template <class _StateT> class fpos
{
public:
fpos(streamoff __pos) : _M_pos(__pos), _M_st(_StateT()) {}
fpos() : _M_pos(0), _M_st(_StateT()) {}
operator streamoff() const { return _M_pos; }
bool operator==(const fpos<_StateT>& __y) const
{ return _M_pos == __y._M_pos; }
bool operator!=(const fpos<_StateT>& __y) const
{ return _M_pos != __y._M_pos; }
fpos<_StateT>& operator+=(streamoff __off) {
_M_pos += __off;
return *this;
}
fpos<_StateT>& operator-=(streamoff __off) {
_M_pos -= __off;
return *this;
}
fpos<_StateT> operator+(streamoff __off) {
fpos<_StateT> __tmp(*this);
__tmp += __off;
return __tmp;
}
fpos<_StateT> operator-(streamoff __off) {
fpos<_StateT> __tmp(*this);
__tmp -= __off;
return __tmp;
}
public:
_StateT state() const { return _M_st; }
void state(_StateT __st) { _M_st = __st; }
private:
streamoff _M_pos;
_StateT _M_st;
};
typedef fpos<mbstate_t> streampos;
typedef fpos<mbstate_t> wstreampos;
template <class _CharT, class _IntT> class __char_traits_base {
public:
typedef _CharT char_type;
typedef _IntT int_type;
typedef streamoff off_type;
typedef streampos pos_type;
typedef mbstate_t state_type;
static void assign(char_type& __c1, const char_type& __c2) { __c1 = __c2; }
static bool eq(const _CharT& __c1, const _CharT& __c2)
{ return __c1 == __c2; }
static bool lt(const _CharT& __c1, const _CharT& __c2)
{ return __c1 < __c2; }
static int compare(const _CharT* __s1, const _CharT* __s2, size_t __n) {
for (size_t __i = 0; __i < __n; ++__i)
if (!eq(__s1[__i], __s2[__i]))
return __s1[__i] < __s2[__i] ? -1 : 1;
return 0;
}
static size_t length(const _CharT* __s) {
const _CharT _NullChar = _CharT();
size_t __i;
for (__i = 0; !eq(__s[__i], _NullChar); ++__i)
{}
return __i;
}
static const _CharT* find(const _CharT* __s, size_t __n, const _CharT& __c) {
for ( ; __n > 0 ; ++__s, --__n)
if (eq(*__s, __c))
return __s;
return 0;
}
static _CharT* move(_CharT* __s1, const _CharT* __s2, size_t _Sz) {
return (_Sz == 0 ? __s1 : (_CharT*)memmove(__s1, __s2, _Sz * sizeof(_CharT)));
}
static _CharT* copy(_CharT* __s1, const _CharT* __s2, size_t __n) {
return (__n == 0 ? __s1 :
(_CharT*)memcpy(__s1, __s2, __n * sizeof(_CharT)));
}
static _CharT* assign(_CharT* __s, size_t __n, _CharT __c) {
for (size_t __i = 0; __i < __n; ++__i)
__s[__i] = __c;
return __s;
}
static int_type not_eof(const int_type& __c) {
return !eq_int_type(__c, eof()) ? __c : static_cast<int_type>(0);
}
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 (int_type)-1;
}
};
template <class _CharT> class char_traits
: public __char_traits_base<_CharT, _CharT>
{};
template<> class char_traits<char>
: public __char_traits_base<char, int>
{
public:
typedef char char_type;
typedef int int_type;
typedef streamoff off_type;
typedef streampos pos_type;
typedef mbstate_t state_type;
static char to_char_type(const int& __c) {
return (char)(unsigned char)__c;
}
static int to_int_type(const char& __c) {
return (unsigned char)__c;
}
static int compare(const char* __s1, const char* __s2, size_t __n)
{ return memcmp(__s1, __s2, __n); }
static size_t length(const char* __s) { return strlen(__s); }
static void assign(char& __c1, const char& __c2) { __c1 = __c2; }
static char* assign(char* __s, size_t __n, char __c)
{ memset(__s, __c, __n); return __s; }
};
template<> class char_traits<wchar_t>
: public __char_traits_base<wchar_t, wint_t>
{};
}
namespace _STL {
class ios_base;
template <class _CharT, class _Traits = char_traits<_CharT> >
class basic_ios;
template <class _CharT, class _Traits = char_traits<_CharT> >
class basic_streambuf;
template <class _CharT, class _Traits = char_traits<_CharT> >
class basic_istream;
template <class _CharT, class _Traits = char_traits<_CharT> >
class basic_ostream;
template <class _CharT, class _Traits = char_traits<_CharT> >
class basic_iostream;
template <class _CharT, class _Traits = char_traits<_CharT>,
class _Allocator = allocator<_CharT> >
class basic_stringbuf;
template <class _CharT, class _Traits = char_traits<_CharT>,
class _Allocator = allocator<_CharT> >
class basic_istringstream;
template <class _CharT, class _Traits = char_traits<_CharT>,
class _Allocator = allocator<_CharT> >
class basic_ostringstream;
template <class _CharT, class _Traits = char_traits<_CharT>,
class _Allocator = allocator<_CharT> >
class basic_stringstream;
template <class _CharT, class _Traits = char_traits<_CharT> >
class basic_filebuf;
template <class _CharT, class _Traits = char_traits<_CharT> >
class basic_ifstream;
template <class _CharT, class _Traits = char_traits<_CharT> >
class basic_ofstream;
template <class _CharT, class _Traits = char_traits<_CharT> >
class basic_fstream;
template <class _CharT, class _Traits = char_traits<_CharT> >
class istreambuf_iterator;
template <class _CharT, class _Traits = char_traits<_CharT> >
class ostreambuf_iterator;
typedef basic_ios<char, char_traits<char> > ios;
typedef basic_ios<wchar_t, char_traits<wchar_t> > wios;
class locale;
template <class _Facet> inline const _Facet& use_facet(const locale&);
template <class _CharT> class ctype;
template <class _CharT> class ctype_byname;
template <class _CharT> class collate;
template <class _CharT> class collate_byname;
template<> class ctype<char>;
template<> class ctype_byname<char>;
template<> class collate<char>;
template<> class collate_byname<char>;
template<> class ctype<wchar_t>;
template<> class ctype_byname<wchar_t>;
template<> class collate<wchar_t>;
template<> class collate_byname<wchar_t>;
template<> class basic_streambuf<char, char_traits<char> >;
typedef basic_istream<char, char_traits<char> > istream;
typedef basic_ostream<char, char_traits<char> > ostream;
typedef basic_iostream<char, char_traits<char> > iostream;
typedef basic_streambuf<char,char_traits<char> > streambuf;
typedef basic_stringbuf<char, char_traits<char>, allocator<char> > stringbuf;
typedef basic_istringstream<char, char_traits<char>, allocator<char> > istringstream;
typedef basic_ostringstream<char, char_traits<char>, allocator<char> > ostringstream;
typedef basic_stringstream<char, char_traits<char>, allocator<char> > stringstream;
typedef basic_filebuf<char, char_traits<char> > filebuf;
typedef basic_ifstream<char, char_traits<char> > ifstream;
typedef basic_ofstream<char, char_traits<char> > ofstream;
typedef basic_fstream<char, char_traits<char> > fstream;
typedef basic_streambuf<wchar_t, char_traits<wchar_t> > wstreambuf;
typedef basic_istream<wchar_t, char_traits<wchar_t> > wistream;
typedef basic_ostream<wchar_t, char_traits<wchar_t> > wostream;
typedef basic_iostream<wchar_t, char_traits<wchar_t> > wiostream;
typedef basic_stringbuf<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstringbuf;
typedef basic_istringstream<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wistringstream;
typedef basic_ostringstream<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wostringstream;
typedef basic_stringstream<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstringstream;
typedef basic_filebuf<wchar_t, char_traits<wchar_t> > wfilebuf;
typedef basic_ifstream<wchar_t, char_traits<wchar_t> > wifstream;
typedef basic_ofstream<wchar_t, char_traits<wchar_t> > wofstream;
typedef basic_fstream<wchar_t, char_traits<wchar_t> > wfstream;
}
namespace _STL {
template <class _CharT,
class _Traits = char_traits<_CharT>,
class _Alloc = allocator<_CharT> >
class basic_string;
typedef basic_string<char, char_traits<char>, allocator<char> > string;
typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstring;
const char*
__get_c_string(const string& __str);
}
namespace _STL {
template <class _Arg, class _Result>
struct unary_function {
typedef _Arg argument_type;
typedef _Result result_type;
};
template <class _Arg1, class _Arg2, class _Result>
struct binary_function {
typedef _Arg1 first_argument_type;
typedef _Arg2 second_argument_type;
typedef _Result result_type;
};
template <class _Tp>
struct equal_to : public binary_function<_Tp,_Tp,bool>
{
bool operator()(const _Tp& __x, const _Tp& __y) const { return __x == __y; }
};
template <class _Tp>
struct not_equal_to : public binary_function<_Tp,_Tp,bool>
{
bool operator()(const _Tp& __x, const _Tp& __y) const { return __x != __y; }
};
template <class _Tp>
struct greater : public binary_function<_Tp,_Tp,bool>
{
bool operator()(const _Tp& __x, const _Tp& __y) const { return __x > __y; }
};
template <class _Tp>
struct less : public binary_function<_Tp,_Tp,bool>
{
bool operator()(const _Tp& __x, const _Tp& __y) const { return __x < __y; }
};
template <class _Tp>
struct greater_equal : public binary_function<_Tp,_Tp,bool>
{
bool operator()(const _Tp& __x, const _Tp& __y) const { return __x >= __y; }
};
template <class _Tp>
struct less_equal : public binary_function<_Tp,_Tp,bool>
{
bool operator()(const _Tp& __x, const _Tp& __y) const { return __x <= __y; }
};
template <class _Tp>
less<_Tp> __less(_Tp* ) { return less<_Tp>(); }
template <class _Tp>
equal_to<_Tp> __equal_to(_Tp* ) { return equal_to<_Tp>(); }
template <class _Tp>
struct plus : public binary_function<_Tp,_Tp,_Tp> {
_Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x + __y; }
};
template <class _Tp>
struct minus : public binary_function<_Tp,_Tp,_Tp> {
_Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x - __y; }
};
template <class _Tp>
plus<_Tp> __plus(_Tp* ) { return plus<_Tp>(); }
template <class _Tp>
minus<_Tp> __minus(_Tp* ) { return minus<_Tp>(); }
template <class _Tp>
struct multiplies : public binary_function<_Tp,_Tp,_Tp> {
_Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x * __y; }
};
template <class _Tp>
struct divides : public binary_function<_Tp,_Tp,_Tp> {
_Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x / __y; }
};
template <class _Tp>
struct modulus : public binary_function<_Tp,_Tp,_Tp>
{
_Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x % __y; }
};
template <class _Tp>
struct negate : public unary_function<_Tp,_Tp>
{
_Tp operator()(const _Tp& __x) const { return -__x; }
};
template <class _Tp>
struct logical_and : public binary_function<_Tp,_Tp,bool>
{
bool operator()(const _Tp& __x, const _Tp& __y) const { return __x && __y; }
};
template <class _Tp>
struct logical_or : public binary_function<_Tp,_Tp,bool>
{
bool operator()(const _Tp& __x, const _Tp& __y) const { return __x || __y; }
};
template <class _Tp>
struct logical_not : public unary_function<_Tp,bool>
{
bool operator()(const _Tp& __x) const { return !__x; }
};
template <class _Pair>
struct _Select1st : public unary_function<_Pair, typename _Pair::first_type> {
const typename _Pair::first_type& operator()(const _Pair& __x) const {
return __x.first;
}
};
template <class _Pair>
struct _Select2nd : public unary_function<_Pair, typename _Pair::second_type>
{
const typename _Pair::second_type& operator()(const _Pair& __x) const {
return __x.second;
}
};
template <class _Arg1, class _Arg2>
struct _Project1st : public binary_function<_Arg1, _Arg2, _Arg1> {
_Arg1 operator()(const _Arg1& __x, const _Arg2&) const { return __x; }
};
template <class _Arg1, class _Arg2>
struct _Project2nd : public binary_function<_Arg1, _Arg2, _Arg2> {
_Arg2 operator()(const _Arg1&, const _Arg2& __y) const { return __y; }
};
template <class _Tp>
struct _Identity : public unary_function<_Tp,_Tp> {
const _Tp& operator()(const _Tp& __x) const { return __x; }
};
template <class _Result, class _Argument>
struct _Constant_unary_fun {
typedef _Argument argument_type;
typedef _Result result_type;
result_type _M_val;
_Constant_unary_fun(const result_type& __v) : _M_val(__v) {}
const result_type& operator()(const _Argument&) const { return _M_val; }
};
template <class _Result, class _Arg1, class _Arg2>
struct _Constant_binary_fun {
typedef _Arg1 first_argument_type;
typedef _Arg2 second_argument_type;
typedef _Result result_type;
_Result _M_val;
_Constant_binary_fun(const _Result& __v) : _M_val(__v) {}
const result_type& operator()(const _Arg1&, const _Arg2&) const {
return _M_val;
}
};
template <class _Tp> inline _Tp __identity_element(plus<_Tp>) { return _Tp(0); }
template <class _Tp> inline _Tp __identity_element(multiplies<_Tp>) { return _Tp(1); }
}
namespace _STL {
template <class _Tp> inline _Tp identity_element(plus<_Tp>) { return _Tp(0); }
template <class _Tp> inline _Tp identity_element(multiplies<_Tp>) { return _Tp(1); }
template <class _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 <class _Predicate>
inline unary_negate<_Predicate>
not1(const _Predicate& __pred)
{
return unary_negate<_Predicate>(__pred);
}
template <class _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 <class _Predicate>
inline binary_negate<_Predicate>
not2(const _Predicate& __pred)
{
return binary_negate<_Predicate>(__pred);
}
template <class _Operation>
class binder1st :
public unary_function<typename _Operation::second_argument_type,
typename _Operation::result_type > {
protected:
_Operation _M_op;
typename _Operation::first_argument_type _M_value;
public:
binder1st(const _Operation& __x,
const typename _Operation::first_argument_type& __y)
: _M_op(__x), _M_value(__y) {}
typename _Operation::result_type
operator()(const typename _Operation::second_argument_type& __x) const {
return _M_op(_M_value, __x);
}
};
template <class _Operation, class _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 <class _Operation>
class binder2nd
: public unary_function<typename _Operation::first_argument_type,
typename _Operation::result_type> {
protected:
_Operation _M_op;
typename _Operation::second_argument_type value;
public:
binder2nd(const _Operation& __x,
const typename _Operation::second_argument_type& __y)
: _M_op(__x), value(__y) {}
typename _Operation::result_type
operator()(const typename _Operation::first_argument_type& __x) const {
return _M_op(__x, value);
}
};
template <class _Operation, class _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));
}
template <class _Operation1, class _Operation2>
class unary_compose :
public unary_function<typename _Operation2::argument_type,
typename _Operation1::result_type> {
protected:
_Operation1 _M_fn1;
_Operation2 _M_fn2;
public:
unary_compose(const _Operation1& __x, const _Operation2& __y)
: _M_fn1(__x), _M_fn2(__y) {}
typename _Operation1::result_type
operator()(const typename _Operation2::argument_type& __x) const {
return _M_fn1(_M_fn2(__x));
}
};
template <class _Operation1, class _Operation2>
inline unary_compose<_Operation1,_Operation2>
compose1(const _Operation1& __fn1, const _Operation2& __fn2)
{
return unary_compose<_Operation1,_Operation2>(__fn1, __fn2);
}
template <class _Operation1, class _Operation2, class _Operation3>
class binary_compose :
public unary_function<typename _Operation2::argument_type,
typename _Operation1::result_type> {
protected:
_Operation1 _M_fn1;
_Operation2 _M_fn2;
_Operation3 _M_fn3;
public:
binary_compose(const _Operation1& __x, const _Operation2& __y,
const _Operation3& __z)
: _M_fn1(__x), _M_fn2(__y), _M_fn3(__z) { }
typename _Operation1::result_type
operator()(const typename _Operation2::argument_type& __x) const {
return _M_fn1(_M_fn2(__x), _M_fn3(__x));
}
};
template <class _Operation1, class _Operation2, class _Operation3>
inline binary_compose<_Operation1, _Operation2, _Operation3>
compose2(const _Operation1& __fn1, const _Operation2& __fn2,
const _Operation3& __fn3)
{
return binary_compose<_Operation1,_Operation2,_Operation3>
(__fn1, __fn2, __fn3);
}
template <class _Arg, class _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 <class _Arg, class _Result>
inline pointer_to_unary_function<_Arg, _Result> ptr_fun(_Result (*__x)(_Arg))
{
return pointer_to_unary_function<_Arg, _Result>(__x);
}
template <class _Arg1, class _Arg2, class _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 <class _Arg1, class _Arg2, class _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 <class _Tp> struct identity : public _Identity<_Tp> {};
template <class _Pair> struct select1st : public _Select1st<_Pair> {};
template <class _Pair> struct select2nd : public _Select2nd<_Pair> {};
template <class _Arg1, class _Arg2>
struct project1st : public _Project1st<_Arg1, _Arg2> {};
template <class _Arg1, class _Arg2>
struct project2nd : public _Project2nd<_Arg1, _Arg2> {};
template <class _Result>
struct _Constant_void_fun {
typedef _Result result_type;
result_type _M_val;
_Constant_void_fun(const result_type& __v) : _M_val(__v) {}
const result_type& operator()() const { return _M_val; }
};
template <class _Result>
struct constant_void_fun : public _Constant_void_fun<_Result> {
constant_void_fun(const _Result& __v) : _Constant_void_fun<_Result>(__v) {}
};
template <class _Result, class _Argument = _Result >
struct constant_unary_fun : public _Constant_unary_fun<_Result, _Argument>
{
constant_unary_fun(const _Result& __v)
: _Constant_unary_fun<_Result, _Argument>(__v) {}
};
template <class _Result, class _Arg1 = _Result, class _Arg2 = _Arg1 >
struct constant_binary_fun
: public _Constant_binary_fun<_Result, _Arg1, _Arg2>
{
constant_binary_fun(const _Result& __v)
: _Constant_binary_fun<_Result, _Arg1, _Arg2>(__v) {}
};
template <class _Result>
inline constant_void_fun<_Result> constant0(const _Result& __val)
{
return constant_void_fun<_Result>(__val);
}
template <class _Result>
inline constant_unary_fun<_Result,_Result> constant1(const _Result& __val)
{
return constant_unary_fun<_Result,_Result>(__val);
}
template <class _Result>
inline constant_binary_fun<_Result,_Result,_Result>
constant2(const _Result& __val)
{
return constant_binary_fun<_Result,_Result,_Result>(__val);
}
class subtractive_rng : public unary_function<unsigned long, unsigned long> {
private:
unsigned long _M_table[55];
unsigned long _M_index1;
unsigned long _M_index2;
public:
unsigned long operator()(unsigned long __limit) {
_M_index1 = (_M_index1 + 1) % 55;
_M_index2 = (_M_index2 + 1) % 55;
_M_table[_M_index1] = _M_table[_M_index1] - _M_table[_M_index2];
return _M_table[_M_index1] % __limit;
}
void _M_initialize(unsigned long __seed)
{
unsigned long __k = 1;
_M_table[54] = __seed;
unsigned long __i;
for (__i = 0; __i < 54; __i++) {
unsigned long __ii = (21 * (__i + 1) % 55) - 1;
_M_table[__ii] = __k;
__k = __seed - __k;
__seed = _M_table[__ii];
}
for (int __loop = 0; __loop < 4; __loop++) {
for (__i = 0; __i < 55; __i++)
_M_table[__i] = _M_table[__i] - _M_table[(1 + __i + 30) % 55];
}
_M_index1 = 0;
_M_index2 = 31;
}
subtractive_rng(unsigned int __seed) { _M_initialize(__seed); }
subtractive_rng() { _M_initialize(161803398ul); }
};
template <class _Ret, class _Tp>
class mem_fun_t : public unary_function<_Tp*,_Ret> {
typedef _Ret (_Tp::*_fun_type)(void);
public:
explicit mem_fun_t(_fun_type __pf) : _M_f(__pf) {}
_Ret operator()(_Tp* __p) const { return (__p->*_M_f)(); }
private:
_fun_type _M_f;
};
template <class _Ret, class _Tp>
class const_mem_fun_t : public unary_function<const _Tp*,_Ret> {
typedef _Ret (_Tp::*_fun_type)(void) const;
public:
explicit const_mem_fun_t(_fun_type __pf) : _M_f(__pf) {}
_Ret operator()(const _Tp* __p) const { return (__p->*_M_f)(); }
private:
_fun_type _M_f;
};
template <class _Ret, class _Tp>
class mem_fun_ref_t : public unary_function<_Tp,_Ret> {
typedef _Ret (_Tp::*_fun_type)(void);
public:
explicit mem_fun_ref_t(_fun_type __pf) : _M_f(__pf) {}
_Ret operator()(_Tp& __r) const { return (__r.*_M_f)(); }
private:
_fun_type _M_f;
};
template <class _Ret, class _Tp>
class const_mem_fun_ref_t : public unary_function<_Tp,_Ret> {
typedef _Ret (_Tp::*_fun_type)(void) const;
public:
explicit const_mem_fun_ref_t(_fun_type __pf) : _M_f(__pf) {}
_Ret operator()(const _Tp& __r) const { return (__r.*_M_f)(); }
private:
_fun_type _M_f;
};
template <class _Ret, class _Tp, class _Arg>
class mem_fun1_t : public binary_function<_Tp*,_Arg,_Ret> {
typedef _Ret (_Tp::*_fun_type)(_Arg);
public:
explicit mem_fun1_t(_fun_type __pf) : _M_f(__pf) {}
_Ret operator()(_Tp* __p, _Arg __x) const { return (__p->*_M_f)(__x); }
private:
_fun_type _M_f;
};
template <class _Ret, class _Tp, class _Arg>
class const_mem_fun1_t : public binary_function<const _Tp*,_Arg,_Ret> {
typedef _Ret (_Tp::*_fun_type)(_Arg) const;
public:
explicit const_mem_fun1_t(_fun_type __pf) : _M_f(__pf) {}
_Ret operator()(const _Tp* __p, _Arg __x) const
{ return (__p->*_M_f)(__x); }
private:
_fun_type _M_f;
};
template <class _Ret, class _Tp, class _Arg>
class mem_fun1_ref_t : public binary_function<_Tp,_Arg,_Ret> {
typedef _Ret (_Tp::*_fun_type)(_Arg);
public:
explicit mem_fun1_ref_t(_fun_type __pf) : _M_f(__pf) {}
_Ret operator()(_Tp& __r, _Arg __x) const { return (__r.*_M_f)(__x); }
private:
_fun_type _M_f;
};
template <class _Ret, class _Tp, class _Arg>
class const_mem_fun1_ref_t : public binary_function<_Tp,_Arg,_Ret> {
typedef _Ret (_Tp::*_fun_type)(_Arg) const;
public:
explicit const_mem_fun1_ref_t(_fun_type __pf) : _M_f(__pf) {}
_Ret operator()(const _Tp& __r, _Arg __x) const { return (__r.*_M_f)(__x); }
private:
_fun_type _M_f;
};
template <class _Tp>
class mem_fun_t<void, _Tp> : public unary_function<_Tp*,void> {
typedef void (_Tp::*_fun_type)(void);
public:
explicit mem_fun_t (_fun_type __pf) : _M_f(__pf) {}
void operator()(_Tp* __p) const { (__p->*_M_f)(); }
private:
_fun_type _M_f;
};
template <class _Tp>
class const_mem_fun_t<void, _Tp> : public unary_function<const _Tp*,void> {
typedef void (_Tp::*_fun_type)(void) const;
public:
explicit const_mem_fun_t (_fun_type __pf) : _M_f(__pf) {}
void operator()(const _Tp* __p) const { (__p->*_M_f)(); }
private:
_fun_type _M_f;
};
template <class _Tp>
class mem_fun_ref_t<void, _Tp> : public unary_function<_Tp,void> {
typedef void (_Tp::*_fun_type)(void);
public:
explicit mem_fun_ref_t (_fun_type __pf) : _M_f(__pf) {}
void operator()(_Tp& __r) const { (__r.*_M_f)(); }
private:
_fun_type _M_f;
};
template <class _Tp>
class const_mem_fun_ref_t<void, _Tp> : public unary_function<_Tp,void> {
typedef void (_Tp::*_fun_type)(void) const;
public:
explicit const_mem_fun_ref_t (_fun_type __pf) : _M_f(__pf) {}
void operator()(const _Tp& __r) const { (__r.*_M_f)(); }
private:
_fun_type _M_f;
};
template <class _Tp, class _Arg>
class mem_fun1_t<void, _Tp, _Arg> : public binary_function<_Tp*,_Arg,void> {
typedef void (_Tp::*_fun_type)(_Arg);
public:
explicit mem_fun1_t (_fun_type __pf) : _M_f(__pf) {}
void operator()(_Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); }
private:
_fun_type _M_f;
};
template <class _Tp, class _Arg>
class const_mem_fun1_t<void, _Tp, _Arg>
: public binary_function<const _Tp*,_Arg,void> {
typedef void (_Tp::*_fun_type)(_Arg) const;
public:
explicit const_mem_fun1_t (_fun_type __pf) : _M_f(__pf) {}
void operator()(const _Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); }
private:
_fun_type _M_f;
};
template <class _Tp, class _Arg>
class mem_fun1_ref_t<void, _Tp, _Arg>
: public binary_function<_Tp,_Arg,void> {
typedef void (_Tp::*_fun_type)(_Arg);
public:
explicit mem_fun1_ref_t (_fun_type __pf) : _M_f(__pf) {}
void operator()(_Tp& __r, _Arg __x) const { (__r.*_M_f)(__x); }
private:
_fun_type _M_f;
};
template <class _Tp, class _Arg>
class const_mem_fun1_ref_t<void, _Tp, _Arg>
: public binary_function<_Tp,_Arg,void> {
typedef void (_Tp::*_fun_type)(_Arg) const;
public:
explicit const_mem_fun1_ref_t (_fun_type __pf) : _M_f(__pf) {}
void operator()(const _Tp& __r, _Arg __x) const { (__r.*_M_f)(__x); }
private:
_fun_type _M_f;
};
template <class _Ret, class _Tp>
inline mem_fun_t<_Ret,_Tp> mem_fun(_Ret (_Tp::*__f)()) { return mem_fun_t<_Ret,_Tp>(__f); }
template <class _Ret, class _Tp>
inline const_mem_fun_t<_Ret,_Tp> mem_fun(_Ret (_Tp::*__f)() const) { return const_mem_fun_t<_Ret,_Tp>(__f); }
template <class _Ret, class _Tp>
inline mem_fun_ref_t<_Ret,_Tp> mem_fun_ref(_Ret (_Tp::*__f)()) { return mem_fun_ref_t<_Ret,_Tp>(__f); }
template <class _Ret, class _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 <class _Ret, class _Tp, class _Arg>
inline mem_fun1_t<_Ret,_Tp,_Arg>
mem_fun(_Ret (_Tp::*__f)(_Arg)) { return mem_fun1_t<_Ret,_Tp,_Arg>(__f); }
template <class _Ret, class _Tp, class _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 <class _Ret, class _Tp, class _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 <class _Ret, class _Tp, class _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); }
template <class _Ret, class _Tp, class _Arg>
inline mem_fun1_t<_Ret,_Tp,_Arg>
mem_fun1(_Ret (_Tp::*__f)(_Arg)) { return mem_fun1_t<_Ret,_Tp,_Arg>(__f); }
template <class _Ret, class _Tp, class _Arg>
inline const_mem_fun1_t<_Ret,_Tp,_Arg>
mem_fun1(_Ret (_Tp::*__f)(_Arg) const) { return const_mem_fun1_t<_Ret,_Tp,_Arg>(__f); }
template <class _Ret, class _Tp, class _Arg>
inline mem_fun1_ref_t<_Ret,_Tp,_Arg>
mem_fun1_ref(_Ret (_Tp::*__f)(_Arg)) { return mem_fun1_ref_t<_Ret,_Tp,_Arg>(__f); }
template <class _Ret, class _Tp, class _Arg>
inline const_mem_fun1_ref_t<_Ret,_Tp,_Arg>
mem_fun1_ref(_Ret (_Tp::*__f)(_Arg) const) { return const_mem_fun1_ref_t<_Ret,_Tp,_Arg>(__f); }
}
namespace _STL {
template <class _Traits>
struct _Eq_traits
: public binary_function<typename _Traits::char_type,
typename _Traits::char_type,
bool>
{
bool operator()(const typename _Traits::char_type& __x,
const typename _Traits::char_type& __y) const
{ return _Traits::eq(__x, __y); }
};
template <class _Traits>
struct _Eq_char_bound
: public unary_function<typename _Traits::char_type, bool>
{
typename _Traits::char_type __val;
_Eq_char_bound(typename _Traits::char_type __c) : __val(__c) {}
bool operator()(const typename _Traits::char_type& __x) const
{ return _Traits::eq(__x, __val); }
};
template <class _Traits>
struct _Neq_char_bound
: public unary_function<typename _Traits::char_type, bool>
{
typename _Traits::char_type __val;
_Neq_char_bound(typename _Traits::char_type __c) : __val(__c) {}
bool operator()(const typename _Traits::char_type& __x) const
{ return !_Traits::eq(__x, __val); }
};
template <class _Traits>
struct _Eq_int_bound
: public unary_function<typename _Traits::char_type, bool>
{
typename _Traits::int_type __val;
_Eq_int_bound(typename _Traits::int_type __c) : __val(__c) {}
bool operator()(const typename _Traits::char_type& __x) const
{ return _Traits::eq_int_type(_Traits::to_int_type(__x), __val); }
};
}
namespace _STL {
template <class _Traits> struct _Not_within_traits
: public unary_function<typename _Traits::char_type, bool> {
typedef typename _Traits::char_type _CharT;
const _CharT* _M_first;
const _CharT* _M_last;
_Not_within_traits(const typename _Traits::char_type* __f,
const typename _Traits::char_type* __l)
: _M_first(__f), _M_last(__l) {}
bool operator()(const typename _Traits::char_type& __x) const {
return find_if(const_cast<_CharT*>(_M_first),
const_cast<_CharT*>(_M_last),
_Eq_char_bound<_Traits>(__x)) ==
const_cast<_CharT*>(_M_last);
}
};
template <class _Tp, class _Alloc> class _String_base {
public:
typedef typename _Alloc_traits<_Tp, _Alloc>::allocator_type allocator_type;
_Tp* _M_start;
_Tp* _M_finish;
_STLP_alloc_proxy<_Tp*, _Tp, allocator_type> _M_end_of_storage;
void _M_allocate_block(size_t);
void _M_deallocate_block()
{ _M_end_of_storage.deallocate(_M_start, _M_end_of_storage._M_data - _M_start); }
size_t max_size() const { return (size_t(-1) / sizeof(_Tp)) - 1; }
_String_base(const allocator_type& __a)
: _M_start(0), _M_finish(0), _M_end_of_storage(__a, (_Tp*)0) {}
_String_base(const allocator_type& __a, size_t __n)
: _M_start(0), _M_finish(0), _M_end_of_storage(__a, (_Tp*)0)
{ _M_allocate_block(__n); }
~_String_base() { _M_deallocate_block(); }
void _M_throw_length_error() const;
void _M_throw_out_of_range() const;
};
struct _String_reserve_t {};
template <class _CharT, class _Traits, class _Alloc> class basic_string : protected _String_base<_CharT,_Alloc> {
private:
typedef _String_base<_CharT,_Alloc> _Base;
typedef basic_string<_CharT, _Traits, _Alloc> _Self;
typedef typename _Is_integer<_CharT>::_Integral _Char_Is_Integral;
public:
typedef _CharT value_type;
typedef _Traits traits_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef random_access_iterator_tag _Iterator_category;
typedef const value_type* const_iterator;
typedef value_type* iterator;
typedef _STL::reverse_iterator<const_iterator> const_reverse_iterator; typedef _STL::reverse_iterator<iterator> reverse_iterator;
static const size_t npos = ~(size_t)0;
typedef _String_reserve_t _Reserve_t;
public:
typedef typename _String_base<_CharT,_Alloc>::allocator_type allocator_type;
allocator_type get_allocator() const {
return (const allocator_type&)this->_M_end_of_storage;
}
basic_string();
explicit basic_string(const allocator_type& __a)
: _String_base<_CharT,_Alloc>(__a, 8) {
_M_terminate_string();
}
basic_string(_Reserve_t, size_t __n,
const allocator_type& __a = allocator_type())
: _String_base<_CharT,_Alloc>(__a, __n + 1) {
_M_terminate_string();
}
basic_string(const basic_string<_CharT, _Traits, _Alloc>&);
basic_string(const _Self& __s, size_type __pos, size_type __n = npos,
const allocator_type& __a = allocator_type())
: _String_base<_CharT,_Alloc>(__a) {
if (__pos > __s.size())
this->_M_throw_out_of_range();
else
_M_range_initialize(__s._M_start + __pos,
__s._M_start + __pos + (min) (__n, __s.size() - __pos));
}
basic_string(const _CharT* __s, size_type __n,
const allocator_type& __a = allocator_type())
: _String_base<_CharT,_Alloc>(__a)
{
_M_range_initialize(__s, __s + __n);
}
basic_string(const _CharT* __s,
const allocator_type& __a = allocator_type());
basic_string(size_type __n, _CharT __c,
const allocator_type& __a = allocator_type())
: _String_base<_CharT,_Alloc>(__a, __n + 1)
{
this->_M_finish = uninitialized_fill_n(this->_M_start, __n, __c);
_M_terminate_string();
}
template <class _InputIterator> basic_string(_InputIterator __f, _InputIterator __l,
const allocator_type & __a = allocator_type())
: _String_base<_CharT,_Alloc>(__a)
{
typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
_M_initialize_dispatch(__f, __l, _Integral());
}
~basic_string() { _Destroy(this->_M_start, this->_M_finish + 1); }
_Self& operator=(const _Self& __s) {
if (&__s != this)
assign(__s._M_start, __s._M_finish);
return *this;
}
_Self& operator=(const _CharT* __s) {
return assign(__s, __s + traits_type::length(__s));
}
_Self& operator=(_CharT __c)
{ return assign(static_cast<size_type>(1), __c); }
static _CharT _M_null() {
return _CharT();
}
private:
void _M_construct_null_aux(_CharT* __p, const __false_type&) {
_Construct(__p);
}
void _M_construct_null_aux(_CharT* __p, const __true_type&) {
*__p = 0;
}
void _M_construct_null(_CharT* __p) {
_M_construct_null_aux(__p, _Char_Is_Integral());
}
private:
void _M_terminate_string_aux(const __false_type&) {
try {
_M_construct_null(this->_M_finish);
}
catch(...) { _Destroy(this->_M_start, this->_M_finish); throw; };
}
void _M_terminate_string_aux(const __true_type&) {
*(this->_M_finish)=0;
}
void _M_terminate_string() {
_M_terminate_string_aux(_Char_Is_Integral());
}
template <class _InputIter> void _M_range_initialize(_InputIter __f, _InputIter __l,
const input_iterator_tag &) {
this->_M_allocate_block(8);
_M_construct_null(this->_M_finish);
try {
append(__f, __l);
}
catch(...) { _Destroy(this->_M_start, this->_M_finish + 1); throw; };
}
template <class _ForwardIter> void _M_range_initialize(_ForwardIter __f, _ForwardIter __l,
const forward_iterator_tag &) {
difference_type __n = distance(__f, __l);
this->_M_allocate_block(__n + 1);
this->_M_finish = uninitialized_copy(__f, __l, this->_M_start);
_M_terminate_string();
}
template <class _InputIter> void _M_range_initialize(_InputIter __f, _InputIter __l) {
_M_range_initialize(__f, __l, typename iterator_traits< _InputIter >::iterator_category());
}
template <class _Integer> void _M_initialize_dispatch(_Integer __n, _Integer __x, const __true_type&) {
this->_M_allocate_block(__n + 1);
this->_M_finish = uninitialized_fill_n(this->_M_start, __n, __x);
_M_terminate_string();
}
template <class _InputIter> void _M_initialize_dispatch(_InputIter __f, _InputIter __l, const __false_type&) {
_M_range_initialize(__f, __l);
}
public:
iterator begin() { return this->_M_start; }
iterator end() { return this->_M_finish; }
const_iterator begin() const { return this->_M_start; }
const_iterator end() const { return this->_M_finish; }
reverse_iterator rbegin()
{ return reverse_iterator(this->_M_finish); }
reverse_iterator rend()
{ return reverse_iterator(this->_M_start); }
const_reverse_iterator rbegin() const
{ return const_reverse_iterator(this->_M_finish); }
const_reverse_iterator rend() const
{ return const_reverse_iterator(this->_M_start); }
public:
size_type size() const { return this->_M_finish - this->_M_start; }
size_type length() const { return size(); }
size_t max_size() const { return _Base::max_size(); }
void resize(size_type __n, _CharT __c) {
if (__n <= size())
erase(begin() + __n, end());
else
append(__n - size(), __c);
}
void resize(size_type __n) { resize(__n, _M_null()); }
void reserve(size_type = 0);
size_type capacity() const { return (this->_M_end_of_storage._M_data - this->_M_start) - 1; }
void clear() {
if (!empty()) {
_Traits::assign(*(this->_M_start), _M_null());
_Destroy(this->_M_start+1, this->_M_finish+1);
this->_M_finish = this->_M_start;
}
}
bool empty() const { return this->_M_start == this->_M_finish; }
public:
const_reference operator[](size_type __n) const
{ return *(this->_M_start + __n); }
reference operator[](size_type __n)
{ return *(this->_M_start + __n); }
const_reference at(size_type __n) const {
if (__n >= size())
this->_M_throw_out_of_range();
return *(this->_M_start + __n);
}
reference at(size_type __n) {
if (__n >= size())
this->_M_throw_out_of_range();
return *(this->_M_start + __n);
}
public:
_Self& operator+=(const _Self& __s) { return append(__s); }
_Self& operator+=(const _CharT* __s) { return append(__s); }
_Self& operator+=(_CharT __c) { push_back(__c); return *this; }
_Self& append(const _Self& __s)
{ return append(__s._M_start, __s._M_finish); }
_Self& append(const _Self& __s,
size_type __pos, size_type __n)
{
if (__pos > __s.size())
this->_M_throw_out_of_range();
return append(__s._M_start + __pos,
__s._M_start + __pos + (min) (__n, __s.size() - __pos));
}
_Self& append(const _CharT* __s, size_type __n)
{ return append(__s, __s+__n); }
_Self& append(const _CharT* __s)
{ return append(__s, __s + traits_type::length(__s)); }
_Self& append(size_type __n, _CharT __c);
template <class _InputIter> _Self& append(_InputIter __first, _InputIter __last) {
typedef typename _Is_integer<_InputIter>::_Integral _Integral;
return _M_append_dispatch(__first, __last, _Integral());
}
void push_back(_CharT __c) {
if (this->_M_finish + 1 == this->_M_end_of_storage._M_data)
reserve(size() + (max)(size(), static_cast<size_type>(1)));
_M_construct_null(this->_M_finish + 1);
_Traits::assign(*(this->_M_finish), __c);
++this->_M_finish;
}
void pop_back() {
_Traits::assign(*(this->_M_finish - 1), _M_null());
_Destroy(this->_M_finish);
--this->_M_finish;
}
private:
template <class _InputIter> _Self& append(_InputIter __first, _InputIter __last, const input_iterator_tag &)
{
for ( ; __first != __last ; ++__first)
push_back(*__first);
return *this;
}
template <class _ForwardIter> _Self& append(_ForwardIter __first, _ForwardIter __last,
const forward_iterator_tag &) {
if (__first != __last) {
const size_type __old_size = size();
difference_type __n = distance(__first, __last);
if (static_cast<size_type>(__n) > max_size() || __old_size > max_size() - static_cast<size_type>(__n))
this->_M_throw_length_error();
if (__old_size + __n > capacity()) {
const size_type __len = __old_size +
(max)(__old_size, static_cast<size_type>(__n)) + 1;
pointer __new_start = this->_M_end_of_storage.allocate(__len);
pointer __new_finish = __new_start;
try {
__new_finish = uninitialized_copy(this->_M_start, this->_M_finish, __new_start);
__new_finish = uninitialized_copy(__first, __last, __new_finish);
_M_construct_null(__new_finish);
}
catch(...) { (_Destroy(__new_start,__new_finish), this->_M_end_of_storage.deallocate(__new_start,__len)); throw; };
_Destroy(this->_M_start, this->_M_finish + 1);
this->_M_deallocate_block();
this->_M_start = __new_start;
this->_M_finish = __new_finish;
this->_M_end_of_storage._M_data = __new_start + __len;
}
else {
_ForwardIter __f1 = __first;
++__f1;
uninitialized_copy(__f1, __last, this->_M_finish + 1);
try {
_M_construct_null(this->_M_finish + __n);
}
catch(...) { _Destroy(this->_M_finish + 1, this->_M_finish + __n); throw; };
_Traits::assign(*end(), *__first);
this->_M_finish += __n;
}
}
return *this;
}
template <class _Integer> _Self& _M_append_dispatch(_Integer __n, _Integer __x, const __true_type&) {
return append((size_type) __n, (_CharT) __x);
}
template <class _InputIter> _Self& _M_append_dispatch(_InputIter __f, _InputIter __l,
const __false_type&) {
return append(__f, __l, typename iterator_traits< _InputIter >::iterator_category());
}
public:
_Self& assign(const _Self& __s)
{ return assign(__s._M_start, __s._M_finish); }
_Self& assign(const _Self& __s,
size_type __pos, size_type __n) {
if (__pos > __s.size())
this->_M_throw_out_of_range();
return assign(__s._M_start + __pos,
__s._M_start + __pos + (min) (__n, __s.size() - __pos));
}
_Self& assign(const _CharT* __s, size_type __n)
{ return assign(__s, __s + __n); }
_Self& assign(const _CharT* __s)
{ return assign(__s, __s + _Traits::length(__s)); }
_Self& assign(size_type __n, _CharT __c);
private:
template <class _Integer>
_Self& _M_assign_dispatch(_Integer __n, _Integer __x, const __true_type&) {
return assign((size_type) __n, (_CharT) __x);
}
template <class _InputIter>
_Self& _M_assign_dispatch(_InputIter __f, _InputIter __l,
const __false_type&) {
pointer __cur = this->_M_start;
while (__f != __l && __cur != this->_M_finish) {
_Traits::assign(*__cur, *__f);
++__f;
++__cur;
}
if (__f == __l)
erase(__cur, end());
else
append(__f, __l);
return *this;
}
public:
template <class _InputIter> _Self& assign(_InputIter __first, _InputIter __last) {
typedef typename _Is_integer<_InputIter>::_Integral _Integral;
return _M_assign_dispatch(__first, __last, _Integral());
}
_Self& assign(const _CharT* __f, const _CharT* __l)
{
ptrdiff_t __n = __l - __f;
if (static_cast<size_type>(__n) <= size()) {
_Traits::copy(this->_M_start, __f, __n);
erase(begin() + __n, end());
}
else {
_Traits::copy(this->_M_start, __f, size());
append(__f + size(), __l);
}
return *this;
}
public:
_Self& insert(size_type __pos, const _Self& __s) {
if (__pos > size())
this->_M_throw_out_of_range();
if (size() > max_size() - __s.size())
this->_M_throw_length_error();
insert(begin() + __pos, __s._M_start, __s._M_finish);
return *this;
}
_Self& insert(size_type __pos, const _Self& __s,
size_type __beg, size_type __n) {
if (__pos > size() || __beg > __s.size())
this->_M_throw_out_of_range();
size_type __len = (min) (__n, __s.size() - __beg);
if (size() > max_size() - __len)
this->_M_throw_length_error();
insert(begin() + __pos,
__s._M_start + __beg, __s._M_start + __beg + __len);
return *this;
}
_Self& insert(size_type __pos, const _CharT* __s, size_type __n) {
if (__pos > size())
this->_M_throw_out_of_range();
if (size() > max_size() - __n)
this->_M_throw_length_error();
insert(begin() + __pos, __s, __s + __n);
return *this;
}
_Self& insert(size_type __pos, const _CharT* __s) {
if (__pos > size())
this->_M_throw_out_of_range();
size_type __len = _Traits::length(__s);
if (size() > max_size() - __len)
this->_M_throw_length_error();
insert(this->_M_start + __pos, __s, __s + __len);
return *this;
}
_Self& insert(size_type __pos, size_type __n, _CharT __c) {
if (__pos > size())
this->_M_throw_out_of_range();
if (size() > max_size() - __n)
this->_M_throw_length_error();
insert(begin() + __pos, __n, __c);
return *this;
}
iterator insert(iterator __p, _CharT __c) {
if (__p == end()) {
push_back(__c);
return this->_M_finish - 1;
}
else
return _M_insert_aux(__p, __c);
}
void insert(iterator __p, size_t __n, _CharT __c);
template <class _InputIter> void insert(iterator __p, _InputIter __first, _InputIter __last) {
typedef typename _Is_integer<_InputIter>::_Integral _Integral;
_M_insert_dispatch(__p, __first, __last, _Integral());
}
private:
template <class _InputIter> void insert(iterator __p, _InputIter __first, _InputIter __last,
const input_iterator_tag &)
{
for ( ; __first != __last; ++__first) {
__p = insert(__p, *__first);
++__p;
}
}
template <class _ForwardIter> void insert(iterator __position, _ForwardIter __first, _ForwardIter __last,
const forward_iterator_tag &) {
if (__first != __last) {
difference_type __n = distance(__first, __last);
if (this->_M_end_of_storage._M_data - this->_M_finish >= __n + 1) {
const difference_type __elems_after = this->_M_finish - __position;
pointer __old_finish = this->_M_finish;
if (__elems_after >= __n) {
uninitialized_copy((this->_M_finish - __n) + 1, this->_M_finish + 1,
this->_M_finish + 1);
this->_M_finish += __n;
_Traits::move(__position + __n,
__position, (__elems_after - __n) + 1);
_M_copy(__first, __last, __position);
}
else {
_ForwardIter __mid = __first;
advance(__mid, __elems_after + 1);
uninitialized_copy(__mid, __last, this->_M_finish + 1);
this->_M_finish += __n - __elems_after;
try {
uninitialized_copy(__position, __old_finish + 1, this->_M_finish);
this->_M_finish += __elems_after;
}
catch(...) { (_Destroy(__old_finish + 1, this->_M_finish), this->_M_finish = __old_finish); throw; };
_M_copy(__first, __mid, __position);
}
}
else {
const size_type __old_size = size();
const size_type __len
= __old_size + (max)(__old_size, static_cast<size_type>(__n)) + 1;
pointer __new_start = this->_M_end_of_storage.allocate(__len);
pointer __new_finish = __new_start;
try {
__new_finish = uninitialized_copy(this->_M_start, __position, __new_start);
__new_finish = uninitialized_copy(__first, __last, __new_finish);
__new_finish
= uninitialized_copy(__position, this->_M_finish, __new_finish);
_M_construct_null(__new_finish);
}
catch(...) { (_Destroy(__new_start,__new_finish), this->_M_end_of_storage.deallocate(__new_start,__len)); throw; };
_Destroy(this->_M_start, this->_M_finish + 1);
this->_M_deallocate_block();
this->_M_start = __new_start;
this->_M_finish = __new_finish;
this->_M_end_of_storage._M_data = __new_start + __len;
}
}
}
template <class _Integer> void _M_insert_dispatch(iterator __p, _Integer __n, _Integer __x,
const __true_type&) {
insert(__p, (size_type) __n, (_CharT) __x);
}
template <class _InputIter> void _M_insert_dispatch(iterator __p, _InputIter __first, _InputIter __last,
const __false_type&) {
insert(__p, __first, __last, typename iterator_traits< _InputIter >::iterator_category());
}
template <class _InputIterator> void
_M_copy(_InputIterator __first, _InputIterator __last, pointer __result) {
for ( ; __first != __last; ++__first, ++__result)
_Traits::assign(*__result, *__first);
}
pointer _M_insert_aux(pointer, _CharT);
void
_M_copy(const _CharT* __first, const _CharT* __last, _CharT* __result) {
_Traits::copy(__result, __first, __last - __first);
}
public:
_Self& erase(size_type __pos = 0, size_type __n = npos) {
if (__pos > size())
this->_M_throw_out_of_range();
erase(begin() + __pos, begin() + __pos + (min) (__n, size() - __pos));
return *this;
}
iterator erase(iterator __position) {
_Traits::move(__position, __position + 1, this->_M_finish - __position);
_Destroy(this->_M_finish);
--this->_M_finish;
return __position;
}
iterator erase(iterator __first, iterator __last) {
if (__first != __last) {
traits_type::move(__first, __last, (this->_M_finish - __last) + 1);
pointer __new_finish = this->_M_finish - (__last - __first);
_Destroy(__new_finish + 1, this->_M_finish + 1);
this->_M_finish = __new_finish;
}
return __first;
}
public:
_Self& replace(size_type __pos, size_type __n,
const _Self& __s) {
if (__pos > size())
this->_M_throw_out_of_range();
const size_type __len = (min) (__n, size() - __pos);
if (size() - __len >= max_size() - __s.size())
this->_M_throw_length_error();
return replace(begin() + __pos, begin() + __pos + __len,
__s._M_start, __s._M_finish);
}
_Self& replace(size_type __pos1, size_type __n1,
const _Self& __s,
size_type __pos2, size_type __n2) {
if (__pos1 > size() || __pos2 > __s.size())
this->_M_throw_out_of_range();
const size_type __len1 = (min) (__n1, size() - __pos1);
const size_type __len2 = (min) (__n2, __s.size() - __pos2);
if (size() - __len1 >= max_size() - __len2)
this->_M_throw_length_error();
return replace(begin() + __pos1, begin() + __pos1 + __len1,
__s._M_start + __pos2, __s._M_start + __pos2 + __len2);
}
_Self& replace(size_type __pos, size_type __n1,
const _CharT* __s, size_type __n2) {
if (__pos > size())
this->_M_throw_out_of_range();
const size_type __len = (min) (__n1, size() - __pos);
if (__n2 > max_size() || size() - __len >= max_size() - __n2)
this->_M_throw_length_error();
return replace(begin() + __pos, begin() + __pos + __len,
__s, __s + __n2);
}
_Self& replace(size_type __pos, size_type __n1,
const _CharT* __s) {
if (__pos > size())
this->_M_throw_out_of_range();
const size_type __len = (min) (__n1, size() - __pos);
const size_type __n2 = _Traits::length(__s);
if (__n2 > max_size() || size() - __len >= max_size() - __n2)
this->_M_throw_length_error();
return replace(begin() + __pos, begin() + __pos + __len,
__s, __s + _Traits::length(__s));
}
_Self& replace(size_type __pos, size_type __n1,
size_type __n2, _CharT __c) {
if (__pos > size())
this->_M_throw_out_of_range();
const size_type __len = (min) (__n1, size() - __pos);
if (__n2 > max_size() || size() - __len >= max_size() - __n2)
this->_M_throw_length_error();
return replace(begin() + __pos, begin() + __pos + __len, __n2, __c);
}
_Self& replace(iterator __first, iterator __last,
const _Self& __s)
{ return replace(__first, __last, __s._M_start, __s._M_finish); }
_Self& replace(iterator __first, iterator __last,
const _CharT* __s, size_type __n)
{ return replace(__first, __last, __s, __s + __n); }
_Self& replace(iterator __first, iterator __last,
const _CharT* __s) {
return replace(__first, __last, __s, __s + _Traits::length(__s));
}
_Self& replace(iterator __first, iterator __last,
size_type __n, _CharT __c);
template <class _InputIter> _Self& replace(iterator __first, iterator __last,
_InputIter __f, _InputIter __l) {
typedef typename _Is_integer<_InputIter>::_Integral _Integral;
return _M_replace_dispatch(__first, __last, __f, __l, _Integral());
}
private:
template <class _Integer> _Self& _M_replace_dispatch(iterator __first, iterator __last,
_Integer __n, _Integer __x,
const __true_type&) {
return replace(__first, __last, (size_type) __n, (_CharT) __x);
}
template <class _InputIter> _Self& _M_replace_dispatch(iterator __first, iterator __last,
_InputIter __f, _InputIter __l,
const __false_type&) {
return replace(__first, __last, __f, __l, typename iterator_traits< _InputIter >::iterator_category());
}
template <class _InputIter> _Self& replace(iterator __first, iterator __last,
_InputIter __f, _InputIter __l, const input_iterator_tag &) {
for ( ; __first != __last && __f != __l; ++__first, ++__f)
_Traits::assign(*__first, *__f);
if (__f == __l)
erase(__first, __last);
else
insert(__last, __f, __l);
return *this;
}
template <class _ForwardIter> _Self& replace(iterator __first, iterator __last,
_ForwardIter __f, _ForwardIter __l,
const forward_iterator_tag &) {
difference_type __n = distance(__f, __l);
const difference_type __len = __last - __first;
if (__len >= __n) {
_M_copy(__f, __l, __first);
erase(__first + __n, __last);
}
else {
_ForwardIter __m = __f;
advance(__m, __len);
_M_copy(__f, __m, __first);
insert(__last, __m, __l);
}
return *this;
}
public:
size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const {
if (__pos > size())
this->_M_throw_out_of_range();
const size_type __len = (min) (__n, size() - __pos);
_Traits::copy(__s, this->_M_start + __pos, __len);
return __len;
}
void swap(_Self& __s) {
_STL::swap(this->_M_start, __s._M_start);
_STL::swap(this->_M_finish, __s._M_finish);
_STL::swap(this->_M_end_of_storage, __s._M_end_of_storage);
}
public:
const _CharT* c_str() const { return this->_M_start; }
const _CharT* data() const { return this->_M_start; }
public:
size_type find(const _Self& __s, size_type __pos = 0) const
{ return find(__s._M_start, __pos, __s.size()); }
size_type find(const _CharT* __s, size_type __pos = 0) const
{ return find(__s, __pos, _Traits::length(__s)); }
size_type find(const _CharT* __s, size_type __pos, size_type __n) const;
size_type find(_CharT __c, size_type __pos = 0) const;
public:
size_type rfind(const _Self& __s, size_type __pos = npos) const
{ return rfind(__s._M_start, __pos, __s.size()); }
size_type rfind(const _CharT* __s, size_type __pos = npos) const
{ return rfind(__s, __pos, _Traits::length(__s)); }
size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const;
size_type rfind(_CharT __c, size_type __pos = npos) const;
public:
size_type find_first_of(const _Self& __s, size_type __pos = 0) const
{ return find_first_of(__s._M_start, __pos, __s.size()); }
size_type find_first_of(const _CharT* __s, size_type __pos = 0) const
{ return find_first_of(__s, __pos, _Traits::length(__s)); }
size_type find_first_of(const _CharT* __s, size_type __pos,
size_type __n) const;
size_type find_first_of(_CharT __c, size_type __pos = 0) const
{ return find(__c, __pos); }
public:
size_type find_last_of(const _Self& __s,
size_type __pos = npos) const
{ return find_last_of(__s._M_start, __pos, __s.size()); }
size_type find_last_of(const _CharT* __s, size_type __pos = npos) const
{ return find_last_of(__s, __pos, _Traits::length(__s)); }
size_type find_last_of(const _CharT* __s, size_type __pos,
size_type __n) const;
size_type find_last_of(_CharT __c, size_type __pos = npos) const {
return rfind(__c, __pos);
}
public:
size_type find_first_not_of(const _Self& __s,
size_type __pos = 0) const
{ return find_first_not_of(__s._M_start, __pos, __s.size()); }
size_type find_first_not_of(const _CharT* __s, size_type __pos = 0) const
{ return find_first_not_of(__s, __pos, _Traits::length(__s)); }
size_type find_first_not_of(const _CharT* __s, size_type __pos,
size_type __n) const;
size_type find_first_not_of(_CharT __c, size_type __pos = 0) const;
public:
size_type find_last_not_of(const _Self& __s,
size_type __pos = npos) const
{ return find_last_not_of(__s._M_start, __pos, __s.size()); }
size_type find_last_not_of(const _CharT* __s, size_type __pos = npos) const
{ return find_last_not_of(__s, __pos, _Traits::length(__s)); }
size_type find_last_not_of(const _CharT* __s, size_type __pos,
size_type __n) const;
size_type find_last_not_of(_CharT __c, size_type __pos = npos) const;
public:
_Self substr(size_type __pos = 0, size_type __n = npos) const {
if (__pos > size())
this->_M_throw_out_of_range();
return _Self(this->_M_start + __pos,
this->_M_start + __pos + (min) (__n, size() - __pos));
}
public:
int compare(const _Self& __s) const
{ return _M_compare(this->_M_start, this->_M_finish, __s._M_start, __s._M_finish); }
int compare(size_type __pos1, size_type __n1,
const _Self& __s) const {
if (__pos1 > size())
this->_M_throw_out_of_range();
return _M_compare(this->_M_start + __pos1,
this->_M_start + __pos1 + (min) (__n1, size() - __pos1),
__s._M_start, __s._M_finish);
}
int compare(size_type __pos1, size_type __n1,
const _Self& __s,
size_type __pos2, size_type __n2) const {
if (__pos1 > size() || __pos2 > __s.size())
this->_M_throw_out_of_range();
return _M_compare(this->_M_start + __pos1,
this->_M_start + __pos1 + (min) (__n1, size() - __pos1),
__s._M_start + __pos2,
__s._M_start + __pos2 + (min) (__n2, __s.size() - __pos2));
}
int compare(const _CharT* __s) const {
return _M_compare(this->_M_start, this->_M_finish, __s, __s + _Traits::length(__s));
}
int compare(size_type __pos1, size_type __n1, const _CharT* __s) const {
if (__pos1 > size())
this->_M_throw_out_of_range();
return _M_compare(this->_M_start + __pos1,
this->_M_start + __pos1 + (min) (__n1, size() - __pos1),
__s, __s + _Traits::length(__s));
}
int compare(size_type __pos1, size_type __n1, const _CharT* __s,
size_type __n2) const {
if (__pos1 > size())
this->_M_throw_out_of_range();
return _M_compare(this->_M_start + __pos1,
this->_M_start + __pos1 + (min) (__n1, size() - __pos1),
__s, __s + __n2);
}
public:
static int _M_compare(const _CharT* __f1, const _CharT* __l1,
const _CharT* __f2, const _CharT* __l2) {
const ptrdiff_t __n1 = __l1 - __f1;
const ptrdiff_t __n2 = __l2 - __f2;
const int cmp = _Traits::compare(__f1, __f2, (min) (__n1, __n2));
return cmp != 0 ? cmp : (__n1 < __n2 ? -1 : (__n1 > __n2 ? 1 : 0));
}
};
template <class _CharT, class _Traits, class _Alloc> inline basic_string<_CharT,_Traits,_Alloc>
operator+(const basic_string<_CharT,_Traits,_Alloc>& __s,
const basic_string<_CharT,_Traits,_Alloc>& __y)
{
typedef basic_string<_CharT,_Traits,_Alloc> _Str;
typedef typename _Str::_Reserve_t _Reserve_t;
_Str __result = _Str(_Reserve_t(),__s.size() + __y.size());
__result.append(__s);
__result.append(__y);
return __result;
}
template <class _CharT, class _Traits, class _Alloc> inline basic_string<_CharT,_Traits,_Alloc>
operator+(const _CharT* __s,
const basic_string<_CharT,_Traits,_Alloc>& __y) {
typedef basic_string<_CharT,_Traits,_Alloc> _Str;
typedef typename _Str::_Reserve_t _Reserve_t;
const size_t __n = _Traits::length(__s);
_Str __result = _Str(_Reserve_t(), __n + __y.size());
__result.append(__s, __s + __n);
__result.append(__y);
return __result;
}
template <class _CharT, class _Traits, class _Alloc> inline basic_string<_CharT,_Traits,_Alloc>
operator+(_CharT __c,
const basic_string<_CharT,_Traits,_Alloc>& __y) {
typedef basic_string<_CharT,_Traits,_Alloc> _Str;
typedef typename _Str::_Reserve_t _Reserve_t;
_Str __result = _Str(_Reserve_t(), 1 + __y.size());
__result.push_back(__c);
__result.append(__y);
return __result;
}
template <class _CharT, class _Traits, class _Alloc> inline basic_string<_CharT,_Traits,_Alloc>
operator+(const basic_string<_CharT,_Traits,_Alloc>& __x,
const _CharT* __s) {
typedef basic_string<_CharT,_Traits,_Alloc> _Str;
typedef typename _Str::_Reserve_t _Reserve_t;
const size_t __n = _Traits::length(__s);
_Str __result = _Str(_Reserve_t(), __x.size() + __n, __x.get_allocator());
__result.append(__x);
__result.append(__s, __s + __n);
return __result;
}
template <class _CharT, class _Traits, class _Alloc> inline basic_string<_CharT,_Traits,_Alloc>
operator+(const basic_string<_CharT,_Traits,_Alloc>& __x,
const _CharT __c) {
typedef basic_string<_CharT,_Traits,_Alloc> _Str;
typedef typename _Str::_Reserve_t _Reserve_t;
_Str __result = _Str(_Reserve_t(), __x.size() + 1, __x.get_allocator());
__result.append(__x);
__result.push_back(__c);
return __result;
}
template <class _CharT, class _Traits, class _Alloc> inline bool
operator==(const basic_string<_CharT,_Traits,_Alloc>& __x,
const basic_string<_CharT,_Traits,_Alloc>& __y) {
return __x.size() == __y.size() && _Traits::compare(__x.data(), __y.data(), __x.size()) == 0;
}
template <class _CharT, class _Traits, class _Alloc> inline bool
operator==(const _CharT* __s,
const basic_string<_CharT,_Traits,_Alloc>& __y) {
size_t __n = _Traits::length(__s);
return __n == __y.size() && _Traits::compare(__s, __y.data(), __n) == 0;
}
template <class _CharT, class _Traits, class _Alloc> inline bool
operator==(const basic_string<_CharT,_Traits,_Alloc>& __x,
const _CharT* __s) {
size_t __n = _Traits::length(__s);
return __x.size() == __n && _Traits::compare(__x.data(), __s, __n) == 0;
}
template <class _CharT, class _Traits, class _Alloc> inline bool
operator<(const basic_string<_CharT,_Traits,_Alloc>& __x,
const basic_string<_CharT,_Traits,_Alloc>& __y) {
return basic_string<_CharT,_Traits,_Alloc> ::_M_compare(__x.begin(), __x.end(),
__y.begin(), __y.end()) < 0;
}
template <class _CharT, class _Traits, class _Alloc> inline bool
operator<(const _CharT* __s,
const basic_string<_CharT,_Traits,_Alloc>& __y) {
size_t __n = _Traits::length(__s);
return basic_string<_CharT,_Traits,_Alloc> ::_M_compare(__s, __s + __n, __y.begin(), __y.end()) < 0;
}
template <class _CharT, class _Traits, class _Alloc> inline bool
operator<(const basic_string<_CharT,_Traits,_Alloc>& __x,
const _CharT* __s) {
size_t __n = _Traits::length(__s);
return basic_string<_CharT,_Traits,_Alloc> ::_M_compare(__x.begin(), __x.end(), __s, __s + __n) < 0;
}
template <class _CharT, class _Traits, class _Alloc> inline bool
operator!=(const basic_string<_CharT,_Traits,_Alloc>& __x,
const basic_string<_CharT,_Traits,_Alloc>& __y) {
return !(__x == __y);
}
template <class _CharT, class _Traits, class _Alloc> inline bool
operator>(const basic_string<_CharT,_Traits,_Alloc>& __x,
const basic_string<_CharT,_Traits,_Alloc>& __y) {
return __y < __x;
}
template <class _CharT, class _Traits, class _Alloc> inline bool
operator<=(const basic_string<_CharT,_Traits,_Alloc>& __x,
const basic_string<_CharT,_Traits,_Alloc>& __y) {
return !(__y < __x);
}
template <class _CharT, class _Traits, class _Alloc> inline bool
operator>=(const basic_string<_CharT,_Traits,_Alloc>& __x,
const basic_string<_CharT,_Traits,_Alloc>& __y) {
return !(__x < __y);
}
template <class _CharT, class _Traits, class _Alloc> inline bool
operator!=(const _CharT* __s,
const basic_string<_CharT,_Traits,_Alloc>& __y) {
return !(__s == __y);
}
template <class _CharT, class _Traits, class _Alloc> inline bool
operator!=(const basic_string<_CharT,_Traits,_Alloc>& __x,
const _CharT* __s) {
return !(__x == __s);
}
template <class _CharT, class _Traits, class _Alloc> inline bool
operator>(const _CharT* __s,
const basic_string<_CharT,_Traits,_Alloc>& __y) {
return __y < __s;
}
template <class _CharT, class _Traits, class _Alloc> inline bool
operator>(const basic_string<_CharT,_Traits,_Alloc>& __x,
const _CharT* __s) {
return __s < __x;
}
template <class _CharT, class _Traits, class _Alloc> inline bool
operator<=(const _CharT* __s,
const basic_string<_CharT,_Traits,_Alloc>& __y) {
return !(__y < __s);
}
template <class _CharT, class _Traits, class _Alloc> inline bool
operator<=(const basic_string<_CharT,_Traits,_Alloc>& __x,
const _CharT* __s) {
return !(__s < __x);
}
template <class _CharT, class _Traits, class _Alloc> inline bool
operator>=(const _CharT* __s,
const basic_string<_CharT,_Traits,_Alloc>& __y) {
return !(__s < __y);
}
template <class _CharT, class _Traits, class _Alloc> inline bool
operator>=(const basic_string<_CharT,_Traits,_Alloc>& __x,
const _CharT* __s) {
return !(__x < __s);
}
template <class _CharT, class _Traits, class _Alloc> inline void
swap(basic_string<_CharT,_Traits,_Alloc>& __x,
basic_string<_CharT,_Traits,_Alloc>& __y) {
__x.swap(__y);
}
template <class _CharT, class _Traits, class _Alloc> void _S_string_copy(const basic_string<_CharT,_Traits,_Alloc>& __s,
_CharT* __buf,
size_t __n);
}
namespace _STL {
template <class _CharT, class _Traits, class _Alloc> void basic_string<_CharT,_Traits,_Alloc>::reserve(size_type __res_arg) {
if (__res_arg > max_size())
this->_M_throw_length_error();
size_type __n = (max)(__res_arg, size()) + 1;
pointer __new_start = this->_M_end_of_storage.allocate(__n);
pointer __new_finish = __new_start;
try {
__new_finish = uninitialized_copy(this->_M_start, this->_M_finish, __new_start);
_M_construct_null(__new_finish);
}
catch(...) { (_Destroy(__new_start, __new_finish), this->_M_end_of_storage.deallocate(__new_start, __n)); throw; };
_Destroy(this->_M_start, this->_M_finish + 1);
this->_M_deallocate_block();
this->_M_start = __new_start;
this->_M_finish = __new_finish;
this->_M_end_of_storage._M_data = __new_start + __n;
}
template <class _CharT, class _Traits, class _Alloc> basic_string<_CharT,_Traits,_Alloc>& basic_string<_CharT,_Traits,_Alloc>::append(size_type __n, _CharT __c) {
if (__n > max_size() || size() > max_size() - __n)
this->_M_throw_length_error();
if (size() + __n > capacity())
reserve(size() + (max)(size(), __n));
if (__n > 0) {
uninitialized_fill_n(this->_M_finish + 1, __n - 1, __c);
try {
_M_construct_null(this->_M_finish + __n);
}
catch(...) { _Destroy(this->_M_finish + 1, this->_M_finish + __n); throw; };
_Traits::assign(*end(), __c);
this->_M_finish += __n;
}
return *this;
}
template <class _CharT, class _Traits, class _Alloc>
basic_string<_CharT,_Traits,_Alloc>&
basic_string<_CharT,_Traits,_Alloc>::assign(size_type __n, _CharT __c) {
if (__n <= size()) {
_Traits::assign(this->_M_start, __n, __c);
erase(begin() + __n, end());
}
else {
_Traits::assign(this->_M_start, size(), __c);
append(__n - size(), __c);
}
return *this;
}
template <class _CharT, class _Traits, class _Alloc> _CharT*
basic_string<_CharT,_Traits,_Alloc> ::_M_insert_aux(_CharT* __p,
_CharT __c)
{
pointer __new_pos = __p;
if (this->_M_finish + 1 < this->_M_end_of_storage._M_data) {
_M_construct_null(this->_M_finish + 1);
_Traits::move(__p + 1, __p, this->_M_finish - __p);
_Traits::assign(*__p, __c);
++this->_M_finish;
}
else {
const size_type __old_len = size();
const size_type __len = __old_len +
(max)(__old_len, static_cast<size_type>(1)) + 1;
pointer __new_start = this->_M_end_of_storage.allocate(__len);
pointer __new_finish = __new_start;
try {
__new_pos = uninitialized_copy(this->_M_start, __p, __new_start);
_Construct(__new_pos, __c);
__new_finish = __new_pos + 1;
__new_finish = uninitialized_copy(__p, this->_M_finish, __new_finish);
_M_construct_null(__new_finish);
}
catch(...) { (_Destroy(__new_start,__new_finish), this->_M_end_of_storage.deallocate(__new_start,__len)); throw; };
_Destroy(this->_M_start, this->_M_finish + 1);
this->_M_deallocate_block();
this->_M_start = __new_start;
this->_M_finish = __new_finish;
this->_M_end_of_storage._M_data = __new_start + __len;
}
return __new_pos;
}
template <class _CharT, class _Traits, class _Alloc> void basic_string<_CharT,_Traits,_Alloc>::insert(iterator __position,
size_t __n, _CharT __c)
{
if (__n != 0) {
if (size_type(this->_M_end_of_storage._M_data - this->_M_finish) >= __n + 1) {
const size_type __elems_after = this->_M_finish - __position;
pointer __old_finish = this->_M_finish;
if (__elems_after >= __n) {
uninitialized_copy((this->_M_finish - __n) + 1, this->_M_finish + 1,
this->_M_finish + 1);
this->_M_finish += __n;
_Traits::move(__position + __n,
__position, (__elems_after - __n) + 1);
_Traits::assign(__position, __n, __c);
}
else {
uninitialized_fill_n(this->_M_finish + 1, __n - __elems_after - 1, __c);
this->_M_finish += __n - __elems_after;
try {
uninitialized_copy(__position, __old_finish + 1, this->_M_finish);
this->_M_finish += __elems_after;
}
catch(...) { (_Destroy(__old_finish + 1, this->_M_finish), this->_M_finish = __old_finish); throw; };
_Traits::assign(__position, __elems_after + 1, __c);
}
}
else {
const size_type __old_size = size();
const size_type __len = __old_size + (max)(__old_size, __n) + 1;
pointer __new_start = this->_M_end_of_storage.allocate(__len);
pointer __new_finish = __new_start;
try {
__new_finish = uninitialized_copy(this->_M_start, __position, __new_start);
__new_finish = uninitialized_fill_n(__new_finish, __n, __c);
__new_finish = uninitialized_copy(__position, this->_M_finish,
__new_finish);
_M_construct_null(__new_finish);
}
catch(...) { (_Destroy(__new_start,__new_finish), this->_M_end_of_storage.deallocate(__new_start,__len)); throw; };
_Destroy(this->_M_start, this->_M_finish + 1);
this->_M_deallocate_block();
this->_M_start = __new_start;
this->_M_finish = __new_finish;
this->_M_end_of_storage._M_data = __new_start + __len;
}
}
}
template <class _CharT, class _Traits, class _Alloc> basic_string<_CharT,_Traits,_Alloc>& basic_string<_CharT,_Traits,_Alloc> ::replace(iterator __first, iterator __last, size_type __n, _CharT __c)
{
size_type __len = (size_type)(__last - __first);
if (__len >= __n) {
_Traits::assign(__first, __n, __c);
erase(__first + __n, __last);
}
else {
_Traits::assign(__first, __len, __c);
insert(__last, __n - __len, __c);
}
return *this;
}
template <class _CharT, class _Traits, class _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
{
if (__pos + __n > size())
return npos;
else {
const const_pointer __result =
_STL::search((const _CharT*)this->_M_start + __pos, (const _CharT*)this->_M_finish,
__s, __s + __n, _Eq_traits<_Traits>());
return __result != this->_M_finish ? __result - this->_M_start : npos;
}
}
template <class _CharT, class _Traits, class _Alloc> typename basic_string<_CharT,_Traits,_Alloc>::size_type
basic_string<_CharT,_Traits,_Alloc> ::find(_CharT __c, size_type __pos) const
{
if (__pos >= size())
return npos;
else {
const const_pointer __result =
_STL::find_if((const _CharT*)this->_M_start + __pos, (const _CharT*)this->_M_finish,
_Eq_char_bound<_Traits>(__c));
return __result != this->_M_finish ? __result - this->_M_start : npos;
}
}
template <class _CharT, class _Traits, class _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_t __len = size();
if (__n > __len)
return npos;
else if (__n == 0)
return (min) (__len, __pos);
else {
const_pointer __last = this->_M_start + (min) (__len - __n, __pos) + __n;
const_pointer __result = _STL::find_end((const_pointer)this->_M_start, __last,
__s, __s + __n,
_Eq_traits<_Traits>());
return __result != __last ? __result - this->_M_start : npos;
}
}
template <class _CharT, class _Traits, class _Alloc> typename basic_string<_CharT,_Traits,_Alloc>::size_type
basic_string<_CharT,_Traits,_Alloc> ::rfind(_CharT __c, size_type __pos) const
{
const size_type __len = size();
if (__len < 1)
return npos;
else {
const const_iterator __last = begin() + (min) (__len - 1, __pos) + 1;
const_reverse_iterator __rresult =
_STL::find_if(const_reverse_iterator(__last), rend(),
_Eq_char_bound<_Traits>(__c));
return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos;
}
}
template <class _CharT, class _Traits, class _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
{
if (__pos >= size())
return npos;
else {
const_iterator __result = __find_first_of(begin() + __pos, end(),
__s, __s + __n,
_Eq_traits<_Traits>());
return __result != end() ? __result - begin() : npos;
}
}
template <class _CharT, class _Traits, class _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
{
const size_type __len = size();
if (__len < 1)
return npos;
else {
const const_iterator __last = begin() + (min) (__len - 1, __pos) + 1;
const const_reverse_iterator __rresult =
__find_first_of(const_reverse_iterator(__last), rend(),
__s, __s + __n,
_Eq_traits<_Traits>());
return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos;
}
}
template <class _CharT, class _Traits, class _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
{
typedef typename _Traits::char_type _CharType;
if (__pos > size())
return npos;
else {
const_pointer __result = _STL::find_if((const _CharT*)this->_M_start + __pos,
(const _CharT*)this->_M_finish,
_Not_within_traits<_Traits>((const _CharType*)__s,
(const _CharType*)__s + __n));
return __result != this->_M_finish ? __result - this->_M_start : npos;
}
}
template <class _CharT, class _Traits, class _Alloc> typename basic_string<_CharT,_Traits,_Alloc>::size_type
basic_string<_CharT,_Traits,_Alloc> ::find_first_not_of(_CharT __c, size_type __pos) const
{
if (__pos > size())
return npos;
else {
const_pointer __result = _STL::find_if((const _CharT*)this->_M_start + __pos, (const _CharT*)this->_M_finish,
_Neq_char_bound<_Traits>(__c));
return __result != this->_M_finish ? __result - this->_M_start : npos;
}
}
template <class _CharT, class _Traits, class _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
{
typedef typename _Traits::char_type _CharType;
const size_type __len = size();
if (__len < 1)
return npos;
else {
const_iterator __last = begin() + (min) (__len - 1, __pos) + 1;
const_reverse_iterator __rlast = const_reverse_iterator(__last);
const_reverse_iterator __rresult =
_STL::find_if(__rlast, rend(),
_Not_within_traits<_Traits>((const _CharType*)__s,
(const _CharType*)__s + __n));
return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos;
}
}
template <class _CharT, class _Traits, class _Alloc> typename basic_string<_CharT,_Traits,_Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc> ::find_last_not_of(_CharT __c, size_type __pos) const
{
const size_type __len = size();
if (__len < 1)
return npos;
else {
const_iterator __last = begin() + (min) (__len - 1, __pos) + 1;
const_reverse_iterator __rlast = const_reverse_iterator(__last);
const_reverse_iterator __rresult =
_STL::find_if(__rlast, rend(),
_Neq_char_bound<_Traits>(__c));
return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos;
}
}
template <class _CharT, class _Traits, class _Alloc> void _S_string_copy(const basic_string<_CharT,_Traits,_Alloc>& __s,
_CharT* __buf,
size_t __n)
{
if (__n > 0) {
__n = (min) (__n - 1, __s.size());
_STL::copy(__s.begin(), __s.begin() + __n, __buf);
__buf[__n] = _CharT();
}
}
}
namespace _STL {
void __stl_throw_range_error(const char* __msg);
void __stl_throw_out_of_range(const char* __msg);
void __stl_throw_length_error(const char* __msg);
void __stl_throw_invalid_argument(const char* __msg);
void __stl_throw_overflow_error(const char* __msg);
}
namespace _STL {
template <class _Tp, class _Alloc> void _String_base<_Tp,_Alloc>::_M_throw_length_error() const {
__stl_throw_length_error("basic_string");
}
template <class _Tp, class _Alloc> void _String_base<_Tp, _Alloc>::_M_throw_out_of_range() const {
__stl_throw_out_of_range("basic_string");
}
template <class _Tp, class _Alloc> void _String_base<_Tp, _Alloc>::_M_allocate_block(size_t __n) {
if ((__n <= (max_size()+1)) && (__n>0)){
_M_start = _M_end_of_storage.allocate(__n);
_M_finish = _M_start;
_M_end_of_storage._M_data = _M_start + __n;
}
else
_M_throw_length_error();
}
template <class _CharT, class _Traits, class _Alloc> basic_string<_CharT, _Traits, _Alloc>::basic_string()
: _String_base<_CharT,_Alloc>(allocator_type()) {
this->_M_start = this->_M_end_of_storage.allocate(8);
this->_M_finish = this->_M_start;
this->_M_end_of_storage._M_data = this->_M_start + 8;
_M_terminate_string();
}
template <class _CharT, class _Traits, class _Alloc> basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT* __s,
const allocator_type& __a)
: _String_base<_CharT,_Alloc>(__a)
{
_M_range_initialize(__s, __s + traits_type::length(__s));
}
template <class _CharT, class _Traits, class _Alloc> basic_string<_CharT, _Traits, _Alloc>::basic_string(const basic_string<_CharT, _Traits, _Alloc> & __s)
: _String_base<_CharT,_Alloc>(__s.get_allocator())
{
_M_range_initialize(__s._M_start, __s._M_finish);
}
}
namespace _STL {
template <class _CharT, class _Traits, class _Alloc>
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
const basic_string<_CharT,_Traits,_Alloc>& __s);
template <class _CharT, class _Traits, class _Alloc>
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
basic_string<_CharT,_Traits,_Alloc>& __s);
template <class _CharT, class _Traits, class _Alloc>
basic_istream<_CharT, _Traits>&
getline(basic_istream<_CharT, _Traits>& __is,
basic_string<_CharT,_Traits,_Alloc>& __s,
_CharT __delim);
template <class _CharT, class _Traits, class _Alloc>
inline basic_istream<_CharT, _Traits>&
getline(basic_istream<_CharT, _Traits>& __is,
basic_string<_CharT,_Traits,_Alloc>& __s)
{
return getline(__is, __s, __is.widen('\n'));
}
template <class _CharT, class _Traits>
bool
__stlp_string_fill(basic_ostream<_CharT, _Traits>& __os,
basic_streambuf<_CharT, _Traits>* __buf,
size_t __n);
}
namespace _STL {
template <class _CharT, class _Traits>
bool
__stlp_string_fill(basic_ostream<_CharT, _Traits>& __os,
basic_streambuf<_CharT, _Traits>* __buf,
size_t __n)
{
_CharT __f = __os.fill();
size_t __i;
bool __ok = true;
for (__i = 0; __i < __n; ++__i)
__ok = __ok && !_Traits::eq_int_type(__buf->sputc(__f), _Traits::eof());
return __ok;
}
template <class _CharT, class _Traits, class _Alloc>
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
const basic_string<_CharT,_Traits,_Alloc>& __s)
{
typedef basic_ostream<_CharT, _Traits> __ostream;
typename __ostream::sentry __sentry(__os);
bool __ok = false;
if (__sentry) {
__ok = true;
size_t __n = __s.size();
size_t __pad_len = 0;
const bool __left = (__os.flags() & __ostream::left) != 0;
const size_t __w = __os.width(0);
basic_streambuf<_CharT, _Traits>* __buf = __os.rdbuf();
if (__n < __w) {
__pad_len = __w - __n;
}
if (!__left)
__ok = __stlp_string_fill(__os, __buf, __pad_len);
__ok = __ok && (__buf->sputn(__s.data(), streamsize(__n)) == streamsize(__n));
if (__left)
__ok = __ok && __stlp_string_fill(__os, __buf, __pad_len);
}
if (!__ok)
__os.setstate(__ostream::failbit);
return __os;
}
template <class _CharT, class _Traits, class _Alloc>
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
basic_string<_CharT,_Traits, _Alloc>& __s)
{
typedef basic_istream<_CharT, _Traits> __istream;
typename __istream::sentry __sentry(__is);
if (__sentry) {
basic_streambuf<_CharT, _Traits>* __buf = __is.rdbuf();
typedef ctype<_CharT> _C_type;
const _C_type& _Ctype = *(const _C_type*)__is._M_ctype_facet();
__s.clear();
size_t __n = __is.width(0);
if (__n == 0)
__n = static_cast<size_t>(-1);
else
__s.reserve(__n);
while (__n-- > 0) {
typename _Traits::int_type __c1 = __buf->sbumpc();
if (_Traits::eq_int_type(__c1, _Traits::eof())) {
__is.setstate(__istream::eofbit);
break;
}
else {
_CharT __c = _Traits::to_char_type(__c1);
if (_Ctype.is(_C_type::space, __c)) {
if (_Traits::eq_int_type(__buf->sputbackc(__c), _Traits::eof()))
__is.setstate(__istream::failbit);
break;
}
else
__s.push_back(__c);
}
}
if (__s.size() == 0)
__is.setstate(__istream::failbit);
}
else
__is.setstate(__istream::failbit);
return __is;
}
template <class _CharT, class _Traits, class _Alloc>
basic_istream<_CharT, _Traits>&
getline(basic_istream<_CharT, _Traits>& __is,
basic_string<_CharT,_Traits,_Alloc>& __s,
_CharT __delim)
{
typedef basic_istream<_CharT, _Traits> __istream;
size_t __nread = 0;
typename basic_istream<_CharT, _Traits>::sentry __sentry(__is, true);
if (__sentry) {
basic_streambuf<_CharT, _Traits>* __buf = __is.rdbuf();
__s.clear();
while (__nread < __s.max_size()) {
int __c1 = __buf->sbumpc();
if (_Traits::eq_int_type(__c1, _Traits::eof())) {
__is.setstate(__istream::eofbit);
break;
}
else {
++__nread;
_CharT __c = _Traits::to_char_type(__c1);
if (!_Traits::eq(__c, __delim))
__s.push_back(__c);
else
break;
}
}
}
if (__nread == 0 || __nread >= __s.max_size())
__is.setstate(__istream::failbit);
return __is;
}
}
namespace _STL {
template <class _Key> struct hash { };
inline size_t __stl_hash_string(const char* __s)
{
unsigned long __h = 0;
for ( ; *__s; ++__s)
__h = 5*__h + *__s;
return size_t(__h);
}
template<> struct hash<char*>
{
size_t operator()(const char* __s) const { return __stl_hash_string(__s); }
};
template<> struct hash<const char*>
{
size_t operator()(const char* __s) const { return __stl_hash_string(__s); }
};
template<> struct hash<char> {
size_t operator()(char __x) const { return __x; }
};
template<> struct hash<unsigned char> {
size_t operator()(unsigned char __x) const { return __x; }
};
template<> struct hash<signed char> {
size_t operator()(unsigned char __x) const { return __x; }
};
template<> struct hash<short> {
size_t operator()(short __x) const { return __x; }
};
template<> struct hash<unsigned short> {
size_t operator()(unsigned short __x) const { return __x; }
};
template<> struct hash<int> {
size_t operator()(int __x) const { return __x; }
};
template<> struct hash<unsigned int> {
size_t operator()(unsigned int __x) const { return __x; }
};
template<> struct hash<long> {
size_t operator()(long __x) const { return __x; }
};
template<> struct hash<unsigned long> {
size_t operator()(unsigned long __x) const { return __x; }
};
template<> struct hash<long long> {
size_t operator()(long x) const { return x; }
};
template<> struct hash<unsigned long long> {
size_t operator()(unsigned long x) const { return x; }
};
}
namespace _STL {
template <class _CharT, class _Traits, class _Alloc>
inline size_t
__stl_string_hash(const basic_string<_CharT,_Traits,_Alloc>& __s) {
unsigned long __h = 0;
typedef typename basic_string<_CharT,_Traits,_Alloc>::const_pointer const_ptr;
size_t __len = __s.size();
const _CharT* __data = __s.data();
for ( size_t __i = 0; __i < __len; ++__i)
__h = 5*__h + __data[__i];
return size_t(__h);
}
template <class _CharT, class _Traits, class _Alloc>
struct hash<basic_string<_CharT,_Traits,_Alloc> > {
size_t operator()(const basic_string<_CharT,_Traits,_Alloc>& __s) const
{ return __stl_string_hash(__s); }
};
}
namespace _STL {}
namespace std {
using namespace _STL;
}
namespace _STL {
using __std_alias::exception;
using __std_alias::bad_exception;
using __std_alias::unexpected;
using __std_alias::unexpected_handler;
using __std_alias::set_unexpected;
using __std_alias::terminate;
using __std_alias::terminate_handler;
using __std_alias::set_terminate;
}
namespace _STL {
using __std_alias::exception;
class __Named_exception : public exception {
public:
__Named_exception(const string& __str)
;
const char* what() const throw();
~__Named_exception() throw();
private:
enum { _S_bufsize = 256 };
char _M_name[_S_bufsize];
};
class logic_error : public __Named_exception {
public:
logic_error(const string& __s) : __Named_exception(__s) {}
~logic_error() throw();
};
class runtime_error : public __Named_exception {
public:
runtime_error(const string& __s) : __Named_exception(__s) {}
~runtime_error() throw();
};
class domain_error : public logic_error {
public:
domain_error(const string& __arg) : logic_error(__arg) {}
~domain_error() throw();
};
class invalid_argument : public logic_error {
public:
invalid_argument(const string& __arg) : logic_error(__arg) {}
~invalid_argument() throw();
};
class length_error : public logic_error {
public:
length_error(const string& __arg) : logic_error(__arg) {}
~length_error() throw();
};
class out_of_range : public logic_error {
public:
out_of_range(const string& __arg) : logic_error(__arg) {}
~out_of_range() throw();
};
class range_error : public runtime_error {
public:
range_error(const string& __arg) : runtime_error(__arg) {}
~range_error() throw();
};
class overflow_error : public runtime_error {
public:
overflow_error(const string& __arg) : runtime_error(__arg) {}
~overflow_error() throw();
};
class underflow_error : public runtime_error {
public:
underflow_error(const string& __arg) : runtime_error(__arg) {}
~underflow_error() throw();
};
}
namespace _STL {
class _Locale_impl;
class _Locale;
class locale;
class ios_base;
template <class _CharT>
bool
__locale_do_operator_call (const locale* __that,
const basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> >& __x,
const basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> >& __y);
class locale {
public:
class facet : private _Refcount_Base {
protected:
explicit facet(size_t __no_del = 0) : _Refcount_Base(1), _M_delete(__no_del == 0) {}
virtual ~facet();
friend class locale;
friend class _Locale_impl;
friend class _Locale;
private:
facet(const facet& __f) : _Refcount_Base(1), _M_delete(__f._M_delete == 0) {};
void operator=(const facet&);
private:
const bool _M_delete;
};
class
id {
friend class locale;
friend class _Locale_impl;
public:
size_t _M_index;
static size_t _S_max;
};
typedef int category;
static const category
none = 0x000,
collate = 0x010,
ctype = 0x020,
monetary = 0x040,
numeric = 0x100,
time = 0x200,
messages = 0x400,
all = collate | ctype | monetary | numeric | time | messages
;
locale();
locale(const locale&) ;
explicit locale(const char *);
locale(const locale&, const char*, category);
locale(_Locale_impl*);
locale(_Locale_impl*, bool);
public:
template <class _Facet>
locale(const locale& __loc, _Facet* __f) : _M_impl(0)
{
new(this) locale(__loc._M_impl, __f != 0);
if (__f != 0)
this->_M_insert(__f, _Facet::id);
}
locale(const locale&, const locale&, category);
~locale() ;
const locale& operator=(const locale&) ;
template <class _Facet> locale combine(const locale& __loc) {
locale __result(__loc._M_impl, true);
if (facet* __f = __loc._M_get_facet(_Facet::id)) {
__result._M_insert(__f, _Facet::id);
__f->_M_incr();
}
else
_M_throw_runtime_error();
return __result;
}
string name() const;
bool operator==(const locale&) const;
bool operator!=(const locale&) const;
template <class _CharT, class _Traits, class _Alloc>
bool operator()(const basic_string<_CharT, _Traits, _Alloc>& __x,
const basic_string<_CharT, _Traits, _Alloc>& __y) const {
return __locale_do_operator_call(this, __x, __y);
}
static locale global(const locale&);
static const locale& classic();
public:
facet* _M_get_facet(const id&) const;
facet* _M_use_facet(const id&) const;
static void _M_throw_runtime_error(const char* = 0);
static void _S_initialize();
static void _S_uninitialize();
private:
void _M_insert(facet* __f, id& __id);
friend class _Locale_impl;
friend class _Locale;
friend class ios_base;
private:
_Locale_impl* _M_impl;
};
template <class _Facet> inline const _Facet& use_facet(const locale& __loc)
{
return *static_cast<const _Facet*>(__loc._M_use_facet(_Facet::id));
}
template <class _Facet> inline bool has_facet(const locale& __loc)
{
return (__loc._M_get_facet(_Facet::id) != 0);
}
}
namespace _STL {
class ios_base {
public:
class failure : public __Named_exception {
public:
explicit failure(const string&);
virtual ~failure() throw();
};
typedef int fmtflags;
typedef int iostate;
typedef int openmode;
typedef int seekdir;
typedef fmtflags fmt_flags;
static const int
left = 0x0001,
right = 0x0002,
internal = 0x0004,
dec = 0x0008,
hex = 0x0010,
oct = 0x0020,
fixed = 0x0040,
scientific = 0x0080,
boolalpha = 0x0100,
showbase = 0x0200,
showpoint = 0x0400,
showpos = 0x0800,
skipws = 0x1000,
unitbuf = 0x2000,
uppercase = 0x4000,
adjustfield = left | right | internal,
basefield = dec | hex | oct,
floatfield = scientific | fixed,
goodbit = 0x00,
badbit = 0x01,
eofbit = 0x02,
failbit = 0x04,
__default_mode = 0x0,
app = 0x01,
ate = 0x02,
binary = 0x04,
in = 0x08,
out = 0x10,
trunc = 0x20,
beg = 0x01,
cur = 0x02,
end = 0x04
;
public:
fmtflags flags() const { return _M_fmtflags; }
fmtflags flags(fmtflags __flags) {
fmtflags __tmp = _M_fmtflags;
_M_fmtflags = __flags;
return __tmp;
}
fmtflags setf(fmtflags __flag) {
fmtflags __tmp = _M_fmtflags;
_M_fmtflags |= __flag;
return __tmp;
}
fmtflags setf(fmtflags __flag, fmtflags __mask) {
fmtflags __tmp = _M_fmtflags;
_M_fmtflags &= ~__mask;
_M_fmtflags |= __flag & __mask;
return __tmp;
}
void unsetf(fmtflags __mask) { _M_fmtflags &= ~__mask; }
streamsize precision() const { return _M_precision; }
streamsize precision(streamsize __newprecision) {
streamsize __tmp = _M_precision;
_M_precision = __newprecision;
return __tmp;
}
streamsize width() const { return _M_width; }
streamsize width(streamsize __newwidth) {
streamsize __tmp = _M_width;
_M_width = __newwidth;
return __tmp;
}
public:
locale imbue(const locale&);
locale getloc() const { return _M_locale; }
public:
static int xalloc();
long& iword(int __index);
void*& pword(int __index);
public:
virtual ~ios_base();
public:
enum event { erase_event, imbue_event, copyfmt_event };
typedef void (*event_callback)(event, ios_base&, int __index);
void register_callback(event_callback __fn, int __index);
public:
static bool sync_with_stdio(bool __sync = true);
public:
operator void*() const { return !fail() ? (void*) const_cast<ios_base*>(this) : (void*) 0; }
bool operator!() const { return fail(); }
iostate rdstate() const { return _M_iostate; }
bool good() const { return _M_iostate == 0; }
bool eof() const { return (_M_iostate & eofbit) != 0; }
bool fail() const { return (_M_iostate & (failbit | badbit)) != 0; }
bool bad() const { return (_M_iostate & badbit) != 0; }
protected:
void _M_copy_state(const ios_base& __x);
void _M_setstate_nothrow(iostate __state) { _M_iostate |= __state; }
void _M_clear_nothrow(iostate __state) { _M_iostate = __state; }
iostate _M_get_exception_mask() const { return _M_exception_mask; }
void _M_set_exception_mask(iostate __mask) { _M_exception_mask = __mask; }
void _M_check_exception_mask() {
if (_M_iostate & _M_exception_mask)
_M_throw_failure();
}
void _M_invoke_callbacks(event);
void _M_throw_failure();
ios_base();
protected:
static void _S_initialize();
static void _S_uninitialize();
static bool _S_was_synced;
private:
ios_base(const ios_base&);
void operator=(const ios_base&);
private:
fmtflags _M_fmtflags;
iostate _M_iostate;
openmode _M_openmode;
seekdir _M_seekdir;
iostate _M_exception_mask;
streamsize _M_precision;
streamsize _M_width;
locale _M_locale;
pair<event_callback, int>* _M_callbacks;
size_t _M_num_callbacks;
size_t _M_callback_index;
long* _M_iwords;
size_t _M_num_iwords;
void** _M_pwords;
size_t _M_num_pwords;
static int _S_index;
protected:
locale::facet* _M_cached_ctype;
locale::facet* _M_cached_numpunct;
string _M_cached_grouping;
public:
const locale::facet* _M_ctype_facet() const { return _M_cached_ctype; }
const locale::facet* _M_numpunct_facet() const { return _M_cached_numpunct; }
const string& _M_grouping() const { return _M_cached_grouping; }
public:
class Init {
public:
Init();
~Init();
private:
static long _S_count;
friend class ios_base;
};
class _Loc_init {
public:
_Loc_init();
~_Loc_init();
private:
static long _S_count;
friend class ios_base;
};
friend class Init;
public:
typedef iostate io_state;
typedef openmode open_mode;
typedef seekdir seek_dir;
typedef _STL::streamoff streamoff;
typedef _STL::streampos streampos;
};
template <class Facet>
locale::facet* _M_get_facet(ios_base& __i, Facet*)
{
}
inline ios_base& boolalpha(ios_base& __s)
{ __s.setf(ios_base::boolalpha); return __s;}
inline ios_base& noboolalpha(ios_base& __s)
{ __s.unsetf(ios_base::boolalpha); return __s;}
inline ios_base& showbase(ios_base& __s)
{ __s.setf(ios_base::showbase); return __s;}
inline ios_base& noshowbase(ios_base& __s)
{ __s.unsetf(ios_base::showbase); return __s;}
inline ios_base& showpoint(ios_base& __s)
{ __s.setf(ios_base::showpoint); return __s;}
inline ios_base& noshowpoint(ios_base& __s)
{ __s.unsetf(ios_base::showpoint); return __s;}
inline ios_base& showpos(ios_base& __s)
{ __s.setf(ios_base::showpos); return __s;}
inline ios_base& noshowpos(ios_base& __s)
{ __s.unsetf(ios_base::showpos); return __s;}
inline ios_base& skipws(ios_base& __s)
{ __s.setf(ios_base::skipws); return __s;}
inline ios_base& noskipws(ios_base& __s)
{ __s.unsetf(ios_base::skipws); return __s;}
inline ios_base& uppercase(ios_base& __s)
{ __s.setf(ios_base::uppercase); return __s;}
inline ios_base& nouppercase(ios_base& __s)
{ __s.unsetf(ios_base::uppercase); return __s;}
inline ios_base& unitbuf(ios_base& __s)
{ __s.setf(ios_base::unitbuf); return __s;}
inline ios_base& nounitbuf(ios_base& __s)
{ __s.unsetf(ios_base::unitbuf); return __s;}
inline ios_base& internal(ios_base& __s)
{ __s.setf(ios_base::internal, ios_base::adjustfield); return __s; }
inline ios_base& left(ios_base& __s)
{ __s.setf(ios_base::left, ios_base::adjustfield); return __s; }
inline ios_base& right(ios_base& __s)
{ __s.setf(ios_base::right, ios_base::adjustfield); return __s; }
inline ios_base& dec(ios_base& __s)
{ __s.setf(ios_base::dec, ios_base::basefield); return __s; }
inline ios_base& hex(ios_base& __s)
{ __s.setf(ios_base::hex, ios_base::basefield); return __s; }
inline ios_base& oct(ios_base& __s)
{ __s.setf(ios_base::oct, ios_base::basefield); return __s; }
inline ios_base& fixed(ios_base& __s)
{ __s.setf(ios_base::fixed, ios_base::floatfield); return __s; }
inline ios_base& scientific(ios_base& __s)
{ __s.setf(ios_base::scientific, ios_base::floatfield); return __s; }
}
struct _Locale_ctype;
struct _Locale_numeric;
struct _Locale_time;
struct _Locale_collate;
struct _Locale_monetary;
struct _Locale_messages;
namespace _STL {
class ctype_base {
public:
enum mask {
space = _ISspace,
print = _ISprint,
cntrl = _IScntrl,
upper = _ISupper,
lower = _ISlower,
alpha = _ISalpha,
digit = _ISdigit,
punct = _ISpunct,
xdigit = _ISxdigit,
alnum = alpha | digit,
graph = alnum | punct
};
};
template <class charT> class ctype {};
template <class charT> class ctype_byname {};
template<>
class ctype<char> : public locale::facet, public ctype_base
{
friend class ctype<wchar_t>;
friend class _Locale;
public:
typedef char char_type;
explicit ctype(const mask* __tab = 0, bool __del = false, size_t __refs = 0);
bool is(mask __m, char __c) const
{ return ((*(_M_ctype_table+(unsigned char)__c)) & __m) != 0; }
const char* is(const char* __low, const char* __high, mask* __vec) const {
for (const char* __p = __low;__p != __high; ++__p, ++__vec) {
*__vec = _M_ctype_table[(unsigned char)*__p];
}
return __high;
}
const char* scan_is(mask __m, const char* __low, const char* __high) const;
const char* scan_not(mask __m, const char* __low, const char* __high) const;
char (toupper)(char __c) const { return do_toupper(__c); }
const char* (toupper)(char* __low, const char* __high) const {
return do_toupper(__low, __high);
}
char (tolower)(char __c) const { return do_tolower(__c); }
const char* (tolower)(char* __low, const char* __high) const {
return do_tolower(__low, __high);
}
char widen(char __c) const { return do_widen(__c); }
const char* widen(const char* __low, const char* __high, char* __to) const {
return do_widen(__low, __high, __to);
}
char narrow(char __c, char __dfault) const {
return do_narrow(__c, __dfault);
}
const char* narrow(const char* __low, const char* __high,
char __dfault, char* __to) const {
return do_narrow(__low, __high, __dfault, __to);
}
static locale::id id;
static const size_t table_size = 256;
protected:
const mask* table() const {return _M_ctype_table;}
static const mask* classic_table() { return & _S_classic_table [1]; }
~ctype();
virtual char do_toupper(char __c) const;
virtual char do_tolower(char __c) const;
virtual const char* do_toupper(char* __low, const char* __high) const;
virtual const char* do_tolower(char* __low, const char* __high) const;
virtual char do_widen(char __c) const;
virtual const char* do_widen(const char* __low, const char* __high,
char* __to) const;
virtual char do_narrow(char __c, char ) const;
virtual const char* do_narrow(const char* __low, const char* __high,
char , char* __to) const;
private:
struct _Is_mask {
mask __m;
_Is_mask(mask __x): __m(__x) {}
bool operator()(char __c) {return (__m & (unsigned char) __c) != 0;}
};
static const mask _S_classic_table[257 ];
const mask* _M_ctype_table;
bool _M_delete;
static const unsigned char _S_upper[256 ];
static const unsigned char _S_lower[256 ];
};
template<>
class ctype_byname<char>: public ctype<char> {
public:
explicit ctype_byname(const char*, size_t = 0);
~ctype_byname();
virtual char do_toupper(char __c) const;
virtual char do_tolower(char __c) const;
virtual const char* do_toupper(char*, const char*) const;
virtual const char* do_tolower(char*, const char*) const;
private:
mask _M_byname_table[table_size + 1];
_Locale_ctype* _M_ctype;
};
template<>
class ctype<wchar_t> : public locale::facet, public ctype_base
{
friend class _Locale;
public:
typedef wchar_t char_type;
explicit ctype(size_t __refs = 0) : locale::facet(__refs) {}
bool is(mask __m, wchar_t __c) const
{ return do_is(__m, __c); }
const wchar_t* is(const wchar_t* __low, const wchar_t* __high,
mask* __vec) const
{ return do_is(__low, __high, __vec); }
const wchar_t* scan_is(mask __m,
const wchar_t* __low, const wchar_t* __high) const
{ return do_scan_is(__m, __low, __high); }
const wchar_t* scan_not (mask __m,
const wchar_t* __low, const wchar_t* __high) const
{ return do_scan_not(__m, __low, __high); }
wchar_t (toupper)(wchar_t __c) const { return do_toupper(__c); }
const wchar_t* (toupper)(wchar_t* __low, wchar_t* __high) const
{ return do_toupper(__low, __high); }
wchar_t (tolower)(wchar_t __c) const { return do_tolower(__c); }
const wchar_t* (tolower)(wchar_t* __low, wchar_t* __high) const
{ return do_tolower(__low, __high); }
wchar_t widen(char __c) const { return do_widen(__c); }
const char* widen(const char* __low, const char* __high,
wchar_t* __to) const
{ return do_widen(__low, __high, __to); }
char narrow(wchar_t __c, char __dfault) const
{ return do_narrow(__c, __dfault); }
const wchar_t* narrow(const wchar_t* __low, const wchar_t* __high,
char __dfault, char* __to) const
{ return do_narrow(__low, __high, __dfault, __to); }
static locale::id id;
protected:
~ctype();
virtual bool do_is(mask __m, wchar_t __c) const;
virtual const wchar_t* do_is(const wchar_t*, const wchar_t*, mask*) const;
virtual const wchar_t* do_scan_is(mask,
const wchar_t*, const wchar_t*) const;
virtual const wchar_t* do_scan_not(mask,
const wchar_t*, const wchar_t*) const;
virtual wchar_t do_toupper(wchar_t __c) const;
virtual const wchar_t* do_toupper(wchar_t*, const wchar_t*) const;
virtual wchar_t do_tolower(wchar_t c) const;
virtual const wchar_t* do_tolower(wchar_t*, const wchar_t*) const;
virtual wchar_t do_widen(char c) const;
virtual const char* do_widen(const char*, const char*, wchar_t*) const;
virtual char do_narrow(wchar_t __c, char __dfault) const;
virtual const wchar_t* do_narrow(const wchar_t*, const wchar_t*,
char, char*) const;
};
template<>
class ctype_byname<wchar_t>: public ctype<wchar_t> {
public:
explicit ctype_byname(const char* __name, size_t __refs = 0);
protected:
~ctype_byname();
virtual bool do_is(mask __m, wchar_t __c) const;
virtual const wchar_t* do_is(const wchar_t*, const wchar_t*, mask*) const;
virtual const wchar_t* do_scan_is(mask,
const wchar_t*, const wchar_t*) const;
virtual const wchar_t* do_scan_not(mask,
const wchar_t*, const wchar_t*) const;
virtual wchar_t do_toupper(wchar_t __c) const;
virtual const wchar_t* do_toupper(wchar_t*, const wchar_t*) const;
virtual wchar_t do_tolower(wchar_t c) const;
virtual const wchar_t* do_tolower(wchar_t*, const wchar_t*) const;
private:
_Locale_ctype* _M_ctype;
};
}
namespace _STL {
template <class _CharT> class numpunct {};
template <class _CharT> class numpunct_byname {};
template <class _Ch, class _InIt> class num_get;
template<>
class numpunct<char> : public locale::facet
{
friend class _Locale;
template <class _Ch, class _InIt> friend class num_get;
public:
typedef char char_type;
typedef string string_type;
explicit numpunct(size_t __refs = 0) : locale::facet(__refs) {}
char decimal_point() const { return do_decimal_point(); }
char thousands_sep() const { return do_thousands_sep(); }
string grouping() const { return do_grouping(); }
string truename() const { return do_truename(); }
string falsename() const { return do_falsename(); }
static locale::id id;
protected:
~numpunct();
static string _M_truename;
static string _M_falsename;
static string _M_grouping;
virtual char do_decimal_point() const;
virtual char do_thousands_sep() const;
virtual string do_grouping() const;
virtual string do_truename() const;
virtual string do_falsename() const;
};
template<>
class numpunct<wchar_t> : public locale::facet
{
friend class _Locale;
public:
typedef wchar_t char_type;
typedef wstring string_type;
explicit numpunct(size_t __refs = 0) : locale::facet(__refs) {}
wchar_t decimal_point() const { return do_decimal_point(); }
wchar_t thousands_sep() const { return do_thousands_sep(); }
string grouping() const { return do_grouping(); }
wstring truename() const { return do_truename(); }
wstring falsename() const { return do_falsename(); }
static locale::id id;
protected:
static wstring _M_truename;
static wstring _M_falsename;
static string _M_grouping;
~numpunct();
virtual wchar_t do_decimal_point() const;
virtual wchar_t do_thousands_sep() const;
virtual string do_grouping() const;
virtual wstring do_truename() const;
virtual wstring do_falsename() const;
};
template<>
class numpunct_byname<char> : public numpunct<char> {
public:
typedef char char_type;
typedef string string_type;
explicit numpunct_byname(const char* __name, size_t __refs = 0);
protected:
~numpunct_byname();
virtual char do_decimal_point() const;
virtual char do_thousands_sep() const;
virtual string do_grouping() const;
private:
_Locale_numeric* _M_numeric;
};
template<>
class numpunct_byname<wchar_t>: public numpunct<wchar_t> {
public:
typedef wchar_t char_type;
typedef wstring string_type;
explicit numpunct_byname(const char* __name, size_t __refs = 0);
protected:
~numpunct_byname();
virtual wchar_t do_decimal_point() const;
virtual wchar_t do_thousands_sep() const;
virtual string do_grouping() const;
private:
_Locale_numeric* _M_numeric;
};
}
namespace _STL {
template <class _CharT, class _Traits>
class basic_ios : public ios_base {
friend class 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;
public:
explicit basic_ios(basic_streambuf<_CharT, _Traits>* __streambuf);
virtual ~basic_ios() {}
public:
basic_ostream<_CharT, _Traits>* tie() const {
return _M_tied_ostream;
}
basic_ostream<_CharT, _Traits>*
tie(basic_ostream<char_type, traits_type>* __new_tied_ostream) {
basic_ostream<char_type, traits_type>* __tmp = _M_tied_ostream;
_M_tied_ostream = __new_tied_ostream;
return __tmp;
}
basic_streambuf<_CharT, _Traits>* rdbuf() const
{ return _M_streambuf; }
basic_streambuf<_CharT, _Traits>*
rdbuf(basic_streambuf<char_type, traits_type>*);
basic_ios<_CharT, _Traits>& copyfmt(const basic_ios<_CharT, _Traits>& __x);
char_type fill() const { return _M_fill; }
char_type fill(char_type __fill) {
char_type __tmp(_M_fill);
_M_fill = __fill;
return __tmp;
}
public:
void clear(iostate __state = goodbit) {
_M_clear_nothrow(this->rdbuf() ? __state : iostate(__state|ios_base::badbit));
_M_check_exception_mask();
}
void setstate(iostate __state) { this->clear(rdstate() | __state); }
iostate exceptions() const { return this->_M_get_exception_mask(); }
void exceptions(iostate __mask) {
this->_M_set_exception_mask(__mask);
this->clear(this->rdstate());
}
public:
locale imbue(const locale&);
inline char narrow(_CharT, char) const ;
inline _CharT widen(char) const;
static bool _S_eof(int_type __c) {
const int_type __eof = _Traits::eof();
return _Traits::eq_int_type(__c, __eof);
}
protected:
basic_ios();
void init(basic_streambuf<_CharT, _Traits>* __streambuf);
public:
void _M_handle_exception(ios_base::iostate __flag);
private:
char_type _M_fill;
basic_streambuf<_CharT, _Traits>* _M_streambuf;
basic_ostream<_CharT, _Traits>* _M_tied_ostream;
};
template <class _CharT, class _Traits>
inline char
basic_ios<_CharT, _Traits>::narrow(_CharT __c, char __default) const
{ return ((const ctype<_CharT>*)this->_M_ctype_facet())->narrow(__c, __default); }
template <class _CharT, class _Traits>
inline _CharT
basic_ios<_CharT, _Traits>::widen(char __c) const
{
return ((const ctype<_CharT>*)this->_M_ctype_facet())->widen(__c); }
template<>
inline char
basic_ios<char, char_traits<char> >::narrow(char __c, char) const
{
return __c;
}
template<>
inline char
basic_ios<char, char_traits<char> >::widen(char __c) const
{
return __c;
}
}
extern "C" {
typedef struct
{
__off_t __pos;
__mbstate_t __state;
} _G_fpos_t;
typedef struct
{
__off64_t __pos;
__mbstate_t __state;
} _G_fpos64_t;
enum
{
__GCONV_OK = 0,
__GCONV_NOCONV,
__GCONV_NODB,
__GCONV_NOMEM,
__GCONV_EMPTY_INPUT,
__GCONV_FULL_OUTPUT,
__GCONV_ILLEGAL_INPUT,
__GCONV_INCOMPLETE_INPUT,
__GCONV_ILLEGAL_DESCRIPTOR,
__GCONV_INTERNAL_ERROR
};
enum
{
__GCONV_IS_LAST = 0x0001,
__GCONV_IGNORE_ERRORS = 0x0002
};
struct __gconv_step;
struct __gconv_step_data;
struct __gconv_loaded_object;
struct __gconv_trans_data;
typedef int (*__gconv_fct) (struct __gconv_step *, struct __gconv_step_data *,
__const unsigned char **, __const unsigned char *,
unsigned char **, size_t *, int, int);
typedef int (*__gconv_init_fct) (struct __gconv_step *);
typedef void (*__gconv_end_fct) (struct __gconv_step *);
typedef int (*__gconv_trans_fct) (struct __gconv_step *,
struct __gconv_step_data *, void *,
__const unsigned char *,
__const unsigned char **,
__const unsigned char *, unsigned char **,
size_t *);
typedef int (*__gconv_trans_context_fct) (void *, __const unsigned char *,
__const unsigned char *,
unsigned char *, unsigned char *);
typedef int (*__gconv_trans_query_fct) (__const char *, __const char ***,
size_t *);
typedef int (*__gconv_trans_init_fct) (void **, const char *);
typedef void (*__gconv_trans_end_fct) (void *);
struct __gconv_trans_data
{
__gconv_trans_fct __trans_fct;
__gconv_trans_context_fct __trans_context_fct;
__gconv_trans_end_fct __trans_end_fct;
void *__data;
struct __gconv_trans_data *__next;
};
struct __gconv_step
{
struct __gconv_loaded_object *__shlib_handle;
__const char *__modname;
int __counter;
char *__from_name;
char *__to_name;
__gconv_fct __fct;
__gconv_init_fct __init_fct;
__gconv_end_fct __end_fct;
int __min_needed_from;
int __max_needed_from;
int __min_needed_to;
int __max_needed_to;
int __stateful;
void *__data;
};
struct __gconv_step_data
{
unsigned char *__outbuf;
unsigned char *__outbufend;
int __flags;
int __invocation_counter;
int __internal_use;
__mbstate_t *__statep;
__mbstate_t __state;
struct __gconv_trans_data *__trans;
};
typedef struct __gconv_info
{
size_t __nsteps;
struct __gconv_step *__steps;
__extension__ struct __gconv_step_data __data [];
} *__gconv_t;
typedef union
{
struct __gconv_info __cd;
struct
{
struct __gconv_info __cd;
struct __gconv_step_data __data;
} __combined;
} _G_iconv_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_codecvt
{
void (*__codecvt_destr) (struct _IO_codecvt *);
enum __codecvt_result (*__codecvt_do_out) (struct _IO_codecvt *,
__mbstate_t *,
const wchar_t *,
const wchar_t *,
const wchar_t **, char *,
char *, char **);
enum __codecvt_result (*__codecvt_do_unshift) (struct _IO_codecvt *,
__mbstate_t *, char *,
char *, char **);
enum __codecvt_result (*__codecvt_do_in) (struct _IO_codecvt *,
__mbstate_t *,
const char *, const char *,
const char **, wchar_t *,
wchar_t *, wchar_t **);
int (*__codecvt_do_encoding) (struct _IO_codecvt *);
int (*__codecvt_do_always_noconv) (struct _IO_codecvt *);
int (*__codecvt_do_length) (struct _IO_codecvt *, __mbstate_t *,
const char *, const char *, size_t);
int (*__codecvt_do_max_length) (struct _IO_codecvt *);
_G_iconv_t __cd_in;
_G_iconv_t __cd_out;
};
struct _IO_wide_data
{
wchar_t *_IO_read_ptr;
wchar_t *_IO_read_end;
wchar_t *_IO_read_base;
wchar_t *_IO_write_base;
wchar_t *_IO_write_ptr;
wchar_t *_IO_write_end;
wchar_t *_IO_buf_base;
wchar_t *_IO_buf_end;
wchar_t *_IO_save_base;
wchar_t *_IO_backup_base;
wchar_t *_IO_save_end;
__mbstate_t _IO_state;
__mbstate_t _IO_last_state;
struct _IO_codecvt _codecvt;
wchar_t _shortbuf[1];
struct _IO_jump_t *_wide_vtable;
};
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 _blksize;
__off_t _old_offset;
unsigned short _cur_column;
signed char _vtable_offset;
char _shortbuf[1];
_IO_lock_t *_lock;
__off64_t _offset;
struct _IO_codecvt *_codecvt;
struct _IO_wide_data *_wide_data;
int _mode;
char _unused2[15 * sizeof (int) - 2 * sizeof (void *)];
};
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 *) throw ();
extern int __uflow (_IO_FILE *) throw ();
extern int __overflow (_IO_FILE *, int) throw ();
extern wint_t __wunderflow (_IO_FILE *) throw ();
extern wint_t __wuflow (_IO_FILE *) throw ();
extern wint_t __woverflow (_IO_FILE *, wint_t) throw ();
extern int _IO_getc (_IO_FILE *__fp) throw ();
extern int _IO_putc (int __c, _IO_FILE *__fp) throw ();
extern int _IO_feof (_IO_FILE *__fp) throw ();
extern int _IO_ferror (_IO_FILE *__fp) throw ();
extern int _IO_peekc_locked (_IO_FILE *__fp) throw ();
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) throw ();
extern int _IO_vfprintf (_IO_FILE *__restrict, const char *__restrict,
__gnuc_va_list) throw ();
extern __ssize_t _IO_padn (_IO_FILE *, int, __ssize_t) throw ();
extern size_t _IO_sgetn (_IO_FILE *, void *, size_t) throw ();
extern __off64_t _IO_seekoff (_IO_FILE *, __off64_t, int, int) throw ();
extern __off64_t _IO_seekpos (_IO_FILE *, __off64_t, int) throw ();
extern void _IO_free_backup_area (_IO_FILE *) throw ();
extern wint_t _IO_getwc (_IO_FILE *__fp) throw ();
extern wint_t _IO_putwc (wchar_t __wc, _IO_FILE *__fp) throw ();
extern int _IO_fwide (_IO_FILE *__fp, int __mode) throw ();
extern int _IO_vfwscanf (_IO_FILE * __restrict, const wchar_t * __restrict,
__gnuc_va_list, int *__restrict) throw ();
extern int _IO_vfwprintf (_IO_FILE *__restrict, const wchar_t *__restrict,
__gnuc_va_list) throw ();
extern __ssize_t _IO_wpadn (_IO_FILE *, wint_t, __ssize_t) throw ();
extern void _IO_free_wbackup_area (_IO_FILE *) throw ();
}
typedef __gnuc_va_list __not_va_list__;
typedef _G_fpos_t fpos_t;
typedef _G_fpos64_t fpos64_t;
extern FILE *stdin;
extern FILE *stdout;
extern FILE *stderr;
extern int remove (__const char *__filename) throw ();
extern int rename (__const char *__old, __const char *__new) throw ();
extern FILE *tmpfile (void) throw ();
extern FILE *tmpfile64 (void) throw ();
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) throw ();
extern int fflush (FILE *__stream) throw ();
extern int fflush_unlocked (FILE *__stream) throw ();
extern int fcloseall (void) throw ();
extern FILE *fopen (__const char *__restrict __filename,
__const char *__restrict __modes) throw ();
extern FILE *freopen (__const char *__restrict __filename,
__const char *__restrict __modes,
FILE *__restrict __stream) throw ();
extern FILE *fopen64 (__const char *__restrict __filename,
__const char *__restrict __modes) throw ();
extern FILE *freopen64 (__const char *__restrict __filename,
__const char *__restrict __modes,
FILE *__restrict __stream) throw ();
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 **__restrict __bufloc,
size_t *__restrict __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, ...) throw ();
extern int printf (__const char *__restrict __format, ...) throw ();
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) throw ();
extern int vprintf (__const char *__restrict __format, __gnuc_va_list __arg)
throw ();
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)
throw () __attribute__ ((__format__ (__printf__, 2, 0)));
extern int dprintf (int __fd, __const char *__restrict __fmt, ...)
throw () __attribute__ ((__format__ (__printf__, 2, 3)));
extern int fscanf (FILE *__restrict __stream,
__const char *__restrict __format, ...) throw ();
extern int scanf (__const char *__restrict __format, ...) throw ();
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)
throw () __attribute__ ((__format__ (__scanf__, 2, 0)));
extern int vscanf (__const char *__restrict __format, __gnuc_va_list __arg)
throw () __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) throw ();
extern int getc (FILE *__stream) throw ();
extern int getchar (void) throw ();
extern int getc_unlocked (FILE *__stream) throw ();
extern int getchar_unlocked (void) throw ();
extern int fgetc_unlocked (FILE *__stream) throw ();
extern int fputc (int __c, FILE *__stream) throw ();
extern int putc (int __c, FILE *__stream) throw ();
extern int putchar (int __c) throw ();
extern int fputc_unlocked (int __c, FILE *__stream) throw ();
extern int putc_unlocked (int __c, FILE *__stream) throw ();
extern int putchar_unlocked (int __c) throw ();
extern int getw (FILE *__stream) throw ();
extern int putw (int __w, FILE *__stream) throw ();
extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
throw ();
extern char *fgets_unlocked (char *__restrict __s, int __n,
FILE *__restrict __stream) throw ();
extern char *gets (char *__s) throw ();
extern __ssize_t __getdelim (char **__restrict __lineptr,
size_t *__restrict __n, int __delimiter,
FILE *__restrict __stream) throw ();
extern __ssize_t getdelim (char **__restrict __lineptr,
size_t *__restrict __n, int __delimiter,
FILE *__restrict __stream) throw ();
extern __ssize_t getline (char **__restrict __lineptr,
size_t *__restrict __n,
FILE *__restrict __stream) throw ();
extern int fputs (__const char *__restrict __s, FILE *__restrict __stream)
throw ();
extern int fputs_unlocked (__const char *__restrict __s,
FILE *__restrict __stream) throw ();
extern int puts (__const char *__s) throw ();
extern int ungetc (int __c, FILE *__stream) throw ();
extern size_t fread (void *__restrict __ptr, size_t __size,
size_t __n, FILE *__restrict __stream) throw ();
extern size_t fwrite (__const void *__restrict __ptr, size_t __size,
size_t __n, FILE *__restrict __s) throw ();
extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
size_t __n, FILE *__restrict __stream) throw ();
extern size_t fwrite_unlocked (__const void *__restrict __ptr, size_t __size,
size_t __n, FILE *__restrict __stream) throw ();
extern int fseek (FILE *__stream, long int __off, int __whence) throw ();
extern long int ftell (FILE *__stream) throw ();
extern void rewind (FILE *__stream) throw ();
extern int fseeko (FILE *__stream, __off_t __off, int __whence) throw ();
extern __off_t ftello (FILE *__stream) throw ();
extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos)
throw ();
extern int fsetpos (FILE *__stream, __const fpos_t *__pos) throw ();
extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence) throw ();
extern __off64_t ftello64 (FILE *__stream) throw ();
extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos)
throw ();
extern int fsetpos64 (FILE *__stream, __const fpos64_t *__pos) throw ();
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) throw ();
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) throw ();
extern int pclose (FILE *__stream) throw ();
extern char *ctermid (char *__s) throw ();
extern char *cuserid (char *__s) throw ();
struct obstack;
extern int obstack_printf (struct obstack *__restrict __obstack,
__const char *__restrict __format, ...) throw ();
extern int obstack_vprintf (struct obstack *__restrict __obstack,
__const char *__restrict __format,
__gnuc_va_list __args) throw ();
extern void flockfile (FILE *__stream) throw ();
extern int ftrylockfile (FILE *__stream) throw ();
extern void funlockfile (FILE *__stream) throw ();
}
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 _STL {
using __std_alias::FILE;
using __std_alias::fpos_t;
using __std_alias::size_t;
using __std_alias::clearerr;
using __std_alias::fclose;
using __std_alias::feof;
using __std_alias::ferror;
using __std_alias::fflush;
using __std_alias::fgetc;
using __std_alias::fgetpos;
using __std_alias::fgets;
using __std_alias::fopen;
using __std_alias::fprintf;
using __std_alias::fputc;
using __std_alias::fputs;
using __std_alias::fread;
using __std_alias::freopen;
using __std_alias::fscanf;
using __std_alias::fseek;
using __std_alias::fsetpos;
using __std_alias::ftell;
using __std_alias::fwrite;
using __std_alias::getc;
using __std_alias::getchar;
using __std_alias::putc;
using __std_alias::putchar;
using __std_alias::gets;
using __std_alias::perror;
using __std_alias::printf;
using __std_alias::puts;
using __std_alias::remove;
using __std_alias::rename;
using __std_alias::rewind;
using __std_alias::scanf;
using __std_alias::setbuf;
using __std_alias::setvbuf;
using __std_alias::sprintf;
using __std_alias::sscanf;
using __std_alias::tmpfile;
using __std_alias::tmpnam;
using __std_alias::ungetc;
using __std_alias::vfprintf;
using __std_alias::vprintf;
using __std_alias::vsprintf;
}
namespace _STL {
inline int _FILE_fd(const FILE *__f) { return __f->_fileno; }
inline char* _FILE_I_begin(const FILE *__f) { return __f->_IO_read_base; }
inline char* _FILE_I_next(const FILE *__f) { return __f->_IO_read_ptr; }
inline char* _FILE_I_end(const FILE *__f) { return __f->_IO_read_end; }
inline ptrdiff_t _FILE_I_avail(const FILE *__f)
{ return __f->_IO_read_end - __f->_IO_read_ptr; }
inline char& _FILE_I_preincr(FILE *__f) { return *++__f->_IO_read_ptr; }
inline char& _FILE_I_postincr(FILE *__f) { return *__f->_IO_read_ptr++; }
inline char& _FILE_I_predecr(FILE *__f) { return *--__f->_IO_read_ptr; }
inline char& _FILE_I_postdecr(FILE *__f) { return *__f->_IO_read_ptr--; }
inline void _FILE_I_bump(FILE *__f, int __n) { __f->_IO_read_ptr += __n; }
inline void _FILE_I_set(FILE *__f, char* __begin, char* __next, char* __end) {
__f->_IO_read_base = __begin;
__f->_IO_read_ptr = __next;
__f->_IO_read_end = __end;
}
inline char* _FILE_O_begin(const FILE *__f) { return __f->_IO_write_base; }
inline char* _FILE_O_next(const FILE *__f) { return __f->_IO_write_ptr; }
inline char* _FILE_O_end(const FILE *__f) { return __f->_IO_write_end; }
inline ptrdiff_t _FILE_O_avail(const FILE *__f)
{ return __f->_IO_write_end - __f->_IO_write_ptr; }
inline char& _FILE_O_preincr(FILE *__f) { return *++__f->_IO_write_ptr; }
inline char& _FILE_O_postincr(FILE *__f) { return *__f->_IO_write_ptr++; }
inline char& _FILE_O_predecr(FILE *__f) { return *--__f->_IO_write_ptr; }
inline char& _FILE_O_postdecr(FILE *__f) { return *__f->_IO_write_ptr--; }
inline void _FILE_O_bump(FILE *__f, int __n) { __f->_IO_write_ptr += __n; }
inline void _FILE_O_set(FILE *__f, char* __begin, char* __next, char* __end) {
__f->_IO_write_base = __begin;
__f->_IO_write_ptr = __next;
__f->_IO_write_end = __end;
}
}
namespace _STL {
template <class _CharT, class _Traits>
class basic_streambuf
{
friend class basic_istream<_CharT, _Traits>;
friend class 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;
private:
char_type* _M_gbegin;
char_type* _M_gnext;
char_type* _M_gend;
char_type* _M_pbegin;
char_type* _M_pnext;
char_type* _M_pend;
locale _M_locale;
public:
_STLP_mutex _M_lock;
public:
virtual ~basic_streambuf();
protected:
basic_streambuf();
protected:
char_type* eback() const { return _M_gbegin; }
char_type* gptr() const { return _M_gnext; }
char_type* egptr() const { return _M_gend; }
void gbump(int __n) { _M_gnext += __n; }
void setg(char_type* __gbegin, char_type* __gnext, char_type* __gend) {
_M_gbegin = __gbegin;
_M_gnext = __gnext;
_M_gend = __gend;
}
public:
char_type* _M_eback() const { return eback(); }
char_type* _M_gptr() const { return gptr(); }
char_type* _M_egptr() const { return egptr(); }
void _M_gbump(int __n) { gbump(__n); }
void _M_setg(char_type* __gbegin, char_type* __gnext, char_type* __gend)
{ setg(__gbegin, __gnext, __gend); }
protected:
char_type* pbase() const { return _M_pbegin; }
char_type* pptr() const { return _M_pnext; }
char_type* epptr() const { return _M_pend; }
void pbump(int __n) { _M_pnext += __n; }
void setp(char_type* __pbegin, char_type* __pend) {
_M_pbegin = __pbegin;
_M_pnext = __pbegin;
_M_pend = __pend;
}
protected:
virtual basic_streambuf<_CharT, _Traits>* setbuf(char_type*, streamsize);
virtual pos_type seekoff(off_type, ios_base::seekdir,
ios_base::openmode = ios_base::in | ios_base::out);
virtual pos_type
seekpos(pos_type, ios_base::openmode = ios_base::in | ios_base::out);
virtual int sync();
public:
basic_streambuf<_CharT, _Traits>* pubsetbuf(char_type* __s, streamsize __n)
{ return this->setbuf(__s, __n); }
pos_type pubseekoff(off_type __offset, ios_base::seekdir __way,
ios_base::openmode __mod = ios_base::in | ios_base::out)
{ return this->seekoff(__offset, __way, __mod); }
pos_type pubseekpos(pos_type __sp,
ios_base::openmode __mod = ios_base::in | ios_base::out)
{ return this->seekpos(__sp, __mod); }
int pubsync() { return this->sync(); }
protected:
virtual streamsize showmanyc();
virtual streamsize xsgetn(char_type* __s, streamsize __n);
virtual int_type underflow();
virtual int_type uflow();
virtual int_type pbackfail(int_type = traits_type::eof());
protected:
virtual streamsize xsputn(const char_type* __s, streamsize __n);
virtual streamsize _M_xsputnc(char_type __c, streamsize __n);
virtual int_type overflow(int_type = traits_type::eof());
public:
int_type sputc(char_type __c) {
return ((_M_pnext < _M_pend) ? _Traits::to_int_type(*_M_pnext++ = __c)
: this->overflow(_Traits::to_int_type(__c)));
}
streamsize sputn(const char_type* __s, streamsize __n)
{ return this->xsputn(__s, __n); }
streamsize _M_sputnc(char_type __c, streamsize __n)
{ return this->_M_xsputnc(__c, __n); }
private:
int_type _M_snextc_aux();
public:
streamsize in_avail() {
return (_M_gnext < _M_gend) ? (_M_gend - _M_gnext) : this->showmanyc();
}
int_type snextc() {
return ( _M_gend - _M_gnext > 1 ?
_Traits::to_int_type(*++_M_gnext) :
this->_M_snextc_aux());
}
int_type sbumpc() {
return _M_gnext < _M_gend ? _Traits::to_int_type(*_M_gnext++)
: this->uflow();
}
int_type sgetc() {
return _M_gnext < _M_gend ? _Traits::to_int_type(*_M_gnext)
: this->underflow();
}
streamsize sgetn(char_type* __s, streamsize __n)
{ return this->xsgetn(__s, __n); }
int_type sputbackc(char_type __c) {
return ((_M_gbegin < _M_gnext) && _Traits::eq(__c, *(_M_gnext - 1)))
? _Traits::to_int_type(*--_M_gnext)
: this->pbackfail(_Traits::to_int_type(__c));
}
int_type sungetc() {
return (_M_gbegin < _M_gnext)
? _Traits::to_int_type(*--_M_gnext)
: this->pbackfail();
}
protected:
virtual void imbue(const locale&);
public:
locale pubimbue(const locale&);
locale getloc() const { return _M_locale; }
void stossc() { this->sbumpc(); }
};
template<>
class basic_streambuf<char, char_traits<char> >
{
friend class basic_istream<char, char_traits<char> >;
friend class basic_ostream<char, char_traits<char> >;
public:
typedef char char_type;
typedef char_traits<char>::int_type int_type;
typedef char_traits<char>::pos_type pos_type;
typedef char_traits<char>::off_type off_type;
typedef char_traits<char> traits_type;
private:
FILE* _M_get;
FILE* _M_put;
FILE _M_default_get;
FILE _M_default_put;
locale _M_locale;
public:
_STLP_mutex _M_lock;
public:
virtual ~basic_streambuf ();
protected:
basic_streambuf ()
: _M_get(reinterpret_cast<FILE*>(&_M_default_get)),
_M_put(reinterpret_cast<FILE*>(&_M_default_put)), _M_locale()
{
_FILE_I_set(_M_get, 0, 0, 0);
_FILE_O_set(_M_put, 0, 0, 0);
}
basic_streambuf (FILE* __get, FILE* __put);
protected:
char_type* eback() const { return _FILE_I_begin(_M_get); }
char_type* gptr() const { return _FILE_I_next(_M_get); }
char_type* egptr() const { return _FILE_I_end(_M_get); }
void gbump(int __n) { _FILE_I_bump(_M_get, __n); }
void setg(char_type* __gbegin, char_type* __gnext, char_type* __gend)
{ _FILE_I_set(_M_get, __gbegin, __gnext, __gend); }
public:
char_type* _M_eback() const { return _FILE_I_begin(_M_get); }
char_type* _M_gptr() const { return _FILE_I_next(_M_get); }
char_type* _M_egptr() const { return _FILE_I_end(_M_get); }
void _M_gbump(int __n) { _FILE_I_bump(_M_get, __n); }
void _M_setg(char_type* __gbegin, char_type* __gnext, char_type* __gend)
{ _FILE_I_set(_M_get, __gbegin, __gnext, __gend); }
protected:
char_type* pbase() const { return _FILE_O_begin(_M_put); }
char_type* pptr() const { return _FILE_O_next(_M_put); }
char_type* epptr() const { return _FILE_O_end(_M_put); }
void pbump(int __n) { _FILE_O_bump(_M_put, __n); }
void setp(char_type* __pbegin, char_type* __pend)
{ _FILE_O_set(_M_put, __pbegin, __pbegin, __pend); }
protected:
virtual basic_streambuf<char, char_traits<char> >* setbuf(char_type*, streamsize);
virtual pos_type seekoff(off_type, ios_base::seekdir,
ios_base::openmode = ios_base::in | ios_base::out);
virtual pos_type
seekpos(pos_type, ios_base::openmode = ios_base::in | ios_base::out);
virtual int sync();
public:
basic_streambuf<char, char_traits<char> >* pubsetbuf(char_type* __s, streamsize __n)
{ return this->setbuf(__s, __n); }
pos_type pubseekoff(off_type __offset, ios_base::seekdir __way,
ios_base::openmode __mod = ios_base::in | ios_base::out)
{ return this->seekoff(__offset, __way, __mod); }
pos_type pubseekpos(pos_type __sp,
ios_base::openmode __mod = ios_base::in | ios_base::out)
{ return this->seekpos(__sp, __mod); }
int pubsync() { return this->sync(); }
protected:
virtual streamsize showmanyc();
virtual streamsize xsgetn(char_type* __s, streamsize __n);
virtual int_type underflow();
virtual int_type uflow();
virtual int_type pbackfail(int_type __c = traits_type::eof());
protected:
virtual streamsize xsputn(const char_type* __s, streamsize __n);
virtual streamsize _M_xsputnc(char_type __c, streamsize __n);
virtual int_type overflow(int_type = traits_type::eof());
public:
int_type sputc(char_type __c) {
int_type __res;
if( _FILE_O_avail(_M_put) > 0 )
{
_FILE_O_postincr(_M_put) = __c;
__res = traits_type::to_int_type(__c);
}
else
__res = this->overflow(traits_type::to_int_type(__c));
return __res;
}
streamsize sputn(const char_type* __s, streamsize __n)
{ return this->xsputn(__s, __n); }
streamsize _M_sputnc(char_type __c, streamsize __n)
{ return this->_M_xsputnc(__c, __n); }
private:
int_type _M_snextc_aux();
public:
streamsize in_avail()
{ return _FILE_I_avail(_M_get) > 0 ? _FILE_I_avail(_M_get)
: this->showmanyc(); }
int_type snextc() {
return _FILE_I_avail(_M_get) > 1
? traits_type::to_int_type(_FILE_I_preincr(_M_get))
: this->_M_snextc_aux();
}
int_type sbumpc() {
return _FILE_I_avail(_M_get) > 0
? traits_type::to_int_type(_FILE_I_postincr(_M_get))
: this->uflow();
}
int_type sgetc() {
return _FILE_I_avail(_M_get) > 0
? traits_type::to_int_type(*_FILE_I_next(_M_get))
: this->underflow();
}
streamsize sgetn(char_type* __s, streamsize __n)
{ return this->xsgetn(__s, __n); }
int_type sputbackc(char_type __c) {
return _FILE_I_begin(_M_get) < _FILE_I_next(_M_get) &&
__c == *(_FILE_I_next(_M_get) - 1)
? traits_type::to_int_type(_FILE_I_predecr(_M_get))
: this->pbackfail(traits_type::to_int_type(__c));
}
int_type sungetc() {
return _FILE_I_begin(_M_get) < _FILE_I_next(_M_get)
? traits_type::to_int_type(_FILE_I_predecr(_M_get))
: this->pbackfail();
}
protected:
virtual void imbue(const locale&);
public:
locale pubimbue(const locale&);
locale getloc() const { return _M_locale; }
public:
void stossc() { this->sbumpc(); }
};
}
namespace _STL {
template <class _CharT, class _Traits>
basic_streambuf<_CharT, _Traits>::basic_streambuf()
: _M_gbegin(0), _M_gnext(0), _M_gend(0),
_M_pbegin(0), _M_pnext(0), _M_pend(0),
_M_locale()
{
}
template <class _CharT, class _Traits>
basic_streambuf<_CharT, _Traits>::~basic_streambuf()
{}
template <class _CharT, class _Traits>
locale
basic_streambuf<_CharT, _Traits>::pubimbue(const locale& __loc) {
this->imbue(__loc);
locale __tmp = _M_locale;
_M_locale = __loc;
return __tmp;
}
template <class _CharT, class _Traits>
streamsize
basic_streambuf<_CharT, _Traits>::xsgetn(_CharT* __s, streamsize __n)
{
streamsize __result = 0;
const int_type __eof = _Traits::eof();
while (__result < __n) {
if (_M_gnext < _M_gend) {
size_t __chunk = (min) (static_cast<size_t>(_M_gend - _M_gnext),
static_cast<size_t>(__n - __result));
_Traits::copy(__s, _M_gnext, __chunk);
__result += __chunk;
__s += __chunk;
_M_gnext += __chunk;
}
else {
int_type __c = this->sbumpc();
if (!_Traits::eq_int_type(__c, __eof)) {
*__s = __c;
++__result;
++__s;
}
else
break;
}
}
return __result;
}
template <class _CharT, class _Traits>
streamsize
basic_streambuf<_CharT, _Traits>::xsputn(const _CharT* __s, streamsize __n)
{
streamsize __result = 0;
const int_type __eof = _Traits::eof();
while (__result < __n) {
if (_M_pnext < _M_pend) {
size_t __chunk = (min) (static_cast<size_t>(_M_pend - _M_pnext),
static_cast<size_t>(__n - __result));
_Traits::copy(_M_pnext, __s, __chunk);
__result += __chunk;
__s += __chunk;
_M_pnext += __chunk;
}
else if (!_Traits::eq_int_type(this->overflow(_Traits::to_int_type(*__s)),
__eof)) {
++__result;
++__s;
}
else
break;
}
return __result;
}
template <class _CharT, class _Traits>
streamsize
basic_streambuf<_CharT, _Traits>::_M_xsputnc(_CharT __c, streamsize __n)
{
streamsize __result = 0;
const int_type __eof = _Traits::eof();
while (__result < __n) {
if (_M_pnext < _M_pend) {
size_t __chunk = (min) (static_cast<size_t>(_M_pend - _M_pnext),
static_cast<size_t>(__n - __result));
_Traits::assign(_M_pnext, __chunk, __c);
__result += __chunk;
_M_pnext += __chunk;
}
else if (!_Traits::eq_int_type(this->overflow(_Traits::to_int_type(__c)),
__eof))
++__result;
else
break;
}
return __result;
}
template <class _CharT, class _Traits>
typename basic_streambuf<_CharT, _Traits>::int_type
basic_streambuf<_CharT, _Traits>::_M_snextc_aux()
{
int_type __eof = _Traits::eof();
if (_M_gend == _M_gnext)
return _Traits::eq_int_type(this->uflow(), __eof) ? __eof : this->sgetc();
else {
_M_gnext = _M_gend;
return this->underflow();
}
}
template <class _CharT, class _Traits>
typename basic_streambuf<_CharT, _Traits>::int_type
basic_streambuf<_CharT, _Traits>::pbackfail(int_type) {
return _Traits::eof();
}
template <class _CharT, class _Traits>
typename basic_streambuf<_CharT, _Traits>::int_type
basic_streambuf<_CharT, _Traits>::overflow(int_type) {
return _Traits::eof();
}
template <class _CharT, class _Traits>
typename basic_streambuf<_CharT, _Traits>::int_type
basic_streambuf<_CharT, _Traits>::uflow() {
return ( _Traits::eq_int_type(this->underflow(),_Traits::eof()) ?
_Traits::eof() :
_Traits::to_int_type(*_M_gnext++));
}
template <class _CharT, class _Traits>
typename basic_streambuf<_CharT, _Traits>::int_type
basic_streambuf<_CharT, _Traits>::underflow()
{ return _Traits::eof(); }
template <class _CharT, class _Traits>
streamsize
basic_streambuf<_CharT, _Traits>::showmanyc()
{ return 0; }
template <class _CharT, class _Traits>
void
basic_streambuf<_CharT, _Traits>::imbue(const locale&) {}
template <class _CharT, class _Traits>
int
basic_streambuf<_CharT, _Traits>::sync() { return 0; }
template <class _CharT, class _Traits>
typename basic_streambuf<_CharT, _Traits>::pos_type
basic_streambuf<_CharT, _Traits>::seekpos(pos_type, ios_base::openmode)
{ return pos_type(-1); }
template <class _CharT, class _Traits>
typename basic_streambuf<_CharT, _Traits>::pos_type
basic_streambuf<_CharT, _Traits>::seekoff(off_type, ios_base::seekdir,
ios_base::openmode)
{ return pos_type(-1); }
template <class _CharT, class _Traits>
basic_streambuf<_CharT, _Traits>*
basic_streambuf<_CharT, _Traits>:: setbuf(char_type*, streamsize)
{ return this; }
}
namespace _STL {
template <class _CharT, class _Traits>
basic_ios<_CharT, _Traits>
::basic_ios(basic_streambuf<_CharT, _Traits>* __streambuf)
: ios_base(),
_M_fill(_CharT()), _M_streambuf(0), _M_tied_ostream(0)
{
init(__streambuf);
}
template <class _CharT, class _Traits>
basic_streambuf<_CharT, _Traits>*
basic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<_CharT, _Traits>* __buf)
{
basic_streambuf<_CharT, _Traits>* __tmp = _M_streambuf;
_M_streambuf = __buf;
this->clear();
return __tmp;
}
template <class _CharT, class _Traits>
basic_ios<_CharT, _Traits>&
basic_ios<_CharT, _Traits>::copyfmt(const basic_ios<_CharT, _Traits>& __x)
{
_M_invoke_callbacks(erase_event);
_M_copy_state(__x);
_M_fill = __x._M_fill;
_M_tied_ostream = __x._M_tied_ostream;
_M_invoke_callbacks(copyfmt_event);
this->_M_set_exception_mask(__x.exceptions());
return *this;
}
template <class _CharT, class _Traits>
locale basic_ios<_CharT, _Traits>::imbue(const locale& __loc)
{
locale __tmp = ios_base::imbue(__loc);
if (_M_streambuf)
_M_streambuf->pubimbue(__loc);
this->_M_cached_ctype = __loc._M_get_facet(ctype<char_type>::id) ;
this->_M_cached_numpunct = __loc._M_get_facet(numpunct<char_type>::id) ;
this->_M_cached_grouping = ((numpunct<char_type>*)_M_cached_numpunct)->grouping() ;
return __tmp;
}
template <class _CharT, class _Traits>
basic_ios<_CharT, _Traits>::basic_ios()
: ios_base(),
_M_fill(_CharT()), _M_streambuf(0), _M_tied_ostream(0)
{}
template <class _CharT, class _Traits>
void
basic_ios<_CharT, _Traits>::init(basic_streambuf<_CharT, _Traits>* __sb)
{
this->rdbuf(__sb);
this->imbue(locale());
this->tie(0);
this->_M_set_exception_mask(ios_base::goodbit);
this->_M_clear_nothrow(__sb != 0 ? ios_base::goodbit : ios_base::badbit);
ios_base::flags(ios_base::skipws | ios_base::dec);
ios_base::width(0);
ios_base::precision(6);
this->fill(widen(' '));
}
template <class _CharT, class _Traits>
void basic_ios<_CharT, _Traits>::_M_handle_exception(ios_base::iostate __flag)
{
this->_M_setstate_nothrow(__flag);
if (this->_M_get_exception_mask() & __flag)
throw;
}
}
namespace _STL {
template <class _CharT, class _Traits>
extern basic_streambuf<_CharT, _Traits>* _M_get_ostreambuf(basic_ostream<_CharT, _Traits>& ) ;
template<class _CharT, class _Traits>
class ostreambuf_iterator
{
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_ostream<_CharT, _Traits> ostream_type;
typedef output_iterator_tag iterator_category;
typedef void value_type;
typedef void difference_type;
typedef void pointer;
typedef void reference;
public:
ostreambuf_iterator(streambuf_type* __buf) : _M_buf(__buf), _M_ok(__buf!=0) {}
inline ostreambuf_iterator(ostream_type& __o) ;
ostreambuf_iterator<_CharT, _Traits>& operator=(char_type __c) {
_M_ok = _M_ok && !traits_type::eq_int_type(_M_buf->sputc(__c),
traits_type::eof());
return *this;
}
ostreambuf_iterator<_CharT, _Traits>& operator*() { return *this; }
ostreambuf_iterator<_CharT, _Traits>& operator++() { return *this; }
ostreambuf_iterator<_CharT, _Traits>& operator++(int) { return *this; }
bool failed() const { return !_M_ok; }
private:
streambuf_type* _M_buf;
bool _M_ok;
};
template <class _CharT, class _Traits>
inline ostreambuf_iterator<_CharT, _Traits>::ostreambuf_iterator(basic_ostream<_CharT, _Traits>& __o) : _M_buf(_M_get_ostreambuf(__o)), _M_ok(_M_buf != 0) {}
}
namespace _STL {
template <class _CharT, class _Traits, class _Number>
basic_ostream<_CharT, _Traits>&
_M_put_num(basic_ostream<_CharT, _Traits>& __os, _Number __x);
template <class _CharT, class _Traits>
bool
_M_init(basic_ostream<_CharT, _Traits>& __str);
template <class _CharT, class _Traits>
class basic_ostream : virtual public basic_ios<_CharT, _Traits>
{
typedef basic_ostream<_CharT, _Traits> _Self;
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_ios<_CharT, _Traits> _Basic_ios;
public:
explicit basic_ostream(basic_streambuf<_CharT, _Traits>* __buf);
~basic_ostream();
public:
typedef basic_ios<_CharT, _Traits>& ( *__ios_fn)(basic_ios<_CharT, _Traits>&);
typedef ios_base& ( *__ios_base_fn)(ios_base&);
typedef _Self& ( *__ostream_fn)(_Self&);
_Self& operator<< (__ostream_fn __f) { return __f(*this); }
_Self & operator<< (__ios_base_fn __f) { __f(*this); return *this; }
_Self& operator<< (__ios_fn __ff) { __ff(*this); return *this; }
private:
bool _M_copy_buffered(basic_streambuf<_CharT, _Traits>* __from,
basic_streambuf<_CharT, _Traits>* __to);
bool _M_copy_unbuffered(basic_streambuf<_CharT, _Traits>* __from,
basic_streambuf<_CharT, _Traits>* __to);
public:
void _M_put_char(_CharT __c);
void _M_put_nowiden(const _CharT* __s);
void _M_put_widen(const char* __s);
bool _M_put_widen_aux(const char* __s, streamsize __n);
public:
_Self& put(char_type __c);
_Self& write(const char_type* __s, streamsize __n);
public:
_Self& operator<<(basic_streambuf<_CharT, _Traits>* __buf);
_Self& operator<<(unsigned char __x) { _M_put_char(__x); return *this; }
_Self& operator<<(short __x) { return _M_put_num(*this, static_cast<long>(__x)); }
_Self& operator<<(unsigned short __x) { return _M_put_num(*this, static_cast<unsigned long>(__x)); }
_Self& operator<<(int __x) { return _M_put_num(*this, static_cast<long>(__x)); }
_Self& operator<<(unsigned int __x) { return _M_put_num(*this, static_cast<unsigned long>(__x)); }
_Self& operator<<(long __x) { return _M_put_num(*this, __x); }
_Self& operator<<(unsigned long __x) { return _M_put_num(*this, __x); }
_Self& operator<< (long long __x) { return _M_put_num(*this, __x); }
_Self& operator<< (unsigned long long __x) { return _M_put_num(*this, __x); }
_Self& operator<<(float __x)
{ return _M_put_num(*this, static_cast<double>(__x)); }
_Self& operator<<(double __x) { return _M_put_num(*this, __x); }
_Self& operator<<(long double __x) { return _M_put_num(*this, __x); }
_Self& operator<<(const void* __x) { return _M_put_num(*this, __x); }
_Self& operator<<(bool __x) { return _M_put_num(*this, __x); }
public:
_Self& flush() {
if (this->rdbuf())
if (this->rdbuf()->pubsync() == -1)
this->setstate(ios_base::badbit);
return *this;
}
pos_type tellp() {
return this->rdbuf() && !this->fail()
? this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out)
: pos_type(-1);
}
_Self& seekp(pos_type __pos) {
if (this->rdbuf() && !this->fail())
this->rdbuf()->pubseekpos(__pos, ios_base::out);
return *this;
}
_Self& seekp(off_type __off, ios_base::seekdir __dir) {
if (this->rdbuf() && !this->fail())
this->rdbuf()->pubseekoff(__off, __dir, ios_base::out);
return *this;
}
class sentry {
typedef sentry _Self;
private:
basic_ostream<_CharT, _Traits>& _M_str;
bool _M_ok;
public:
explicit sentry(basic_ostream<_CharT, _Traits>& __str)
: _M_str(__str), _M_ok(_M_init(__str))
{
}
~sentry() {
if (_M_str.flags() & ios_base::unitbuf)
_M_str.flush();
}
operator bool() const { return _M_ok; }
private:
sentry(const _Self& __s) : _M_str (__s._M_str) {};
void operator=(const _Self&) {};
};
};
template <class _CharT, class _Traits>
inline basic_streambuf<_CharT, _Traits>*
_M_get_ostreambuf(basic_ostream<_CharT, _Traits>& __St)
{
return __St.rdbuf();
}
template <class _CharT, class _Traits>
inline basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c) {
__os._M_put_char(__c);
return __os;
}
template <class _CharT, class _Traits>
inline basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __s) {
__os._M_put_nowiden(__s);
return __os;
}
template <class _CharT, class _Traits>
inline basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, char __c) {
__os._M_put_char(__os.widen(__c));
return __os;
}
template <class _Traits>
inline basic_ostream<char, _Traits>&
operator<<(basic_ostream<char, _Traits>& __os, char __c) {
__os._M_put_char(__c);
return __os;
}
template <class _Traits>
inline basic_ostream<char, _Traits>&
operator<<(basic_ostream<char, _Traits>& __os, signed char __c) {
__os._M_put_char(__c);
return __os;
}
template <class _Traits>
inline basic_ostream<char, _Traits>&
operator<<(basic_ostream<char, _Traits>& __os, unsigned char __c) {
__os._M_put_char(__c);
return __os;
}
template <class _CharT, class _Traits>
inline basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __s) {
__os._M_put_widen(__s);
return __os;
}
template <class _Traits>
inline basic_ostream<char, _Traits>&
operator<<(basic_ostream<char, _Traits>& __os, const char* __s) {
__os._M_put_nowiden(__s);
return __os;
}
template <class _Traits>
inline basic_ostream<char, _Traits>&
operator<<(basic_ostream<char, _Traits>& __os, const signed char* __s) {
__os._M_put_nowiden(reinterpret_cast<const char*>(__s));
return __os;
}
template <class _Traits>
inline basic_ostream<char, _Traits>&
operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __s) {
__os._M_put_nowiden(reinterpret_cast<const char*>(__s));
return __os;
}
template <class _CharT, class _Traits>
inline basic_ostream<_CharT, _Traits>&
endl(basic_ostream<_CharT, _Traits>& __os) {
__os.put(__os.widen('\n'));
__os.flush();
return __os;
}
template <class _CharT, class _Traits>
inline basic_ostream<_CharT, _Traits>&
ends(basic_ostream<_CharT, _Traits>& __os) {
__os.put(_CharT());
return __os;
}
template <class _CharT, class _Traits>
inline basic_ostream<_CharT, _Traits>&
flush(basic_ostream<_CharT, _Traits>& __os) {
__os.flush();
return __os;
}
}
namespace _STL {
template <class _CharT, class _OutputIter = ostreambuf_iterator<_CharT, char_traits<_CharT> > >
class num_put: public locale::facet
{
friend class _Locale;
public:
typedef _CharT char_type;
typedef _OutputIter iter_type;
explicit num_put(size_t __refs = 0) : locale::facet(__refs) {}
iter_type put(iter_type __s, ios_base& __f, char_type __fill,
bool __val) const {
return do_put(__s, __f, __fill, __val);
}
iter_type put(iter_type __s, ios_base& __f, char_type __fill,
long __val) const {
return do_put(__s, __f, __fill, __val);
}
iter_type put(iter_type __s, ios_base& __f, char_type __fill,
unsigned long __val) const {
return do_put(__s, __f, __fill, __val);
}
iter_type put(iter_type __s, ios_base& __f, char_type __fill,
long long __val) const {
return do_put(__s, __f, __fill, __val);
}
iter_type put(iter_type __s, ios_base& __f, char_type __fill,
unsigned long long __val) const {
return do_put(__s, __f, __fill, __val);
}
iter_type put(iter_type __s, ios_base& __f, char_type __fill,
double __val) const {
return do_put(__s, __f, __fill, (double)__val);
}
iter_type put(iter_type __s, ios_base& __f, char_type __fill,
long double __val) const {
return do_put(__s, __f, __fill, __val);
}
iter_type put(iter_type __s, ios_base& __f, char_type __fill,
const void * __val) const {
return do_put(__s, __f, __fill, __val);
}
static locale::id id;
protected:
~num_put() {}
virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, bool __val) const;
virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, long __val) const;
virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, unsigned long __val) const;
virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, double __val) const;
virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, long double __val) const;
virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, long long __val) const;
virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
unsigned long long __val) const ;
virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, const void* __val) const;
};
template <class _Integer>
char*
__write_integer_backward(char* __buf, ios_base::fmtflags __flags, _Integer __x);
void __string_to_float(const string&, float&);
void __string_to_float(const string&, double&);
extern char* __write_float(char*, ios_base::fmtflags, int, double);
void __string_to_float(const string&, long double&);
extern char* __write_float(char*, ios_base::fmtflags, int, long double);
extern wchar_t* __convert_float_buffer(const char*, const char*, wchar_t*, const ctype<wchar_t>&, wchar_t);
extern void __adjust_float_buffer(char*, char*, char);
extern char*
__write_integer(char* buf, ios_base::fmtflags flags, long x);
extern ptrdiff_t __insert_grouping(char* first, char* last, const string&, char, char, char, int);
extern ptrdiff_t __insert_grouping(wchar_t*, wchar_t*, const string&, wchar_t, wchar_t, wchar_t, int);
}
namespace _STL {
enum float_round_style {
round_indeterminate = -1,
round_toward_zero = 0,
round_to_nearest = 1,
round_toward_infinity = 2,
round_toward_neg_infinity = 3
};
enum float_denorm_style {
denorm_indeterminate = -1,
denorm_absent = 0,
denorm_present = 1
};
template <class __number>
class _Numeric_limits_base {
public:
static __number ( min)() { return __number(); }
static __number ( max)() { return __number(); }
static const int
digits = 0,
digits10 = 0,
radix = 0,
min_exponent = 0,
min_exponent10 = 0,
max_exponent = 0,
max_exponent10 = 0
;
static const float_denorm_style has_denorm = denorm_absent;
static const float_round_style round_style = round_toward_zero;
static const bool
is_specialized = false,
is_signed = false,
is_integer = false,
is_exact = false,
has_infinity = false,
has_quiet_NaN = false,
has_signaling_NaN = false,
has_denorm_loss = false,
is_iec559 = false,
is_bounded = false,
is_modulo = false,
traps = false,
tinyness_before = false
;
static __number epsilon() { return __number(); }
static __number round_error() { return __number(); }
static __number infinity() { return __number(); }
static __number quiet_NaN() { return __number(); }
static __number signaling_NaN() { return __number(); }
static __number denorm_min() { return __number(); }
};
template <class _Int,
_Int __imin,
_Int __imax,
int __idigits, bool __ismod>
class _Integer_limits : public _Numeric_limits_base<_Int>
{
public:
static _Int ( min) () { return (_Int)__imin; }
static _Int ( max) () { return (_Int)__imax; }
static const int
digits = (__idigits < 0) ?
((int)((sizeof(_Int) * (8))) - ((__imin == 0) ? 0 : 1))
: (__idigits),
digits10 = (digits * 301UL) / 1000,
radix = 2
;
static const bool
is_specialized = true,
is_signed = (__imin != 0),
is_integer = true,
is_exact = true,
is_bounded = true,
is_modulo = __ismod
;
};
template <class __number,
int __Digits, int __Digits10,
int __MinExp, int __MaxExp,
int __MinExp10, int __MaxExp10,
bool __IsIEC559,
float_round_style __RoundStyle>
class _Floating_limits : public _Numeric_limits_base<__number>
{
public:
static const int
digits = __Digits,
digits10 = __Digits10,
radix = ( 2 ),
min_exponent = __MinExp,
max_exponent = __MaxExp,
min_exponent10 = __MinExp10,
max_exponent10 = __MaxExp10
;
static const float_denorm_style has_denorm = denorm_indeterminate;
static const float_round_style round_style = __RoundStyle;
static const bool
is_specialized = true,
is_signed = true,
has_infinity = true,
has_quiet_NaN = true,
has_signaling_NaN= true,
has_denorm_loss = false,
is_iec559 = __IsIEC559,
is_bounded = true,
traps = true,
tinyness_before= false
;
};
template<class _Tp>
class numeric_limits : public _Numeric_limits_base<_Tp> {};
template<>
class numeric_limits<bool>
: public _Integer_limits<bool, false, true, 1, false>
{};
template<>
class numeric_limits<char>
: public _Integer_limits<char, (-128), 127, -1, true>
{};
template<>
class numeric_limits<signed char>
: public _Integer_limits<signed char, (-128), 127, -1, true>
{};
template<>
class numeric_limits<unsigned char>
: public _Integer_limits<unsigned char, 0, 255, -1, true>
{};
template<>
class numeric_limits<wchar_t>
: public _Integer_limits<wchar_t, (-2147483647l - 1l), (2147483647l), -1, true>
{};
template<>
class numeric_limits<short>
: public _Integer_limits<short, (-32767 -1), 32767, -1, true>
{};
template<>
class numeric_limits<unsigned short>
: public _Integer_limits<unsigned short, 0, (32767 * 2 + 1), -1, true>
{};
template<>
class numeric_limits<int>
: public _Integer_limits<int, (-2147483647 -1), 2147483647, -1, true>
{};
template<>
class numeric_limits<unsigned int>
: public _Integer_limits<unsigned int, 0, (2147483647 * 2U + 1), -1, true>
{};
template<>
class numeric_limits<long>
: public _Integer_limits<long, (-2147483647L -1), 2147483647L, -1, true>
{};
template<>
class numeric_limits<unsigned long>
: public _Integer_limits<unsigned long, 0, (2147483647L * 2UL + 1), -1, true>
{};
template<>
class numeric_limits<long long>
: public _Numeric_limits_base<long long>
{
public:
static long long ( min) () { return (-0x7fffffffffffffffLL -1LL); }
static long long ( max) () { return 0x7fffffffffffffffLL; }
static const int
digits = ((int)((sizeof(long long) * (8))) - 1),
digits10 = (digits * 301UL) / 1000,
radix = 2
;
static const bool
is_specialized = true,
is_signed = true,
is_integer = true,
is_exact = true,
is_bounded = true,
is_modulo = true
;
};
template<>
class numeric_limits<unsigned long long>
: public _Numeric_limits_base<unsigned long long>
{
public:
static unsigned long long ( min) () { return 0ULL; }
static unsigned long long ( max) () { return 0xffffffffffffffffULL; }
static const int
digits = ((int)((sizeof(unsigned long long) * (8)))),
digits10 = (digits * 301UL) / 1000,
radix = 2
;
static const bool
is_specialized = true,
is_signed = false,
is_integer = true,
is_exact = true,
is_bounded = true,
is_modulo = true
;
};
union _F_rep
{
unsigned short rep[2];
float val;
};
union _D_rep
{
unsigned short rep[4];
double val;
};
union _L_rep
{
unsigned short rep[8];
long double val;
};
template <class __dummy>
class _LimG
{
public:
static const _F_rep _F_inf;
static const _F_rep _F_qNaN;
static const _F_rep _F_sNaN;
static const _D_rep _D_inf;
static const _D_rep _D_qNaN;
static const _D_rep _D_sNaN;
static const _L_rep _L_inf;
static const _L_rep _L_qNaN;
static const _L_rep _L_sNaN;
};
template<> class numeric_limits<float>
: public _Floating_limits<float,
24,
6,
(-125),
128,
(-37),
38,
true,
round_to_nearest>
{
public:
static float ( min) () { return 1.17549435e-38F; }
static float denorm_min() { return 1.17549435e-38F; }
static float ( max) () { using namespace __std_alias ; return 3.40282347e+38F; }
static float epsilon() { return 1.19209290e-07F; }
static float round_error() { return 0.5f; }
static float infinity() { return _LimG<bool>::_F_inf.val; }
static float quiet_NaN() { return _LimG<bool>::_F_qNaN.val; }
static float signaling_NaN() { return _LimG<bool>::_F_sNaN.val; }
};
template<> class numeric_limits<double>
: public _Floating_limits<double,
53,
15,
(-1021),
1024,
(-307),
308,
true,
round_to_nearest>
{
public:
static double ( min)() { return 2.2250738585072014e-308; }
static double denorm_min() { return 2.2250738585072014e-308; }
static double ( max)() { using namespace __std_alias ; return 1.7976931348623157e+308; }
static double epsilon() { return 2.2204460492503131e-16; }
static double round_error() { return 0.5; }
static double infinity() { return _LimG<bool>::_D_inf.val; }
static double quiet_NaN(){ return _LimG<bool>::_D_qNaN.val; }
static double signaling_NaN() { return _LimG<bool>::_D_sNaN.val; }
};
template<>
class numeric_limits<long double>
: public _Floating_limits<long double,
64,
18,
(-16381),
16384,
(-4931),
4932,
false,
round_to_nearest>
{
public:
static long double ( min) () { using namespace __std_alias ; return 3.36210314311209350626e-4932L; }
static long double denorm_min() { using namespace __std_alias ; return 3.36210314311209350626e-4932L; }
static long double ( max) () { using namespace __std_alias ; return 1.18973149535723176502e+4932L; }
static long double epsilon() { return 1.08420217248550443401e-19L; }
static long double round_error() { return 4; }
static long double infinity() { return _LimG<bool>::_L_inf.val; }
static long double quiet_NaN() { return _LimG<bool>::_L_qNaN.val; }
static long double signaling_NaN() { return _LimG<bool>::_L_sNaN.val; }
};
}
namespace _STL {
template <class __number> const bool _Numeric_limits_base<__number>:: is_specialized;
template <class __number> const int _Numeric_limits_base<__number>:: digits;
template <class __number> const int _Numeric_limits_base<__number>:: digits10;
template <class __number> const bool _Numeric_limits_base<__number>:: is_signed;
template <class __number> const bool _Numeric_limits_base<__number>:: is_integer;
template <class __number> const bool _Numeric_limits_base<__number>:: is_exact;
template <class __number> const int _Numeric_limits_base<__number>:: radix;
template <class __number> const int _Numeric_limits_base<__number>:: min_exponent;
template <class __number> const int _Numeric_limits_base<__number>:: max_exponent;
template <class __number> const int _Numeric_limits_base<__number>:: min_exponent10;
template <class __number> const int _Numeric_limits_base<__number>:: max_exponent10;
template <class __number> const bool _Numeric_limits_base<__number>:: has_infinity;
template <class __number> const bool _Numeric_limits_base<__number>:: has_quiet_NaN;
template <class __number> const bool _Numeric_limits_base<__number>:: has_signaling_NaN;
template <class __number> const float_denorm_style _Numeric_limits_base<__number>:: has_denorm;
template <class __number> const bool _Numeric_limits_base<__number>:: has_denorm_loss;
template <class __number> const bool _Numeric_limits_base<__number>:: is_iec559;
template <class __number> const bool _Numeric_limits_base<__number>:: is_bounded;
template <class __number> const bool _Numeric_limits_base<__number>:: is_modulo;
template <class __number> const bool _Numeric_limits_base<__number>:: traps;
template <class __number> const bool _Numeric_limits_base<__number>:: tinyness_before;
template <class __number> const float_round_style _Numeric_limits_base<__number>:: round_style;
template <class _Int, _Int __imin, _Int __imax, int __idigits, bool __ismod> const bool _Integer_limits<_Int, __imin, __imax, __idigits, __ismod>:: is_specialized;
template <class _Int, _Int __imin, _Int __imax, int __idigits, bool __ismod> const int _Integer_limits<_Int, __imin, __imax, __idigits, __ismod>:: digits;
template <class _Int, _Int __imin, _Int __imax, int __idigits, bool __ismod> const int _Integer_limits<_Int, __imin, __imax, __idigits, __ismod>:: digits10;
template <class _Int, _Int __imin, _Int __imax, int __idigits, bool __ismod> const bool _Integer_limits<_Int, __imin, __imax, __idigits, __ismod>:: is_signed;
template <class _Int, _Int __imin, _Int __imax, int __idigits, bool __ismod> const bool _Integer_limits<_Int, __imin, __imax, __idigits, __ismod>:: is_integer;
template <class _Int, _Int __imin, _Int __imax, int __idigits, bool __ismod> const bool _Integer_limits<_Int, __imin, __imax, __idigits, __ismod>:: is_exact;
template <class _Int, _Int __imin, _Int __imax, int __idigits, bool __ismod> const int _Integer_limits<_Int, __imin, __imax, __idigits, __ismod>:: radix;
template <class _Int, _Int __imin, _Int __imax, int __idigits, bool __ismod> const bool _Integer_limits<_Int, __imin, __imax, __idigits, __ismod>:: is_bounded;
template <class _Int, _Int __imin, _Int __imax, int __idigits, bool __ismod> const bool _Integer_limits<_Int, __imin, __imax, __idigits, __ismod>:: is_modulo;
template <class __number, int __Digits, int __Digits10, int __MinExp, int __MaxExp, int __MinExp10, int __MaxExp10, bool __IsIEC559, float_round_style __RoundStyle> const bool _Floating_limits< __number, __Digits, __Digits10, __MinExp, __MaxExp, __MinExp10, __MaxExp10, __IsIEC559, __RoundStyle>:: is_specialized;
template <class __number, int __Digits, int __Digits10, int __MinExp, int __MaxExp, int __MinExp10, int __MaxExp10, bool __IsIEC559, float_round_style __RoundStyle> const int _Floating_limits< __number, __Digits, __Digits10, __MinExp, __MaxExp, __MinExp10, __MaxExp10, __IsIEC559, __RoundStyle>:: digits;
template <class __number, int __Digits, int __Digits10, int __MinExp, int __MaxExp, int __MinExp10, int __MaxExp10, bool __IsIEC559, float_round_style __RoundStyle> const int _Floating_limits< __number, __Digits, __Digits10, __MinExp, __MaxExp, __MinExp10, __MaxExp10, __IsIEC559, __RoundStyle>:: digits10;
template <class __number, int __Digits, int __Digits10, int __MinExp, int __MaxExp, int __MinExp10, int __MaxExp10, bool __IsIEC559, float_round_style __RoundStyle> const bool _Floating_limits< __number, __Digits, __Digits10, __MinExp, __MaxExp, __MinExp10, __MaxExp10, __IsIEC559, __RoundStyle>:: is_signed;
template <class __number, int __Digits, int __Digits10, int __MinExp, int __MaxExp, int __MinExp10, int __MaxExp10, bool __IsIEC559, float_round_style __RoundStyle> const int _Floating_limits< __number, __Digits, __Digits10, __MinExp, __MaxExp, __MinExp10, __MaxExp10, __IsIEC559, __RoundStyle>:: radix;
template <class __number, int __Digits, int __Digits10, int __MinExp, int __MaxExp, int __MinExp10, int __MaxExp10, bool __IsIEC559, float_round_style __RoundStyle> const int _Floating_limits< __number, __Digits, __Digits10, __MinExp, __MaxExp, __MinExp10, __MaxExp10, __IsIEC559, __RoundStyle>:: min_exponent;
template <class __number, int __Digits, int __Digits10, int __MinExp, int __MaxExp, int __MinExp10, int __MaxExp10, bool __IsIEC559, float_round_style __RoundStyle> const int _Floating_limits< __number, __Digits, __Digits10, __MinExp, __MaxExp, __MinExp10, __MaxExp10, __IsIEC559, __RoundStyle>:: max_exponent;
template <class __number, int __Digits, int __Digits10, int __MinExp, int __MaxExp, int __MinExp10, int __MaxExp10, bool __IsIEC559, float_round_style __RoundStyle> const int _Floating_limits< __number, __Digits, __Digits10, __MinExp, __MaxExp, __MinExp10, __MaxExp10, __IsIEC559, __RoundStyle>:: min_exponent10;
template <class __number, int __Digits, int __Digits10, int __MinExp, int __MaxExp, int __MinExp10, int __MaxExp10, bool __IsIEC559, float_round_style __RoundStyle> const int _Floating_limits< __number, __Digits, __Digits10, __MinExp, __MaxExp, __MinExp10, __MaxExp10, __IsIEC559, __RoundStyle>:: max_exponent10;
template <class __number, int __Digits, int __Digits10, int __MinExp, int __MaxExp, int __MinExp10, int __MaxExp10, bool __IsIEC559, float_round_style __RoundStyle> const bool _Floating_limits< __number, __Digits, __Digits10, __MinExp, __MaxExp, __MinExp10, __MaxExp10, __IsIEC559, __RoundStyle>:: has_infinity;
template <class __number, int __Digits, int __Digits10, int __MinExp, int __MaxExp, int __MinExp10, int __MaxExp10, bool __IsIEC559, float_round_style __RoundStyle> const bool _Floating_limits< __number, __Digits, __Digits10, __MinExp, __MaxExp, __MinExp10, __MaxExp10, __IsIEC559, __RoundStyle>:: has_quiet_NaN;
template <class __number, int __Digits, int __Digits10, int __MinExp, int __MaxExp, int __MinExp10, int __MaxExp10, bool __IsIEC559, float_round_style __RoundStyle> const bool _Floating_limits< __number, __Digits, __Digits10, __MinExp, __MaxExp, __MinExp10, __MaxExp10, __IsIEC559, __RoundStyle>:: has_signaling_NaN;
template <class __number, int __Digits, int __Digits10, int __MinExp, int __MaxExp, int __MinExp10, int __MaxExp10, bool __IsIEC559, float_round_style __RoundStyle> const float_denorm_style _Floating_limits< __number, __Digits, __Digits10, __MinExp, __MaxExp, __MinExp10, __MaxExp10, __IsIEC559, __RoundStyle>:: has_denorm;
template <class __number, int __Digits, int __Digits10, int __MinExp, int __MaxExp, int __MinExp10, int __MaxExp10, bool __IsIEC559, float_round_style __RoundStyle> const bool _Floating_limits< __number, __Digits, __Digits10, __MinExp, __MaxExp, __MinExp10, __MaxExp10, __IsIEC559, __RoundStyle>:: has_denorm_loss;
template <class __number, int __Digits, int __Digits10, int __MinExp, int __MaxExp, int __MinExp10, int __MaxExp10, bool __IsIEC559, float_round_style __RoundStyle> const bool _Floating_limits< __number, __Digits, __Digits10, __MinExp, __MaxExp, __MinExp10, __MaxExp10, __IsIEC559, __RoundStyle>:: is_iec559;
template <class __number, int __Digits, int __Digits10, int __MinExp, int __MaxExp, int __MinExp10, int __MaxExp10, bool __IsIEC559, float_round_style __RoundStyle> const bool _Floating_limits< __number, __Digits, __Digits10, __MinExp, __MaxExp, __MinExp10, __MaxExp10, __IsIEC559, __RoundStyle>:: is_bounded;
template <class __number, int __Digits, int __Digits10, int __MinExp, int __MaxExp, int __MinExp10, int __MaxExp10, bool __IsIEC559, float_round_style __RoundStyle> const bool _Floating_limits< __number, __Digits, __Digits10, __MinExp, __MaxExp, __MinExp10, __MaxExp10, __IsIEC559, __RoundStyle>:: traps;
template <class __number, int __Digits, int __Digits10, int __MinExp, int __MaxExp, int __MinExp10, int __MaxExp10, bool __IsIEC559, float_round_style __RoundStyle> const bool _Floating_limits< __number, __Digits, __Digits10, __MinExp, __MaxExp, __MinExp10, __MaxExp10, __IsIEC559, __RoundStyle>:: tinyness_before;
template <class __number, int __Digits, int __Digits10, int __MinExp, int __MaxExp, int __MinExp10, int __MaxExp10, bool __IsIEC559, float_round_style __RoundStyle> const float_round_style _Floating_limits< __number, __Digits, __Digits10, __MinExp, __MaxExp, __MinExp10, __MaxExp10, __IsIEC559, __RoundStyle>:: round_style;
}
namespace _STL {
template <class _CharT, class _OutputIter,class _Float>
_OutputIter
_M_do_put_float(_OutputIter __s, ios_base& __f, _CharT __fill,_Float __x);
template <class _CharT, class _OutputIter>
_OutputIter
__copy_float_and_fill(const _CharT* __first, const _CharT* __last,
_OutputIter __out,
ios_base::fmtflags __flags,
streamsize __width, _CharT __fill,
_CharT __xplus, _CharT __xminus) {
if (__width <= __last - __first)
return copy(__first, __last, __out);
else {
streamsize __pad = __width - (__last - __first);
ios_base::fmtflags __dir = __flags & ios_base::adjustfield;
if (__dir == ios_base::left) {
__out = copy(__first, __last, __out);
return fill_n(__out, __pad, __fill);
}
else if (__dir == ios_base::internal && __first != __last &&
(*__first == __xplus || *__first == __xminus)) {
*__out++ = *__first++;
__out = fill_n(__out, __pad, __fill);
return copy(__first, __last, __out);
}
else {
__out = fill_n(__out, __pad, __fill);
return copy(__first, __last, __out);
}
}
}
template <class _OutputIter>
_OutputIter
__put_float(char* __ibuf, char* __iend, _OutputIter __out,
ios_base& __f, wchar_t __fill,
wchar_t __decimal_point,
wchar_t __sep, const string& __grouping)
{
const ctype<wchar_t>& __ct = *(ctype<wchar_t>*)__f._M_ctype_facet() ;
wchar_t __wbuf[128];
wchar_t* __eend = __convert_float_buffer(__ibuf, __iend, __wbuf,
__ct, __decimal_point);
if (__grouping.size() != 0) {
string __new_grouping = __grouping;
wchar_t* __decimal_pos = find(__wbuf, __eend, __decimal_point);
if (__grouping.size() == 1)
__new_grouping.push_back(__grouping[0]);
__new_grouping[0] += static_cast<char>(__eend - __decimal_pos);
ptrdiff_t __len = __insert_grouping(__wbuf, __eend, __new_grouping,
__sep,
__ct.widen('+'), __ct.widen('-'),
0);
__eend = __wbuf + __len;
}
return __copy_float_and_fill(__wbuf, __eend, __out,
__f.flags(), __f.width(0), __fill,
__ct.widen('+'), __ct.widen('-'));
}
template <class _OutputIter>
_OutputIter
__put_float(char* __ibuf, char* __iend, _OutputIter __out,
ios_base& __f, char __fill,
char __decimal_point,
char __sep, const string& __grouping)
{
__adjust_float_buffer(__ibuf, __iend, __decimal_point);
if (__grouping.size() != 0) {
string __new_grouping = __grouping;
const char * __decimal_pos = find(__ibuf, __iend, __decimal_point);
if (__grouping.size() == 1)
__new_grouping.push_back(__grouping[0]);
__new_grouping[0] += static_cast<char>((__iend - __decimal_pos));
ptrdiff_t __len = __insert_grouping(__ibuf, __iend, __new_grouping,
__sep, '+', '-', 0);
__iend = __ibuf + __len;
}
return __copy_float_and_fill(__ibuf, __iend, __out,
__f.flags(), __f.width(0), __fill, '+', '-');
}
template <class _CharT, class _OutputIter, class _Float>
_OutputIter
_M_do_put_float(_OutputIter __s, ios_base& __f,
_CharT __fill, _Float __x)
{
char __buf[128];
char* __iend = __write_float(__buf, __f.flags(), (int)__f.precision(), __x);
const numpunct<_CharT>& __np = *(const numpunct<_CharT>*)__f._M_numpunct_facet();
return __put_float(__buf, __iend, __s, __f, __fill,
__np.decimal_point(),
__np.thousands_sep(), __f._M_grouping());
}
template <class _CharT, class _OutputIter>
_OutputIter
__copy_integer_and_fill(const _CharT* __buf, ptrdiff_t __len,
_OutputIter __out,
ios_base::fmtflags __flg, streamsize __wid, _CharT __fill,
_CharT __xplus, _CharT __xminus)
{
if (__len >= __wid)
return copy(__buf, __buf + __len, __out);
else {
ptrdiff_t __pad = __wid - __len;
ios_base::fmtflags __dir = __flg & ios_base::adjustfield;
if (__dir == ios_base::left) {
__out = copy(__buf, __buf + __len, __out);
return fill_n(__out, __pad, __fill);
}
else if (__dir == ios_base::internal && __len != 0 &&
(__buf[0] == __xplus || __buf[0] == __xminus)) {
*__out++ = __buf[0];
__out = fill_n(__out, __pad, __fill);
return copy(__buf + 1, __buf + __len, __out);
}
else if (__dir == ios_base::internal && __len >= 2 &&
(__flg & ios_base::showbase) &&
(__flg & ios_base::basefield) == ios_base::hex) {
*__out++ = __buf[0];
*__out++ = __buf[1];
__out = fill_n(__out, __pad, __fill);
return copy(__buf + 2, __buf + __len, __out);
}
else {
__out = fill_n(__out, __pad, __fill);
return copy(__buf, __buf + __len, __out);
}
}
}
template <class _OutputIter>
_OutputIter
__put_integer(char* __buf, char* __iend, _OutputIter __s,
ios_base& __f,
ios_base::fmtflags __flags, wchar_t __fill)
{
locale __loc = __f.getloc();
const ctype<wchar_t>& __ct = *(const ctype<wchar_t>*)__f._M_ctype_facet();
wchar_t __xplus = __ct.widen('+');
wchar_t __xminus = __ct.widen('-');
wchar_t __wbuf[64];
__ct.widen(__buf, __iend, __wbuf);
ptrdiff_t __len = __iend - __buf;
wchar_t* __eend = __wbuf + __len;
const numpunct<wchar_t>& __np = *(const numpunct<wchar_t>*)__f._M_numpunct_facet();
const string& __grouping = __f._M_grouping();
if (!__grouping.empty()) {
int __basechars;
if (__flags & ios_base::showbase)
switch (__flags & ios_base::basefield) {
case ios_base::hex: __basechars = 2; break;
case ios_base::oct: __basechars = 1; break;
default: __basechars = 0;
}
else
__basechars = 0;
__len = __insert_grouping(__wbuf, __eend, __grouping, __np.thousands_sep(),
__xplus, __xminus, __basechars);
}
return __copy_integer_and_fill((wchar_t*)__wbuf, __len, __s,
__flags, __f.width(0), __fill, __xplus, __xminus);
}
template <class _OutputIter>
_OutputIter
__put_integer(char* __buf, char* __iend, _OutputIter __s,
ios_base& __f, ios_base::fmtflags __flags, char __fill)
{
ptrdiff_t __len = __iend - __buf;
const numpunct<char>& __np = *(const numpunct<char>*)__f._M_numpunct_facet();
const string& __grouping = __f._M_grouping();
if (!__grouping.empty()) {
int __basechars;
if (__flags & ios_base::showbase)
switch (__flags & ios_base::basefield) {
case ios_base::hex: __basechars = 2; break;
case ios_base::oct: __basechars = 1; break;
default: __basechars = 0;
}
else
__basechars = 0;
char __grpbuf[64];
copy(__buf, __iend, (char *) __grpbuf);
__buf = __grpbuf;
__iend = __grpbuf + __len;
__len = __insert_grouping(__buf, __iend, __grouping, __np.thousands_sep(),
'+', '-', __basechars);
}
return __copy_integer_and_fill(__buf, __len, __s, __flags, __f.width(0), __fill, '+', '-');
}
typedef long long __max_int_t;
typedef unsigned long long __umax_int_t;
extern const char __hex_char_table_lo[];
extern const char __hex_char_table_hi[];
template <class _Integer>
inline char*
__write_decimal_backward(char* __ptr, _Integer __x, ios_base::fmtflags __flags, const __true_type& )
{
__max_int_t __temp = __x;
const bool __negative = __x < 0 ;
if (__negative) __temp = -__temp;
for (; __temp != 0; __temp /= 10)
*--__ptr = (int)(__temp % 10) + '0';
if (__negative)
*--__ptr = '-';
else if (__flags & ios_base::showpos)
*--__ptr = '+';
return __ptr;
}
template <class _Integer>
inline char*
__write_decimal_backward(char* __ptr, _Integer __x, ios_base::fmtflags, const __false_type& )
{
for (; __x != 0; __x /= 10)
*--__ptr = (int)(__x % 10) + '0';
return __ptr;
}
template <class _Integer>
char*
__write_integer_backward(char* __buf, ios_base::fmtflags __flags, _Integer __x)
{
char* __ptr = __buf;
__umax_int_t __temp;
if (__x == 0) {
*--__ptr = '0';
if ((__flags & ios_base::showpos) && ( (__flags & (ios_base::hex | ios_base::oct)) == 0 ))
*--__ptr = '+';
}
else {
switch (__flags & ios_base::basefield) {
case ios_base::oct:
__temp = __x;
if ( sizeof(__x) < 8 && sizeof(__umax_int_t) >= 8 )
__temp &= 0xFFFFFFFF;
for (; __temp != 0; __temp >>=3)
*--__ptr = (((unsigned)__temp)& 0x7) + '0';
if (__flags & ios_base::showbase)
*--__ptr = '0';
break;
case ios_base::hex:
{
const char* __table_ptr = (__flags & ios_base::uppercase) ?
__hex_char_table_hi : __hex_char_table_lo;
__temp = __x;
if ( sizeof(__x) < 8 && sizeof(__umax_int_t) >= 8 )
__temp &= 0xFFFFFFFF;
for (; __temp != 0; __temp >>=4)
*--__ptr = __table_ptr[((unsigned)__temp & 0xF)];
if (__flags & ios_base::showbase) {
*--__ptr = __table_ptr[16];
*--__ptr = '0';
}
}
break;
default:
{
typedef typename __bool2type<numeric_limits<_Integer>::is_signed>::_Ret _IsSigned;
__ptr = __write_decimal_backward(__ptr, __x, __flags, _IsSigned());
}
break;
}
}
return __ptr;
}
template <class _CharT, class _OutputIterator>
locale::id num_put<_CharT, _OutputIterator>::id;
template <class _CharT, class _OutputIter>
_OutputIter
num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f,
char_type __fill, bool __val) const {
if (!(__f.flags() & ios_base::boolalpha))
return this->do_put(__s, __f, __fill, static_cast<long>(__val));
locale __loc = __f.getloc();
const numpunct<_CharT>& __np = *(const numpunct<_CharT>*)__f._M_numpunct_facet();
basic_string<_CharT> __str = __val ? __np.truename() : __np.falsename();
ios_base::fmtflags __flags = __f.flags();
if ((__flags & ios_base::adjustfield) == ios_base::internal)
__flags = (__flags & ~ios_base::adjustfield) | ios_base::right;
return __copy_integer_and_fill(__str.c_str(), __str.size(), __s,
__flags, __f.width(0), __fill,
(_CharT) 0, (_CharT) 0);
}
template <class _CharT, class _OutputIter>
_OutputIter
num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
long __val) const {
char __buf[64];
ios_base::fmtflags __flags = __f.flags();
char* __ibeg = __write_integer_backward((char*)__buf+64, __flags, __val);
return __put_integer(__ibeg, (char*)__buf+64, __s, __f, __flags, __fill);
}
template <class _CharT, class _OutputIter>
_OutputIter
num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
unsigned long __val) const {
char __buf[64];
ios_base::fmtflags __flags = __f.flags();
char* __ibeg = __write_integer_backward((char*)__buf+64, __flags, __val);
return __put_integer(__ibeg, (char*)__buf+64, __s, __f, __flags, __fill);
}
template <class _CharT, class _OutputIter>
_OutputIter
num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
double __val) const {
return _M_do_put_float(__s, __f, __fill, __val);
}
template <class _CharT, class _OutputIter>
_OutputIter
num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
long double __val) const {
return _M_do_put_float(__s, __f, __fill, __val);
}
template <class _CharT, class _OutputIter>
_OutputIter
num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
long long __val) const {
char __buf[64];
ios_base::fmtflags __flags = __f.flags();
char* __ibeg = __write_integer_backward((char*)__buf+64, __flags, __val);
return __put_integer(__ibeg, (char*)__buf+64, __s, __f, __flags, __fill);
}
template <class _CharT, class _OutputIter>
_OutputIter
num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
unsigned long long __val) const {
char __buf[64];
ios_base::fmtflags __flags = __f.flags();
char* __ibeg = __write_integer_backward((char*)__buf+64, __flags, __val);
return __put_integer(__ibeg, (char*)__buf+64, __s, __f, __flags, __fill);
}
template <class _CharT, class _OutputIter>
_OutputIter
num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT ,
const void* __val) const {
const ctype<_CharT>& __c_type = *(const ctype<_CharT>*)__f._M_ctype_facet();
ios_base::fmtflags __save_flags = __f.flags();
__f.setf(ios_base::hex, ios_base::basefield);
__f.setf(ios_base::showbase);
__f.setf(ios_base::internal, ios_base::adjustfield);
__f.width((sizeof(void*) * 2) + 2);
_OutputIter result = this->do_put(__s, __f, __c_type.widen('0'), reinterpret_cast<unsigned long long>(__val));
__f.flags(__save_flags);
return result;
}
}
namespace _STL {
template <class _CharT, class _Traits>
bool
_M_init(basic_ostream<_CharT, _Traits>& __str) {
if (__str.good()) {
if (!__str.rdbuf())
__str.setstate(ios_base::badbit);
if (__str.tie())
__str.tie()->flush();
return __str.good();
} else
return false;
}
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>
::basic_ostream(basic_streambuf<_CharT, _Traits>* __buf)
: basic_ios<_CharT, _Traits>()
{
this->init(__buf);
}
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>::~basic_ostream()
{}
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<_CharT, _Traits>* __from)
{
sentry __sentry(*this);
if (__sentry) {
if (__from) {
bool __any_inserted = __from->gptr() != __from->egptr()
? this->_M_copy_buffered(__from, this->rdbuf())
: this->_M_copy_unbuffered(__from, this->rdbuf());
if (!__any_inserted)
this->setstate(ios_base::failbit);
}
else
this->setstate(ios_base::badbit);
}
return *this;
}
template <class _CharT, class _Traits>
bool basic_ostream<_CharT, _Traits>
::_M_copy_buffered(basic_streambuf<_CharT, _Traits>* __from,
basic_streambuf<_CharT, _Traits>* __to)
{
bool __any_inserted = false;
while (__from->egptr() != __from->gptr()) {
const ptrdiff_t __avail = __from->egptr() - __from->gptr();
streamsize __nwritten;
try {
__nwritten = __to->sputn(__from->gptr(), __avail);
__from->gbump((int)__nwritten);
}
catch(...) {
this->_M_handle_exception(ios_base::badbit);
return __any_inserted;
}
if (__nwritten == __avail) {
try {
if (this->_S_eof(__from->sgetc()))
return true;
else
__any_inserted = true;
}
catch(...) {
this->_M_handle_exception(ios_base::failbit);
return false;
}
}
else if (__nwritten != 0)
return true;
else
return __any_inserted;
}
return __any_inserted || this->_M_copy_unbuffered(__from, __to);
}
template <class _CharT, class _Traits>
bool basic_ostream<_CharT, _Traits>
::_M_copy_unbuffered(basic_streambuf<_CharT, _Traits>* __from,
basic_streambuf<_CharT, _Traits>* __to)
{
bool __any_inserted = false;
while (true) {
int_type __c;
try {
__c = __from->sbumpc();
}
catch(...) {
this->_M_handle_exception(ios_base::failbit);
return __any_inserted;
}
if (this->_S_eof(__c))
return __any_inserted;
else {
int_type __tmp;
try {
__tmp = __to->sputc(__c);
}
catch(...) {
this->_M_handle_exception(ios_base::badbit);
return __any_inserted;
}
if (this->_S_eof(__tmp)) {
try {
__from->sputbackc(__c);
}
catch(...) {
this->_M_handle_exception(ios_base::badbit);
return __any_inserted;
}
}
else
__any_inserted = true;
}
}
}
template <class _CharT, class _Traits, class _Number>
basic_ostream<_CharT, _Traits>&
_M_put_num(basic_ostream<_CharT, _Traits>& __os, _Number __x)
{
typedef typename basic_ostream<_CharT, _Traits>::sentry _Sentry;
_Sentry __sentry(__os);
bool __failed = true;
if (__sentry) {
try {
typedef num_put<_CharT, ostreambuf_iterator<_CharT, _Traits> > _NumPut;
__failed = (use_facet<_NumPut>(__os.getloc())).put(
ostreambuf_iterator<_CharT, _Traits>(__os.rdbuf()),
__os, __os.fill(),
__x).failed();
}
catch(...) {
__os._M_handle_exception(ios_base::badbit);
}
}
if (__failed)
__os.setstate(ios_base::badbit);
return __os;
}
template <class _CharT, class _Traits>
void basic_ostream<_CharT, _Traits>::_M_put_char(_CharT __c)
{
sentry __sentry(*this);
if (__sentry) {
bool __failed = true;
try {
streamsize __npad = this->width() > 0 ? this->width() - 1 : 0;
if (__npad == 0)
__failed = this->_S_eof(this->rdbuf()->sputc(__c));
else if ((this->flags() & ios_base::adjustfield) == ios_base::left) {
__failed = this->_S_eof(this->rdbuf()->sputc(__c));
__failed = __failed ||
this->rdbuf()->_M_sputnc(this->fill(), __npad) != __npad;
}
else {
__failed = this->rdbuf()->_M_sputnc(this->fill(), __npad) != __npad;
__failed = __failed || this->_S_eof(this->rdbuf()->sputc(__c));
}
this->width(0);
}
catch(...) {
this->_M_handle_exception(ios_base::badbit);
}
if (__failed)
this->setstate(ios_base::badbit);
}
}
template <class _CharT, class _Traits>
void basic_ostream<_CharT, _Traits>::_M_put_nowiden(const _CharT* __s)
{
sentry __sentry(*this);
if (__sentry) {
bool __failed = true;
streamsize __n = _Traits::length(__s);
streamsize __npad = this->width() > __n ? this->width() - __n : 0;
try {
if (__npad == 0)
__failed = this->rdbuf()->sputn(__s, __n) != __n;
else if ((this->flags() & ios_base::adjustfield) == ios_base::left) {
__failed = this->rdbuf()->sputn(__s, __n) != __n;
__failed = __failed ||
this->rdbuf()->_M_sputnc(this->fill(), __npad) != __npad;
}
else {
__failed = this->rdbuf()->_M_sputnc(this->fill(), __npad) != __npad;
__failed = __failed || this->rdbuf()->sputn(__s, __n) != __n;
}
this->width(0);
}
catch(...) {
this->_M_handle_exception(ios_base::badbit);
}
if (__failed)
this->setstate(ios_base::failbit);
}
}
template <class _CharT, class _Traits>
void basic_ostream<_CharT, _Traits>::_M_put_widen(const char* __s)
{
sentry __sentry(*this);
if (__sentry) {
bool __failed = true;
streamsize __n = char_traits<char>::length(__s);
streamsize __npad = this->width() > __n ? this->width() - __n : 0;
try {
if (__npad == 0)
__failed = !this->_M_put_widen_aux(__s, __n);
else if ((this->flags() & ios_base::adjustfield) == ios_base::left) {
__failed = !this->_M_put_widen_aux(__s, __n);
__failed = __failed ||
this->rdbuf()->_M_sputnc(this->fill(), __npad) != __npad;
}
else {
__failed = this->rdbuf()->_M_sputnc(this->fill(), __npad) != __npad;
__failed = __failed || !this->_M_put_widen_aux(__s, __n);
}
this->width(0);
}
catch(...) {
this->_M_handle_exception(ios_base::badbit);
}
if (__failed)
this->setstate(ios_base::failbit);
}
}
template <class _CharT, class _Traits>
bool basic_ostream<_CharT, _Traits>::_M_put_widen_aux(const char* __s,
streamsize __n)
{
basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf();
for ( ; __n > 0 ; --__n)
if (this->_S_eof(__buf->sputc(this->widen(*__s++))))
return false;
return true;
}
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::put(char_type __c)
{
sentry __sentry(*this);
bool __failed = true;
if (__sentry) {
try {
__failed = this->_S_eof(this->rdbuf()->sputc(__c));
}
catch(...) {
this->_M_handle_exception(ios_base::badbit);
}
}
if (__failed)
this->setstate(ios_base::badbit);
return *this;
}
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::write(const char_type* __s, streamsize __n)
{
sentry __sentry(*this);
bool __failed = true;
if (__sentry) {
try {
__failed = this->rdbuf()->sputn(__s, __n) != __n;
}
catch(...) {
this->_M_handle_exception(ios_base::badbit);
}
}
if (__failed)
this->setstate(ios_base::badbit);
return *this;
}
}
namespace _STL {
template <class _CharT, class _Traits>
extern basic_streambuf<_CharT, _Traits>* _M_get_istreambuf(basic_istream<_CharT, _Traits>& ) ;
template<class _CharT, class _Traits>
class istreambuf_iterator
{
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;
typedef input_iterator_tag iterator_category;
typedef _CharT value_type;
typedef typename _Traits::off_type difference_type;
typedef const _CharT* pointer;
typedef const _CharT& reference;
public:
istreambuf_iterator(streambuf_type* __p = 0) { this->_M_init(__p); }
inline istreambuf_iterator(basic_istream<_CharT, _Traits>& __is);
char_type operator*() const { this->_M_getc(); return _M_c; }
istreambuf_iterator<_CharT, _Traits>& operator++() { this->_M_bumpc(); return *this; }
istreambuf_iterator<_CharT, _Traits> operator++(int);
bool equal(const istreambuf_iterator<_CharT, _Traits>& __i) const {
if (this->_M_buf)
this->_M_getc();
if (__i._M_buf)
__i._M_getc();
return this->_M_eof == __i._M_eof;
}
private:
void _M_init(streambuf_type* __p) {
_M_buf = __p;
_M_eof = !__p;
_M_have_c = false;
}
void _M_getc() const {
if (_M_have_c)
return;
int_type __c = _M_buf->sgetc();
_M_c = traits_type::to_char_type(__c);
_M_eof = traits_type::eq_int_type(__c, traits_type::eof());
_M_have_c = true;
}
void _M_bumpc() {
_M_buf->sbumpc();
_M_have_c = false;
}
private:
streambuf_type* _M_buf;
mutable _CharT _M_c;
mutable unsigned char _M_eof;
mutable unsigned char _M_have_c;
};
template<class _CharT, class _Traits>
inline istreambuf_iterator<_CharT, _Traits>::istreambuf_iterator(basic_istream<_CharT, _Traits>& __is)
{ this->_M_init(_M_get_istreambuf(__is)); }
template<class _CharT, class _Traits>
inline bool operator==(const istreambuf_iterator<_CharT, _Traits>& __x,
const istreambuf_iterator<_CharT, _Traits>& __y) {
return __x.equal(__y);
}
template<class _CharT, class _Traits>
inline bool operator!=(const istreambuf_iterator<_CharT, _Traits>& __x,
const istreambuf_iterator<_CharT, _Traits>& __y) {
return !__x.equal(__y);
}
template <class _CharT, class _Traits>
istreambuf_iterator<_CharT, _Traits>
istreambuf_iterator<_CharT, _Traits>::operator++(int) {
istreambuf_iterator<_CharT, _Traits> __tmp = *this;
this->_M_bumpc();
this->_M_have_c = false;
return __tmp;
}
}
namespace _STL {
template <class _CharT, class _Traits, class _Number>
ios_base::iostate
_M_get_num(basic_istream<_CharT, _Traits>& __that, _Number& __val);
struct _No_Skip_WS {};
template <class _CharT, class _Traits>
bool _M_init_skip(basic_istream<_CharT, _Traits>& __is);
template <class _CharT, class _Traits>
bool _M_init_noskip(basic_istream<_CharT, _Traits>& __is);
template <class _CharT, class _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_ios<_CharT, _Traits> _Basic_ios;
typedef basic_istream<_CharT, _Traits> _Self;
typedef basic_ios<_CharT, _Traits>& ( *__ios_fn)(basic_ios<_CharT, _Traits>&);
typedef ios_base& ( *__ios_base_fn)(ios_base&);
typedef _Self& ( *__istream_fn)(_Self&);
public:
explicit basic_istream(basic_streambuf<_CharT, _Traits>* __buf) :
basic_ios<_CharT, _Traits>(), _M_gcount(0) {
this->init(__buf);
}
~basic_istream() {};
public:
public:
_Self& operator>> (__istream_fn __f) { return __f(*this); }
_Self& operator>> (__ios_fn __f) { __f(*this); return *this; }
_Self& operator>> (__ios_base_fn __f) { __f(*this); return *this; }
public:
_Self& operator>> (short& __val) {
long __lval;
unsigned short __uval;
_M_get_num(*this, __lval);
__val = static_cast<short>(__lval);
__uval = __lval;
if ((__val != __lval) && ((long)__uval != __lval))
this->setstate(ios_base::failbit);
return *this;
}
_Self& operator>> (int& __val) {
long __lval;
unsigned int __uval;
_M_get_num(*this, __lval);
__val = __lval;
__uval = __lval;
if ((__val != __lval) && ((long)__uval != __lval))
this->setstate(ios_base::failbit);
return *this;
}
_Self& operator>> (unsigned short& __val) { _M_get_num(*this, __val); return *this; }
_Self& operator>> (unsigned int& __val) { _M_get_num(*this, __val); return *this; }
_Self& operator>> (long& __val) { _M_get_num(*this, __val); return *this; }
_Self& operator>> (unsigned long& __val) { _M_get_num(*this, __val); return *this; }
_Self& operator>> (long long& __val) { _M_get_num(*this, __val); return *this; }
_Self& operator>> (unsigned long long& __val) { _M_get_num(*this, __val); return *this; }
_Self& operator>> (float& __val) { _M_get_num(*this, __val); return *this; }
_Self& operator>> (double& __val) { _M_get_num(*this, __val); return *this; }
_Self& operator>> (long double& __val) { _M_get_num(*this, __val); return *this; }
_Self& operator>> (bool& __val) { _M_get_num(*this, __val); return *this; }
_Self& operator>> (void*& __val) { _M_get_num(*this, __val); return *this; }
public:
_Self& operator>>(basic_streambuf<_CharT, _Traits>*);
public:
streamsize gcount() const { return _M_gcount; }
int_type peek();
public:
int_type get();
_Self& get(char_type& __c);
public:
_Self& get(char_type* __s, streamsize __n, char_type __delim);
_Self& get(char_type* __s, streamsize __n)
{ return get(__s, __n, this->widen('\n')); }
public:
_Self& get(basic_streambuf<_CharT, _Traits>& __buf,
char_type __delim);
_Self& get(basic_streambuf<_CharT, _Traits>& __buf)
{ return get(__buf, this->widen('\n')); }
public:
_Self& getline(char_type* __s, streamsize __n, char_type delim);
_Self& getline(char_type* __s, streamsize __n)
{ return getline(__s, __n, this->widen('\n')); }
public:
_Self& ignore();
_Self& ignore(streamsize __n);
_Self& ignore(streamsize __n, int_type __delim);
_Self& read(char_type* __s, streamsize __n);
streamsize readsome(char_type* __s, streamsize __n);
public:
_Self& putback(char_type __c);
_Self& unget();
public:
int sync();
pos_type tellg();
_Self& seekg(pos_type __pos);
_Self& seekg(off_type, ios_base::seekdir);
public:
void _M_formatted_get(_CharT& __c);
void _M_formatted_get(_CharT* __s);
void _M_skip_whitespace(bool __set_failbit);
private:
streamsize _M_gcount;
public:
class sentry {
typedef sentry _Self;
private:
const bool _M_ok;
public:
typedef _Traits traits_type;
explicit sentry(basic_istream<_CharT, _Traits>& __is,
bool __noskipws = false) :
_M_ok((__noskipws || !(__is.flags() & ios_base::skipws)) ? _M_init_noskip(__is) : _M_init_skip(__is) )
{}
sentry(basic_istream<_CharT, _Traits>& __is, _No_Skip_WS) :
_M_ok(_M_init_noskip(__is)) {}
~sentry() {}
operator bool() const { return _M_ok; }
private:
sentry(const _Self&) : _M_ok(false) {}
void operator=(const _Self&) {}
};
};
template <class _CharT, class _Traits>
inline basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c) {
__in._M_formatted_get(__c);
return __in;
}
template <class _Traits>
inline basic_istream<char, _Traits>&
operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c) {
__in._M_formatted_get(reinterpret_cast<char&>(__c));
return __in;
}
template <class _Traits>
inline basic_istream<char, _Traits>&
operator>>(basic_istream<char, _Traits>& __in, signed char& __c) {
__in._M_formatted_get(reinterpret_cast<char&>(__c));
return __in;
}
template <class _CharT, class _Traits>
inline basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s) {
__in._M_formatted_get(__s);
return __in;
}
template <class _Traits>
inline basic_istream<char, _Traits>&
operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s) {
__in._M_formatted_get(reinterpret_cast<char*>(__s));
return __in;
}
template <class _Traits>
inline basic_istream<char, _Traits>&
operator>>(basic_istream<char, _Traits>& __in, signed char* __s) {
__in._M_formatted_get(reinterpret_cast<char*>(__s));
return __in;
}
template <class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
ws(basic_istream<_CharT, _Traits>& __is);
template <class _CharT, class _Traits>
class basic_iostream
: public basic_istream<_CharT, _Traits>,
public basic_ostream<_CharT, _Traits>
{
public:
typedef basic_ios<_CharT, _Traits> _Basic_ios;
explicit basic_iostream(basic_streambuf<_CharT, _Traits>* __buf);
virtual ~basic_iostream();
};
template <class _CharT, class _Traits>
basic_streambuf<_CharT, _Traits>* _M_get_istreambuf(basic_istream<_CharT, _Traits>& __is)
{
return __is.rdbuf();
}
}
namespace _STL {
template <class _CharT, class _InputIter = istreambuf_iterator<_CharT> >
class num_get: public locale::facet
{
friend class _Locale;
public:
typedef _CharT char_type;
typedef _InputIter iter_type;
explicit num_get(size_t __refs = 0): locale::facet(__refs) {}
_InputIter get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err, bool& __val) const {
return do_get(__in, __end, __str, __err, __val);
}
_InputIter get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err, long& __val) const {
return do_get(__in, __end, __str, __err, __val);
}
_InputIter get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err, unsigned short& __val) const {
return do_get(__in, __end, __str, __err, __val);
}
_InputIter get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err, unsigned int& __val) const {
return do_get(__in, __end, __str, __err, __val);
}
_InputIter get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err, unsigned long& __val) const {
return do_get(__in, __end, __str, __err, __val);
}
_InputIter get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err, long long& __val) const {
return do_get(__in, __end, __str, __err, __val);
}
_InputIter get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err, unsigned long long& __val) const {
return do_get(__in, __end, __str, __err, __val);
}
_InputIter get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err, float& __val) const {
return do_get(__in, __end, __str, __err, __val);
}
_InputIter get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err, double& __val) const {
return do_get(__in, __end, __str, __err, __val);
}
_InputIter get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err, long double& __val) const {
return do_get(__in, __end, __str, __err, __val);
}
_InputIter get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err, void*& __val) const {
return do_get(__in, __end, __str, __err, __val);
}
static locale::id id;
protected:
~num_get() {}
typedef string string_type;
typedef ctype<_CharT> _Ctype;
typedef numpunct<_CharT> _Numpunct;
virtual _InputIter do_get(_InputIter __in, _InputIter __end,
ios_base& __str, ios_base::iostate& __err, bool& __val) const;
virtual _InputIter do_get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err, long& __val) const;
virtual _InputIter do_get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err, unsigned short& __val) const;
virtual _InputIter do_get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err, unsigned int& __val) const;
virtual _InputIter do_get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err, unsigned long& __val) const;
virtual _InputIter do_get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err, float& __val) const;
virtual _InputIter do_get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err, double& __val) const;
virtual _InputIter do_get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err,
void*& __p) const;
virtual _InputIter do_get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err, long double& __val) const;
virtual _InputIter do_get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err, long long& __val) const;
virtual _InputIter do_get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err, unsigned long long& __val) const;
};
extern bool __valid_grouping(const char*, const char*, const char*, const char*);
template <class _InputIter, class _Integer>
bool
__get_decimal_integer(_InputIter& __first, _InputIter& __last, _Integer& __val);
inline bool __get_fdigit(char& __c, const char*);
inline bool __get_fdigit_or_sep(char& __c, char __sep, const char *);
bool __get_fdigit(wchar_t&, const wchar_t*);
bool __get_fdigit_or_sep(wchar_t&, wchar_t, const wchar_t*);
inline void
_Initialize_get_float(const ctype<char>&,
char& Plus, char& Minus,
char& pow_e, char& pow_E,
char*)
{
Plus = '+';
Minus = '-';
pow_e = 'e';
pow_E = 'E';
}
void _Initialize_get_float(const ctype<wchar_t>&,
wchar_t&, wchar_t&, wchar_t&, wchar_t&, wchar_t*);
void __string_to_float(const string&, float&);
void __string_to_float(const string&, double&);
void __string_to_float(const string&, long double&);
}
namespace _STL {
extern const unsigned char __digit_val_table[];
template < class _InputIter, class _Integer, class _CharT>
_InputIter
_M_do_get_integer(_InputIter&, _InputIter&, ios_base&, ios_base::iostate&, _Integer&, _CharT*);
inline bool __get_fdigit(char& __c, const char*)
{ return __c >= '0' && __c <= '9'; }
inline bool __get_fdigit_or_sep(char& __c, char __sep, const char *)
{
if (__c == __sep) {
__c = ',' ;
return true ;
} else
return ( __c >= '0' && __c <= '9');
}
inline int
__get_digit_from_table(unsigned __index)
{
return (__index > 127 ? 0xFF : __digit_val_table[__index]);
}
extern const char __narrow_atoms[];
template <class _InputIter, class _CharT>
int
_M_get_base_or_zero(_InputIter& __in, _InputIter& __end, ios_base& __str, _CharT*)
{
_CharT __atoms[5];
const ctype<_CharT>& __c_type = *(const ctype<_CharT>*)__str._M_ctype_facet();
__c_type.widen(__narrow_atoms, __narrow_atoms + 5, __atoms);
bool __negative = false;
_CharT __c = *__in;
if (__c == __atoms[1] ) {
__negative = true;
++__in;
}
else if (__c == __atoms[0] )
++__in;
int __base;
int __valid_zero = 0;
ios_base::fmtflags __basefield = __str.flags() & ios_base::basefield;
switch (__basefield) {
case ios_base::oct:
__base = 8;
break;
case ios_base::dec:
__base = 10;
break;
case ios_base::hex:
__base = 16;
if (__in != __end && *__in == __atoms[2] ) {
++__in;
if (__in != __end &&
(*__in == __atoms[3] || *__in == __atoms[4] ))
++__in;
else
__valid_zero = 1;
}
break;
default:
if (__in != __end && *__in == __atoms[2] ) {
++__in;
if (__in != __end &&
(*__in == __atoms[3] || *__in == __atoms[4] )) {
++__in;
__base = 16;
}
else
{
__base = 8;
__valid_zero = 1;
}
}
else
__base = 10;
break;
}
return (__base << 2) | ((int)__negative << 1) | __valid_zero;
}
template <class _InputIter, class _Integer>
bool
__get_integer(_InputIter& __first, _InputIter& __last,
int __base, _Integer& __val,
int __got, bool __is_negative, char __separator, const string& __grouping, const __true_type&)
{
bool __ovflow = false;
_Integer __result = 0;
bool __is_group = !__grouping.empty();
char __group_sizes[64];
int __current_group_size = 0;
char* __group_sizes_end = __group_sizes;
_Integer __over_base = (numeric_limits<_Integer>::min)() / static_cast<_Integer>(__base);
for ( ; __first != __last ; ++__first) {
const char __c = *__first;
if (__is_group && __c == __separator) {
*__group_sizes_end++ = __current_group_size;
__current_group_size = 0;
continue;
}
int __n = __get_digit_from_table(__c);
if (__n >= __base)
break;
++__got;
++__current_group_size;
if (__result < __over_base)
__ovflow = true;
else {
_Integer __next = static_cast<_Integer>(__base * __result - __n);
if (__result != 0)
__ovflow = __ovflow || __next >= __result;
__result = __next;
}
}
if (__is_group && __group_sizes_end != __group_sizes) {
*__group_sizes_end++ = __current_group_size;
}
if (__got > 0) {
__val = __ovflow
? __is_negative ? (numeric_limits<_Integer>::min)()
: (numeric_limits<_Integer>::max)()
: (__is_negative ? __result : static_cast<_Integer>(-__result));
}
return ((__got > 0) && !__ovflow) && (__is_group == 0 || __valid_grouping(__group_sizes, __group_sizes_end,
__grouping.data(), __grouping.data()+ __grouping.size())) ;
}
template <class _InputIter, class _Integer>
bool
__get_integer(_InputIter& __first, _InputIter& __last,
int __base, _Integer& __val,
int __got, bool __is_negative, char __separator, const string& __grouping, const __false_type&)
{
bool __ovflow = false;
_Integer __result = 0;
bool __is_group = !__grouping.empty();
char __group_sizes[64];
int __current_group_size = 0;
char* __group_sizes_end = __group_sizes;
_Integer __over_base = (numeric_limits<_Integer>::max)() / static_cast<_Integer>(__base);
for ( ; __first != __last ; ++__first) {
const char __c = *__first;
if (__is_group && __c == __separator) {
*__group_sizes_end++ = __current_group_size;
__current_group_size = 0;
continue;
}
int __n = __get_digit_from_table(__c);
if (__n >= __base)
break;
++__got;
++__current_group_size;
if (__result > __over_base)
__ovflow = true;
else {
_Integer __next = static_cast<_Integer>(__base * __result + __n);
if (__result != 0)
__ovflow = __ovflow || __next <= __result;
__result = __next;
}
}
if (__is_group && __group_sizes_end != __group_sizes) {
*__group_sizes_end++ = __current_group_size;
}
if (__got > 0) {
__val = __ovflow
? (numeric_limits<_Integer>::max)()
: (__is_negative ? static_cast<_Integer>(-__result) : __result);
}
return ((__got > 0) && !__ovflow) &&
(__is_group == 0 || __valid_grouping(__group_sizes, __group_sizes_end,
__grouping.data(), __grouping.data()+ __grouping.size())) ;
}
template <class _InputIter, class _Integer>
bool
__get_decimal_integer(_InputIter& __first, _InputIter& __last, _Integer& __val)
{
string __grp;
return __get_integer(__first, __last, 10, __val, 0, false, ' ', __grp, __false_type());
}
template <class _InputIter, class _Integer, class _CharT>
_InputIter
_M_do_get_integer(_InputIter& __in, _InputIter& __end, ios_base& __str,
ios_base::iostate& __err, _Integer& __val, _CharT* __pc)
{
typedef typename __bool2type<numeric_limits<_Integer>::is_signed>::_Ret _IsSigned;
const numpunct<_CharT>& __numpunct = *(const numpunct<_CharT>*)__str._M_numpunct_facet();
const string& __grouping = __str._M_grouping();
const int __base_or_zero = _M_get_base_or_zero(__in, __end, __str, __pc);
int __got = __base_or_zero & 1;
bool __result;
if (__in == __end) {
if (__got > 0) {
__val = 0;
__result = true;
}
else
__result = false;
} else {
const bool __negative = __base_or_zero & 2;
const int __base = __base_or_zero >> 2;
__result = __get_integer(__in, __end, __base, __val, __got, __negative, __numpunct.thousands_sep(), __grouping, _IsSigned());
}
__err = static_cast<ios_base::iostate>(__result ? ios_base::goodbit : ios_base::failbit);
if (__in == __end)
__err |= ios_base::eofbit;
return __in;
}
template <class _InputIter, class _CharT>
_InputIter
__copy_sign(_InputIter __first, _InputIter __last, string& __v,
_CharT __xplus, _CharT __xminus) {
if (__first != __last) {
_CharT __c = *__first;
if (__c == __xplus)
++__first;
else if (__c == __xminus) {
__v.push_back('-');
++__first;
}
}
return __first;
}
template <class _InputIter, class _CharT>
bool
__copy_digits(_InputIter& __first, _InputIter& __last,
string& __v, const _CharT* __digits)
{
bool __ok = false;
for ( ; __first != __last; ++__first) {
_CharT __c = *__first;
if (__get_fdigit(__c, __digits)) {
__v.push_back((char)__c);
__ok = true;
}
else
break;
}
return __ok;
}
template <class _InputIter, class _CharT>
bool
__copy_grouped_digits(_InputIter& __first, _InputIter& __last,
string& __v, const _CharT * __digits,
_CharT __sep, const string& __grouping,
bool& __grouping_ok)
{
bool __ok = false;
char __group_sizes[64];
char*__group_sizes_end = __group_sizes;
char __current_group_size = 0;
for ( ; __first != __last; ++__first) {
_CharT __c = *__first;
bool __tmp = __get_fdigit_or_sep(__c, __sep, __digits);
if (__tmp) {
if (__c == ',') {
*__group_sizes_end++ = __current_group_size;
__current_group_size = 0;
}
else {
__ok = true;
__v.push_back((char)__c);
++__current_group_size;
}
}
else
break;
}
if (__group_sizes_end != __group_sizes)
*__group_sizes_end++ = __current_group_size;
__grouping_ok = __valid_grouping(__group_sizes, __group_sizes_end, __grouping.data(), __grouping.data() + __grouping.size());
return __ok;
}
template <class _InputIter, class _CharT>
bool
_M_read_float(string& __buf, _InputIter& __in, _InputIter& __end, ios_base& __s, _CharT*)
{
bool __digits_before_dot ;
bool __digits_after_dot = false;
bool __ok;
bool __grouping_ok = true;
const ctype<_CharT>& __ct = *(const ctype<_CharT>*)__s._M_ctype_facet();
const numpunct<_CharT>& __numpunct = *(const numpunct<_CharT>*)__s._M_numpunct_facet();
const string& __grouping = __s._M_grouping();
_CharT __dot = __numpunct.decimal_point();
_CharT __sep = __numpunct.thousands_sep();
_CharT __digits[10];
_CharT __xplus;
_CharT __xminus;
_CharT __pow_e;
_CharT __pow_E;
_Initialize_get_float(__ct, __xplus, __xminus, __pow_e, __pow_E, __digits);
__in = __copy_sign(__in, __end, __buf, __xplus, __xminus);
if (__grouping.size() != 0)
__digits_before_dot = __copy_grouped_digits(__in, __end, __buf, __digits,
__sep, __grouping, __grouping_ok);
else
__digits_before_dot = __copy_digits(__in, __end, __buf, __digits);
if (__in != __end && *__in == __dot) {
__buf.push_back('.');
++__in;
__digits_after_dot = __copy_digits(__in, __end, __buf, __digits);
}
__ok = __digits_before_dot || __digits_after_dot;
if (__ok && __in != __end && (*__in == __pow_e || *__in == __pow_E)) {
__buf.push_back('e');
++__in;
__in = __copy_sign(__in, __end, __buf, __xplus, __xminus);
__ok = __copy_digits(__in, __end, __buf, __digits);
}
return __ok;
}
template <class _CharT, class _InputIterator>
locale::id num_get<_CharT, _InputIterator>::id;
template <class _CharT, class _InputIter>
_InputIter
num_get<_CharT, _InputIter>::do_get(_InputIter __in, _InputIter __end,
ios_base& __s,
ios_base::iostate& __err, bool& __x) const
{
if (__s.flags() & ios_base::boolalpha) {
locale __loc = __s.getloc();
const _Numpunct& __np = *(const _Numpunct*)__s._M_numpunct_facet();
const basic_string<_CharT> __truename = __np.truename();
const basic_string<_CharT> __falsename = __np.falsename();
bool __true_ok = true;
bool __false_ok = true;
size_t __n = 0;
for ( ; __in != __end; ++__in) {
_CharT __c = *__in;
__true_ok = __true_ok && (__c == __truename[__n]);
__false_ok = __false_ok && (__c == __falsename[__n]);
++__n;
if ((!__true_ok && !__false_ok) ||
(__true_ok && __n >= __truename.size()) ||
(__false_ok && __n >= __falsename.size())) {
++__in;
break;
}
}
if (__true_ok && __n < __truename.size()) __true_ok = false;
if (__false_ok && __n < __falsename.size()) __false_ok = false;
if (__true_ok || __false_ok) {
__err = ios_base::goodbit;
__x = __true_ok;
}
else
__err = ios_base::failbit;
if (__in == __end)
__err |= ios_base::eofbit;
return __in;
}
else {
long __lx;
_InputIter __tmp = this->do_get(__in, __end, __s, __err, __lx);
if (!(__err & ios_base::failbit)) {
if (__lx == 0)
__x = false;
else if (__lx == 1)
__x = true;
else
__err |= ios_base::failbit;
}
return __tmp;
}
}
template <class _CharT, class _InputIter>
_InputIter
num_get<_CharT, _InputIter>::do_get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err, long& __val) const {
return _M_do_get_integer(__in, __end, __str, __err, __val, (_CharT*)0 );
}
template <class _CharT, class _InputIter>
_InputIter
num_get<_CharT, _InputIter>::do_get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err,
unsigned short& __val) const {
return _M_do_get_integer(__in, __end, __str, __err, __val, (_CharT*)0 );
}
template <class _CharT, class _InputIter>
_InputIter
num_get<_CharT, _InputIter>::do_get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err,
unsigned int& __val) const {
return _M_do_get_integer(__in, __end, __str, __err, __val, (_CharT*)0 );
}
template <class _CharT, class _InputIter>
_InputIter
num_get<_CharT, _InputIter>::do_get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err,
unsigned long& __val) const {
return _M_do_get_integer(__in, __end, __str, __err, __val, (_CharT*)0 );
}
template <class _CharT, class _InputIter>
_InputIter
num_get<_CharT, _InputIter>::do_get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err,
float& __val) const {
string __buf ;
bool __ok = _M_read_float(__buf, __in, __end, __str, (_CharT*)0 );
__string_to_float(__buf, __val);
__err = static_cast<ios_base::iostate>(__ok ? ios_base::goodbit : ios_base::failbit);
if (__in == __end)
__err |= ios_base::eofbit;
return __in;
}
template <class _CharT, class _InputIter>
_InputIter
num_get<_CharT, _InputIter>::do_get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err,
double& __val) const {
string __buf ;
bool __ok = _M_read_float(__buf, __in, __end, __str, (_CharT*)0 );
__string_to_float(__buf, __val);
__err = static_cast<ios_base::iostate>(__ok ? ios_base::goodbit : ios_base::failbit);
if (__in == __end)
__err |= ios_base::eofbit;
return __in;
}
template <class _CharT, class _InputIter>
_InputIter
num_get<_CharT, _InputIter>::do_get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err,
long double& __val) const {
string __buf ;
bool __ok = _M_read_float(__buf, __in, __end, __str, (_CharT*)0 );
__string_to_float(__buf, __val);
__err = static_cast<ios_base::iostate>(__ok ? ios_base::goodbit : ios_base::failbit);
if (__in == __end)
__err |= ios_base::eofbit;
return __in;
}
template <class _CharT, class _InputIter>
_InputIter
num_get<_CharT, _InputIter>::do_get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err,
void*& __p) const {
unsigned long long __val;
iter_type __tmp = _M_do_get_integer(__in, __end, __str, __err, __val, (_CharT*)0 );
if (!(__err & ios_base::failbit))
__p = reinterpret_cast<void*>(__val);
return __tmp;
}
template <class _CharT, class _InputIter>
_InputIter
num_get<_CharT, _InputIter>::do_get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err,
long long& __val) const {
return _M_do_get_integer(__in, __end, __str, __err, __val, (_CharT*)0 );
}
template <class _CharT, class _InputIter>
_InputIter
num_get<_CharT, _InputIter>::do_get(_InputIter __in, _InputIter __end, ios_base& __str,
ios_base::iostate& __err,
unsigned long long& __val) const {
return _M_do_get_integer(__in, __end, __str, __err, __val, (_CharT*)0 );
}
}
namespace _STL {
template <class _Traits>
struct _Is_not_wspace {
typedef typename _Traits::char_type argument_type;
typedef bool result_type;
const ctype<argument_type>* _M_ctype;
_Is_not_wspace(const ctype<argument_type>* __c_type) : _M_ctype(__c_type) {}
bool operator()(argument_type __c) const
{ return !_M_ctype->is(ctype_base::space, __c); }
};
template <class _Traits>
struct _Is_wspace_null {
typedef typename _Traits::char_type argument_type;
typedef bool result_type;
const ctype<argument_type>* _M_ctype;
_Is_wspace_null(const ctype<argument_type>* __c_type) : _M_ctype(__c_type) {}
bool operator()(argument_type __c) const {
return _Traits::eq(__c, argument_type()) ||
_M_ctype->is(ctype_base::space, __c);
}
};
template <class _Traits>
struct _Scan_for_wspace {
typedef typename _Traits::char_type char_type;
typedef char_type* first_argument_type;
typedef char_type* second_argument_type;
typedef char_type* result_type;
const ctype<char_type>* _M_ctype;
_Scan_for_wspace(const ctype<char_type>* __ctype) : _M_ctype(__ctype) {}
const char_type*
operator()(const char_type* __first, const char_type* __last) const {
return _M_ctype->scan_is(ctype_base::space, __first, __last);
}
};
template <class _Traits>
struct _Scan_wspace_null {
typedef typename _Traits::char_type char_type;
typedef char_type* first_argument_type;
typedef char_type* second_argument_type;
typedef char_type* result_type;
const ctype<char_type>* _M_ctype;
_Scan_wspace_null(const ctype<char_type>* __c_type) : _M_ctype(__c_type) {}
const char_type*
operator()(const char_type* __first, const char_type* __last) const {
__last = find_if(__first, __last,
_Eq_char_bound<_Traits>(char_type()));
return _M_ctype->scan_is(ctype_base::space, __first, __last);
}
};
template <class _Traits>
struct _Scan_for_not_wspace {
typedef typename _Traits::char_type char_type;
typedef char_type* first_argument_type;
typedef char_type* second_argument_type;
typedef char_type* result_type;
const ctype<char_type>* _M_ctype;
_Scan_for_not_wspace(const ctype<char_type>* __c_type) : _M_ctype(__c_type) {}
const char_type*
operator()(const char_type* __first, const char_type* __last) const {
return _M_ctype->scan_not(ctype_base::space, __first, __last);
}
};
template <class _Traits>
struct _Scan_for_char_val
{
typedef typename _Traits::char_type char_type;
typedef char_type* first_argument_type;
typedef char_type* second_argument_type;
typedef char_type* result_type;
char_type _M_val;
_Scan_for_char_val(char_type __val) : _M_val(__val) {}
const char_type*
operator()(const char_type* __first, const char_type* __last) const {
return find_if(__first, __last, _Eq_char_bound<_Traits>(_M_val));
}
};
template <class _Traits>
struct _Scan_for_int_val
{
typedef typename _Traits::char_type char_type;
typedef typename _Traits::int_type int_type;
typedef char_type* first_argument_type;
typedef char_type* second_argument_type;
typedef char_type* result_type;
int_type _M_val;
_Scan_for_int_val(int_type __val) : _M_val(__val) {}
const char_type*
operator()(const char_type* __first, const char_type* __last) const {
return find_if(__first, __last,
_Eq_int_bound<_Traits>(_M_val));
}
};
template <class _CharT, class _Traits>
bool
__pushback(basic_streambuf<_CharT, _Traits>* __buf, _CharT __c)
{
bool ret;
try {
const typename _Traits::int_type __eof = _Traits::eof();
ret = !_Traits::eq_int_type(__buf->sputbackc(__c), __eof);
}
catch(...) {
ret = false;
}
return ret;
}
template <class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
ws(basic_istream<_CharT, _Traits>& __is)
{
typedef typename basic_istream<_CharT, _Traits>::sentry _Sentry;
_Sentry __sentry(__is, _No_Skip_WS());
if (__sentry)
__is._M_skip_whitespace(false);
return __is;
}
template <class _CharT, class _Traits>
bool
_M_init_skip(basic_istream<_CharT, _Traits>& __is) {
if (__is.good()) {
if (__is.tie())
__is.tie()->flush();
__is._M_skip_whitespace(true);
}
if (!__is.good()) {
__is.setstate(ios_base::failbit);
return false;
} else
return true;
}
template <class _CharT, class _Traits>
bool
_M_init_noskip(basic_istream<_CharT, _Traits>& __is){
if (__is.good()) {
if (__is.tie())
__is.tie()->flush();
if (!__is.rdbuf())
__is.setstate(ios_base::badbit);
}
else
__is.setstate(ios_base::failbit);
return __is.good();
}
template <class _CharT, class _Traits, class _Number>
ios_base::iostate
_M_get_num(basic_istream<_CharT, _Traits>& __that, _Number& __val)
{
typedef typename basic_istream<_CharT, _Traits>::sentry _Sentry;
ios_base::iostate __err = 0;
_Sentry __sentry( __that );
if (__sentry) {
typedef num_get<_CharT, istreambuf_iterator<_CharT, _Traits> > _Num_get;
try {
((const _Num_get&)use_facet<_Num_get>(__that.getloc())).get(istreambuf_iterator<_CharT, _Traits>(__that.rdbuf()),
0, __that, __err, __val);
}
catch(...) {
__that._M_handle_exception(ios_base::badbit);
}
if (__err) __that.setstate(__err);
}
return __err;
}
template <class _CharT, class _Traits>
typename basic_istream<_CharT, _Traits>::int_type
basic_istream<_CharT, _Traits>::peek()
{
typename _Traits::int_type __tmp = _Traits::eof();
this->_M_gcount = 0;
sentry __sentry(*this, _No_Skip_WS());
if (__sentry) {
try {
__tmp = this->rdbuf()->sgetc();
}
catch(...) {
this->_M_handle_exception(ios_base::badbit);
}
if (this->_S_eof(__tmp))
this->setstate(ios_base::eofbit);
}
return __tmp;
}
template <class _CharT, class _Traits>
typename basic_istream<_CharT, _Traits>::int_type
basic_istream<_CharT, _Traits>::get()
{
typename _Traits::int_type __tmp = _Traits::eof();
sentry __sentry(*this, _No_Skip_WS());
this->_M_gcount = 0;
if (__sentry) {
try {
__tmp = this->rdbuf()->sbumpc();
}
catch(...) {
this->_M_handle_exception(ios_base::badbit);
}
if (!this->_S_eof(__tmp))
this->_M_gcount = 1;
}
if (_M_gcount == 0)
this->setstate(ios_base::eofbit | ios_base::failbit);
return __tmp;
}
template <class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::get(_CharT& __c)
{
sentry __sentry(*this, _No_Skip_WS());
this->_M_gcount = 0;
if (__sentry) {
typename _Traits::int_type __tmp = _Traits::eof();
try {
__tmp = this->rdbuf()->sbumpc();
}
catch(...) {
this->_M_handle_exception(ios_base::badbit);
}
if (!this->_S_eof(__tmp)) {
this->_M_gcount = 1;
__c = _Traits::to_char_type(__tmp);
}
}
if (this->_M_gcount == 0)
this->setstate(ios_base::eofbit | ios_base::failbit);
return *this;
}
template <class _CharT, class _Traits>
basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore()
{
sentry __sentry(*this, _No_Skip_WS());
this->_M_gcount = 0;
if (__sentry) {
int_type __c;
try {
__c = this->rdbuf()->sbumpc();
}
catch(...) {
this->_M_handle_exception(ios_base::badbit);
return *this;
}
if (!this->_S_eof(__c))
this->_M_gcount = 1;
else
this->setstate(ios_base::eofbit);
}
return *this;
}
template <class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::putback(_CharT __c) {
this->_M_gcount = 0;
sentry __sentry(*this, _No_Skip_WS());
if (__sentry) {
typename _Traits::int_type __tmp = _Traits::eof();
basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf();
if (__buf) {
try {
__tmp = __buf->sputbackc(__c);
}
catch(...) {
this->_M_handle_exception(ios_base::badbit);
}
}
if (this->_S_eof(__tmp))
this->setstate(ios_base::badbit);
}
else
this->setstate(ios_base::failbit);
return *this;
}
template <class _CharT, class _Traits>
basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::unget() {
this->_M_gcount = 0;
sentry __sentry(*this, _No_Skip_WS());
if (__sentry) {
basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf();
if (__buf) {
try {
_CharT __tmp;
__tmp = __buf->sungetc();
if (this->_S_eof(__tmp))
this->setstate(ios_base::badbit);
}
catch(...) {
this->_M_handle_exception(ios_base::badbit);
}
} else
this->setstate(ios_base::badbit);
}
else
this->setstate(ios_base::failbit);
return *this;
}
template <class _CharT, class _Traits>
int basic_istream<_CharT, _Traits>::sync() {
sentry __sentry(*this, _No_Skip_WS());
basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf();
if (__buf) {
if (__buf->pubsync() == -1) {
this->setstate(ios_base::badbit);
return -1;
}
else
return 0;
}
else
return -1;
}
template <class _CharT, class _Traits>
typename basic_istream<_CharT, _Traits>::pos_type
basic_istream<_CharT, _Traits>::tellg() {
basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf();
return (__buf && !this->fail()) ? __buf->pubseekoff(0, ios_base::cur, ios_base::in)
: pos_type(-1);
}
template <class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::seekg(pos_type __pos) {
sentry __sentry(*this, _No_Skip_WS());
basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf();
if (!this->fail() && __buf)
__buf->pubseekpos(__pos, ios_base::in);
return *this;
}
template <class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir)
{
sentry __sentry(*this, _No_Skip_WS());
basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf();
if (!this->fail() && __buf)
__buf->pubseekoff(__off, __dir, ios_base::in);
return *this;
}
template <class _CharT, class _Traits>
void basic_istream<_CharT, _Traits>::_M_formatted_get(_CharT& __c)
{
sentry __sentry(*this);
if (__sentry) {
typename _Traits::int_type __tmp = _Traits::eof();
try {
__tmp = this->rdbuf()->sbumpc();
}
catch(...) {
this->_M_handle_exception(ios_base::badbit);
return;
}
if (!this->_S_eof(__tmp))
__c = _Traits::to_char_type(__tmp);
else
this->setstate(ios_base::eofbit | ios_base::failbit);
}
}
template < class _CharT, class _Traits, class _Is_Delim>
streamsize
_M_read_unbuffered(basic_istream<_CharT, _Traits>* __that, basic_streambuf<_CharT, _Traits>* __buf,
streamsize _Num, _CharT* __s,
_Is_Delim __is_delim,
bool __extract_delim, bool __append_null,
bool __is_getline)
{
streamsize __n = 0;
ios_base::iostate __status = 0;
typedef typename basic_istream<_CharT, _Traits>::int_type int_type;
try {
while (true) {
int_type __c = __buf->sbumpc();
if (__that->_S_eof(__c)) {
if (__n < _Num || __is_getline)
__status |= ios_base::eofbit;
break;
}
else if (__is_delim(__c)) {
if (__extract_delim) {
++__n;
}
break;
}
else {
*__s++ = _Traits::to_char_type(__c);
++__n;
}
if (__n == _Num) {
if (__is_getline)
__status |= ios_base::failbit;
break;
}
}
}
catch(...) {
__that->_M_handle_exception(ios_base::badbit);
*__s = _CharT();
return __n;
}
if (__append_null)
*__s = _CharT();
if (__status)
__that->setstate(__status);
return __n;
}
template < class _CharT, class _Traits, class _Is_Delim, class _Scan_Delim>
streamsize
_M_read_buffered(basic_istream<_CharT, _Traits>* __that, basic_streambuf<_CharT, _Traits>* __buf,
streamsize _Num, _CharT* __s,
_Is_Delim __is_delim, _Scan_Delim __scan_delim,
bool __extract_delim, bool __append_null,
bool __is_getline)
{
streamsize __n = 0;
ios_base::iostate __status = 0;
bool __done = false;
try {
while (__buf->_M_egptr() != __buf->_M_gptr() && !__done) {
const _CharT* __first = __buf->_M_gptr();
const _CharT* __last = __buf->_M_egptr();
ptrdiff_t __request = _Num - __n;
const _CharT* __p = __scan_delim(__first, __last);
ptrdiff_t __chunk = (min) (ptrdiff_t(__p - __first), __request);
_Traits::copy(__s, __first, __chunk);
__s += __chunk;
__n += __chunk;
__buf->_M_gbump((int)__chunk);
if (__p != __last && __p - __first <= __request) {
if (__extract_delim) {
__n += 1;
__buf->_M_gbump(1);
}
__done = true;
}
else if(__n == _Num) {
if (__is_getline) {
if (__chunk == __last - __first) {
if (__that->_S_eof(__buf->sgetc()))
__status |= ios_base::eofbit;
}
else
__status |= ios_base::failbit;
}
__done = true;
}
else {
if (__that->_S_eof(__buf->sgetc())) {
__status |= ios_base::eofbit;
__done = true;
}
}
}
}
catch(...) {
__that->_M_handle_exception(ios_base::badbit);
__done = true;
}
if (__done) {
if (__append_null)
*__s = _CharT();
if (__status != 0)
__that->setstate(__status);
return __n;
}
return __n + _M_read_unbuffered(__that, __buf, _Num - __n, __s, __is_delim,
__extract_delim,__append_null,__is_getline);
}
template <class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::get(_CharT* __s, streamsize __n,
_CharT __delim) {
sentry __sentry(*this, _No_Skip_WS());
this->_M_gcount = 0;
if (__sentry) {
if (__n > 0) {
basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf();
if (__buf->egptr() != __buf->gptr())
this->_M_gcount =
_M_read_buffered(this, __buf, __n - 1, __s,
_Eq_char_bound<_Traits>(__delim),
_Scan_for_char_val<_Traits>(__delim),
false, true, false);
else
this->_M_gcount =
_M_read_unbuffered(this, __buf, __n - 1, __s,
_Eq_char_bound<_Traits>(__delim),
false, true, false);
}
}
if (this->_M_gcount == 0)
this->setstate(ios_base::failbit);
return *this;
}
template <class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::getline(_CharT* __s, streamsize __n,
_CharT __delim) {
sentry __sentry(*this, _No_Skip_WS());
this->_M_gcount = 0;
if (__sentry) {
if (__n > 0) {
basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf();
this->_M_gcount = __buf->egptr() != __buf->gptr()
? _M_read_buffered(this, __buf, __n - 1, __s,
_Eq_char_bound<_Traits>(__delim),
_Scan_for_char_val<_Traits>(__delim),
true, true, true)
: _M_read_unbuffered(this, __buf, __n - 1, __s,
_Eq_char_bound<_Traits>(__delim),
true, true, true);
}
}
if (this->_M_gcount == 0)
this->setstate(ios_base::failbit);
return *this;
}
template <class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::read(char_type* __s, streamsize __n)
{
sentry __sentry(*this, _No_Skip_WS());
this->_M_gcount = 0;
if (__sentry && !this->eof()) {
basic_streambuf<_CharT, _Traits>*__buf = this->rdbuf();
if (__buf->gptr() != __buf->egptr())
_M_gcount
= _M_read_buffered(this, __buf, __n, __s,
_Constant_unary_fun<bool, int_type>(false),
_Project2nd<const _CharT*, const _CharT*>(),
false, false, false);
else
_M_gcount
= _M_read_unbuffered(this, __buf, __n, __s,
_Constant_unary_fun<bool, int_type>(false),
false, false, false);
}
else
this->setstate(ios_base::failbit);
if (this->eof())
this->setstate(ios_base::eofbit | ios_base::failbit);
return *this;
}
template <class _CharT, class _Traits>
streamsize
basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize __nmax)
{
sentry __sentry(*this, _No_Skip_WS());
this->_M_gcount = 0;
if (__sentry && !this->eof() && __nmax >= 0) {
basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf();
streamsize __avail = __buf->in_avail();
if (__avail == -1)
this->_M_setstate_nothrow(ios_base::eofbit);
else if (__avail != 0) {
if (__buf->gptr() != __buf->egptr())
_M_gcount
= _M_read_buffered(this, __buf, (min) (__avail, __nmax), __s,
_Constant_unary_fun<bool, int_type>(false),
_Project2nd<const _CharT*, const _CharT*>(),
false, false, false);
else
_M_gcount
= _M_read_unbuffered(this, __buf, (min) (__avail, __nmax), __s,
_Constant_unary_fun<bool, int_type>(false),
false, false, false);
}
}
else {
if (this->eof())
this->setstate(ios_base::eofbit | ios_base::failbit);
else
this->setstate(ios_base::failbit);
}
return _M_gcount;
}
template <class _CharT, class _Traits>
void basic_istream<_CharT, _Traits>::_M_formatted_get(_CharT* __s)
{
sentry __sentry(*this);
if (__sentry) {
basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf();
streamsize __nmax = this->width() > 0
? this->width() - 1
: (numeric_limits<streamsize>::max)() / sizeof(_CharT) - 1;
streamsize __n = __buf->gptr() != __buf->egptr()
? _M_read_buffered(this, __buf, __nmax, __s,
_Is_wspace_null<_Traits>((const ctype<_CharT>*)this->_M_ctype_facet()),
_Scan_wspace_null<_Traits>((const ctype<_CharT>*)this->_M_ctype_facet()),
false, true, false)
: _M_read_unbuffered(this, __buf, __nmax, __s,
_Is_wspace_null<_Traits>((const ctype<_CharT>*)this->_M_ctype_facet()),
false, true, false);
if (__n == 0)
this->setstate(ios_base::failbit);
}
this->width(0);
}
template < class _CharT, class _Traits, class _Is_Delim>
void
_M_ignore_unbuffered(basic_istream<_CharT, _Traits>* __that,
basic_streambuf<_CharT, _Traits>* __buf,
_Is_Delim __is_delim,
bool __extract_delim, bool __set_failbit)
{
bool __done = false;
ios_base::iostate __status = 0;
typedef typename basic_istream<_CharT, _Traits>::int_type int_type;
try {
while (!__done) {
int_type __c = __buf->sbumpc();
if (__that->_S_eof(__c)) {
__done = true;
__status |= __set_failbit ? ios_base::eofbit | ios_base::failbit
: ios_base::eofbit;
}
else if (__is_delim(__c)) {
__done = true;
if (!__extract_delim)
if (__that->_S_eof(__buf->sputbackc(_Traits::to_char_type(__c))))
__status |= ios_base::failbit;
}
}
}
catch(...) {
__that->_M_handle_exception(ios_base::badbit);
}
__that->setstate(__status);
}
template < class _CharT, class _Traits, class _Is_Delim, class _Scan_Delim>
void
_M_ignore_buffered(basic_istream<_CharT, _Traits>* __that,
basic_streambuf<_CharT, _Traits>* __buf,
_Is_Delim __is_delim, _Scan_Delim __scan_delim,
bool __extract_delim, bool __set_failbit)
{
bool __at_eof = false;
bool __found_delim = false;
try {
while (__buf->_M_egptr() != __buf->_M_gptr() && !__at_eof && !__found_delim) {
const _CharT* __p = __scan_delim(__buf->_M_gptr(), __buf->_M_egptr());
__buf->_M_gbump((int)(__p - __buf->_M_gptr()));
if (__p != __buf->_M_egptr()) {
if (__extract_delim)
__buf->_M_gbump(1);
__found_delim = true;
}
else
__at_eof = __that->_S_eof(__buf->sgetc());
}
}
catch(...) {
__that->_M_handle_exception(ios_base::badbit);
return;
}
if (__at_eof) {
__that->setstate(__set_failbit ? ios_base::eofbit | ios_base::failbit
: ios_base::eofbit);
return;
}
if (__found_delim)
return;
_M_ignore_unbuffered(__that, __buf, __is_delim, __extract_delim, __set_failbit);
}
template < class _CharT, class _Traits, class _Max_Chars, class _Is_Delim>
streamsize
_M_ignore_unbuffered(basic_istream<_CharT, _Traits>* __that,
basic_streambuf<_CharT, _Traits>* __buf,
streamsize _Num, _Max_Chars __max_chars,
_Is_Delim __is_delim,
bool __extract_delim, bool __set_failbit)
{
streamsize __n = 0;
ios_base::iostate __status = 0;
typedef typename basic_istream<_CharT, _Traits>::int_type int_type;
try {
while (__max_chars(_Num, __n) > 0) {
int_type __c = __buf->sbumpc();
if (__that->_S_eof(__c)) {
__status |= __set_failbit ? ios_base::eofbit | ios_base::failbit
: ios_base::eofbit;
break;
}
else if (__is_delim(__c)) {
if (__extract_delim)
++__n;
else if (__that->_S_eof(__buf->sputbackc(_Traits::to_char_type(__c))))
__status |= ios_base::failbit;
break;
}
++__n;
}
}
catch(...) {
__that->_M_handle_exception(ios_base::badbit);
}
if (__status)
__that->setstate(__status);
return __n;
}
template < class _CharT, class _Traits, class _Max_Chars, class _Is_Delim, class _Scan_Delim>
streamsize
_M_ignore_buffered(basic_istream<_CharT, _Traits>* __that,
basic_streambuf<_CharT, _Traits>* __buf,
streamsize _Num,
_Max_Chars __max_chars,
_Is_Delim __is_delim, _Scan_Delim __scan_delim,
bool __extract_delim, bool __set_failbit)
{
streamsize __n = 0;
bool __at_eof = false;
bool __done = false;
try {
while (__buf->_M_egptr() != __buf->_M_gptr() && !__done) {
ptrdiff_t __avail = __buf->_M_egptr() - __buf->_M_gptr();
streamsize __m = __max_chars(_Num, __n);
if (__avail >= __m) {
const _CharT* __last = __buf->_M_gptr() + __m;
const _CharT* __p = __scan_delim(__buf->_M_gptr(), __last);
ptrdiff_t __chunk = __p - __buf->_M_gptr();
__n += __chunk;
__buf->_M_gbump((int)__chunk);
if (__extract_delim && __p != __last) {
__n += 1;
__buf->_M_gbump(1);
}
__done = true;
}
else {
const _CharT* __p = __scan_delim(__buf->_M_gptr(), __buf->_M_egptr());
ptrdiff_t __chunk = __p - __buf->_M_gptr();
__n += __chunk;
__buf->_M_gbump((int)__chunk);
if (__p != __buf->_M_egptr()) {
if (__extract_delim) {
__n += 1;
__buf->_M_gbump(1);
}
__done = true;
}
else if (__that->_S_eof(__buf->sgetc())) {
__done = true;
__at_eof = true;
}
}
}
}
catch(...) {
__that->_M_handle_exception(ios_base::badbit);
return __n;
}
if (__at_eof)
__that->setstate(__set_failbit ? ios_base::eofbit | ios_base::failbit
: ios_base::eofbit);
if (__done)
return __n;
return __n + _M_ignore_unbuffered( __that, __buf, _Num, __max_chars,
__is_delim, __extract_delim, __set_failbit);
}
template <class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::ignore(streamsize __n)
{
sentry __sentry(*this, _No_Skip_WS());
this->_M_gcount = 0;
if (__sentry) {
basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf();
typedef _Constant_unary_fun<bool, int_type> _Const_bool;
typedef _Constant_binary_fun<streamsize, streamsize, streamsize>
_Const_streamsize;
const streamsize __maxss = (numeric_limits<streamsize>::max)();
if (__n == (numeric_limits<int>::max)()) {
if (__buf->gptr() != __buf->egptr())
_M_gcount
= _M_ignore_buffered(this, __buf,
__maxss, _Const_streamsize(__maxss),
_Const_bool(false),
_Project2nd<const _CharT*, const _CharT*>(),
false, false);
else
_M_gcount = _M_ignore_unbuffered(this, __buf,
__maxss, _Const_streamsize(__maxss),
_Const_bool(false), false, false);
}
else {
if (__buf->gptr() != __buf->egptr())
_M_gcount
= _M_ignore_buffered(this, __buf,
__n, minus<streamsize>(),
_Const_bool(false),
_Project2nd<const _CharT*, const _CharT*>(),
false, false);
else
_M_gcount = _M_ignore_unbuffered(this, __buf, __n, minus<streamsize>(),
_Const_bool(false), false, false);
}
}
return *this;
}
template <class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __delim)
{
sentry __sentry(*this, _No_Skip_WS());
this->_M_gcount = 0;
if (__sentry) {
basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf();
typedef _Constant_unary_fun<bool, int_type> _Const_bool;
typedef _Constant_binary_fun<streamsize, streamsize, streamsize>
_Const_streamsize;
const streamsize __maxss = (numeric_limits<streamsize>::max)();
if (__n == (numeric_limits<int>::max)()) {
if (__buf->gptr() != __buf->egptr())
_M_gcount = _M_ignore_buffered(this, __buf,
__maxss, _Const_streamsize(__maxss),
_Eq_int_bound<_Traits>(__delim),
_Scan_for_int_val<_Traits>(__delim),
true, false);
else
_M_gcount = _M_ignore_unbuffered(this, __buf,
__maxss, _Const_streamsize(__maxss),
_Eq_int_bound<_Traits>(__delim),
true, false);
}
else {
if (__buf->gptr() != __buf->egptr())
_M_gcount = _M_ignore_buffered(this, __buf,
__n, minus<streamsize>(),
_Eq_int_bound<_Traits>(
__delim),
_Scan_for_int_val<_Traits>(__delim),
true, false);
else
_M_gcount = _M_ignore_unbuffered(this, __buf, __n, minus<streamsize>(),
_Eq_int_bound<_Traits>(__delim),
true, false);
}
}
return *this;
}
template <class _CharT, class _Traits>
void basic_istream<_CharT, _Traits>::_M_skip_whitespace(bool __set_failbit)
{
basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf();
if (!__buf)
this->setstate(ios_base::badbit);
else if (__buf->gptr() != __buf->egptr())
_M_ignore_buffered(this, __buf,
_Is_not_wspace<_Traits>((const ctype<_CharT>*)this->_M_ctype_facet()),
_Scan_for_not_wspace<_Traits>((const ctype<_CharT>*)this->_M_ctype_facet()),
false, __set_failbit);
else
_M_ignore_unbuffered(this, __buf,
_Is_not_wspace<_Traits>((const ctype<_CharT>*)this->_M_ctype_facet()),
false, __set_failbit);
}
template < class _CharT, class _Traits, class _Is_Delim>
streamsize
_M_copy_unbuffered( basic_istream<_CharT, _Traits>* __that, basic_streambuf<_CharT, _Traits>* __src,
basic_streambuf<_CharT, _Traits>* __dest,
_Is_Delim __is_delim,
bool __extract_delim, bool __rethrow)
{
streamsize __extracted = 0;
ios_base::iostate __status = 0;
typedef typename basic_istream<_CharT, _Traits>::int_type int_type;
int_type __c;
try {
while (true) {
__c = __src->sbumpc();
if (__that->_S_eof(__c)) {
__status |= ios_base::eofbit;
break;
}
else if (__is_delim(__c)) {
if (!__extract_delim && !__pushback(__src, _Traits::to_char_type(__c)))
__status |= ios_base::failbit;
break;
}
else {
bool __failed = false;
try {
if (!__that->_S_eof(__dest->sputc(__c)))
++__extracted;
else
__failed = true;
}
catch(...) {
__failed = true;
}
if (__failed && !__pushback(__src, _Traits::to_char_type(__c)))
__status |= ios_base::failbit;
if (__failed)
break;
}
}
}
catch(...) {
if (__rethrow && __extracted == 0)
__that->_M_handle_exception(ios_base::failbit);
}
__that->setstate(__status);
return __extracted;
}
template < class _CharT, class _Traits, class _Is_Delim, class _Scan_Delim>
streamsize
_M_copy_buffered(basic_istream<_CharT, _Traits>* __that, basic_streambuf<_CharT, _Traits>* __src,
basic_streambuf<_CharT, _Traits>* __dest,
_Scan_Delim __scan_delim, _Is_Delim __is_delim,
bool __extract_delim, bool __rethrow)
{
streamsize __extracted = 0;
ios_base::iostate __status = 0;
typedef typename basic_istream<_CharT, _Traits>::int_type int_type;
int_type __c = _Traits::eof();
_CharT* __first = __src->_M_gptr();
ptrdiff_t __avail = __src->_M_egptr() - __first;
bool __do_handle_exceptions;
try {
while (true) {
__do_handle_exceptions = false ;
const _CharT* __last = __scan_delim(__first, __src->_M_egptr());
streamsize __n = __dest->sputn(__first, __extract_delim && __last != __src->_M_egptr()
? (__last - __first) + 1
: (__last - __first));
__src->_M_gbump((int)__n);
__extracted += __n;
__do_handle_exceptions = true;
if (__n < __avail)
break;
__c = __src->sgetc();
__first = __src->_M_gptr();
__avail = __src->_M_egptr() - __first;
if (__avail > 0)
{}
else if (__that->_S_eof(__c)) {
__status |= ios_base::eofbit;
break;
}
else
return __extracted + _M_copy_unbuffered(__that, __src, __dest, __is_delim,
__extract_delim, __rethrow);
}
}
catch(...) {
if (__rethrow && __do_handle_exceptions && __extracted == 0)
__that->_M_handle_exception(ios_base::failbit);
}
if (__status)
__that->setstate(__status);
return __extracted;
}
template <class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>
::get(basic_streambuf<_CharT, _Traits>& __dest, _CharT __delim)
{
sentry __sentry(*this, _No_Skip_WS());
this->_M_gcount = 0;
if (__sentry) {
basic_streambuf<_CharT, _Traits>* __src = this->rdbuf();
if (__src)
this->_M_gcount = __src->egptr() != __src->gptr()
? _M_copy_buffered(this, __src, &__dest,
_Scan_for_char_val<_Traits>(__delim),
_Eq_char_bound<_Traits>(__delim),
false, false)
: _M_copy_unbuffered(this, __src, &__dest,
_Eq_char_bound<_Traits>(__delim),
false, false);
}
if (this->_M_gcount == 0)
this->setstate(ios_base::failbit);
return *this;
}
template <class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>
::operator>>(basic_streambuf<_CharT, _Traits>* __dest)
{
streamsize __n = 0;
typedef typename basic_istream<_CharT, _Traits>::sentry _Sentry;
_Sentry __sentry(*this);
if (__sentry) {
basic_streambuf<_CharT, _Traits>* __src = this->rdbuf();
if (__src && __dest)
__n = __src->egptr() != __src->gptr()
? _M_copy_buffered(this, __src, __dest,
_Project2nd<const _CharT*, const _CharT*>(),
_Constant_unary_fun<bool, int_type>(false),
false, true)
: _M_copy_unbuffered(this, __src, __dest,
_Constant_unary_fun<bool, int_type>(false),
false, true);
}
if (__n == 0)
this->setstate(ios_base::failbit);
return *this;
}
template <class _CharT, class _Traits>
basic_iostream<_CharT, _Traits>
::basic_iostream(basic_streambuf<_CharT, _Traits>* __buf)
: basic_ios<_CharT, _Traits>(),
basic_istream<_CharT, _Traits>(__buf),
basic_ostream<_CharT, _Traits>(__buf)
{
this->init(__buf);
}
template <class _CharT, class _Traits>
basic_iostream<_CharT, _Traits>::~basic_iostream()
{}
}
namespace _STL {
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::_Loc_init _LocInit;
static ios_base::Init _IosInit;
}
namespace _STL {}
namespace std {
using namespace _STL;
}
namespace _STL {}
namespace std {
using namespace _STL;
}
extern "C" {
extern void closelog (void) throw ();
extern void openlog (__const char *__ident, int __option, int __facility)
throw ();
extern int setlogmask (int __mask) throw ();
extern void syslog (int __pri, __const char *__fmt, ...) throw ()
__attribute__ ((__format__(__printf__, 2, 3)));
extern void vsyslog (int __pri, __const char *__fmt, __gnuc_va_list __ap)
throw () __attribute__ ((__format__(__printf__, 2, 0)));
}
namespace Logger
{
void warn(std::string const&);
void fatal(std::string const&);
void die(std::string const&)
__attribute__((noreturn));
void info(std::string const&);
void print(std::string const&);
void debug(std::string const&);
void syswarn(char const* file, int line);
void sysdie(char const* file, int line)
__attribute__((noreturn));
extern bool logDebug;
void useSyslog(bool);
void isServer(bool);
}
class Exit
{
private: int status_;
public: explicit Exit(int status = 0);
public: int status() const { return status_; }
};
namespace _STL {
template <class _Tp>
struct _Deque_iterator_base {
enum _Constants {
_blocksize = _MAX_BYTES,
__buffer_size = (sizeof(_Tp) < (size_t)_blocksize ?
( (size_t)_blocksize / sizeof(_Tp)) : size_t(1))
};
typedef random_access_iterator_tag iterator_category;
typedef _Tp value_type;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef value_type** _Map_pointer;
typedef _Deque_iterator_base< _Tp > _Self;
value_type* _M_cur;
value_type* _M_first;
value_type* _M_last;
_Map_pointer _M_node;
_Deque_iterator_base(value_type* __x, _Map_pointer __y)
: _M_cur(__x), _M_first(*__y),
_M_last(*__y + __buffer_size), _M_node(__y) {}
_Deque_iterator_base() : _M_cur(0), _M_first(0), _M_last(0), _M_node(0) {}
difference_type _M_subtract(const _Self& __x) const {
return difference_type(__buffer_size) * (_M_node - __x._M_node - 1) +
(_M_cur - _M_first) + (__x._M_last - __x._M_cur);
}
void _M_increment() {
if (++_M_cur == _M_last) {
_M_set_node(_M_node + 1);
_M_cur = _M_first;
}
}
void _M_decrement() {
if (_M_cur == _M_first) {
_M_set_node(_M_node - 1);
_M_cur = _M_last;
}
--_M_cur;
}
void _M_advance(difference_type __n)
{
difference_type __offset = __n + (_M_cur - _M_first);
if (__offset >= 0 && __offset < difference_type(__buffer_size))
_M_cur += __n;
else {
difference_type __node_offset =
__offset > 0 ? __offset / __buffer_size
: -difference_type((-__offset - 1) / __buffer_size) - 1;
_M_set_node(_M_node + __node_offset);
_M_cur = _M_first +
(__offset - __node_offset * difference_type(__buffer_size));
}
}
void _M_set_node(_Map_pointer __new_node) {
_M_last = (_M_first = *(_M_node = __new_node)) + difference_type(__buffer_size);
}
};
template <class _Tp, class _Traits>
struct _Deque_iterator : public _Deque_iterator_base< _Tp> {
typedef random_access_iterator_tag iterator_category;
typedef _Tp value_type;
typedef typename _Traits::reference reference;
typedef typename _Traits::pointer pointer;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef value_type** _Map_pointer;
typedef _Deque_iterator_base< _Tp > _Base;
typedef _Deque_iterator<_Tp, _Traits> _Self;
typedef _Deque_iterator<_Tp, _Nonconst_traits<_Tp> > _Nonconst_self;
typedef _Deque_iterator<_Tp, _Const_traits<_Tp> > _Const_self;
_Deque_iterator(value_type* __x, _Map_pointer __y) :
_Deque_iterator_base<value_type>(__x,__y) {}
_Deque_iterator() {}
_Deque_iterator(const _Nonconst_self& __x) :
_Deque_iterator_base<value_type>(__x) {}
reference operator*() const {
return *this->_M_cur;
}
pointer operator->() const { return &(operator*()); }
difference_type operator-(const _Self& __x) const { return this->_M_subtract(__x); }
_Self& operator++() { this->_M_increment(); return *this; }
_Self operator++(int) {
_Self __tmp = *this;
++*this;
return __tmp;
}
_Self& operator--() { this->_M_decrement(); return *this; }
_Self operator--(int) {
_Self __tmp = *this;
--*this;
return __tmp;
}
_Self& operator+=(difference_type __n) { this->_M_advance(__n); 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); }
};
template <class _Tp, class _Traits>
inline _Deque_iterator<_Tp, _Traits>
operator+(ptrdiff_t __n, const _Deque_iterator<_Tp, _Traits>& __x)
{
return __x + __n;
}
template <class _Tp>
inline bool
operator==(const _Deque_iterator_base<_Tp >& __x,
const _Deque_iterator_base<_Tp >& __y) {
return __x._M_cur == __y._M_cur;
}
template <class _Tp>
inline bool
operator < (const _Deque_iterator_base<_Tp >& __x,
const _Deque_iterator_base<_Tp >& __y) {
return (__x._M_node == __y._M_node) ?
(__x._M_cur < __y._M_cur) : (__x._M_node < __y._M_node);
}
template <class _Tp>
inline bool
operator!=(const _Deque_iterator_base<_Tp >& __x,
const _Deque_iterator_base<_Tp >& __y) {
return __x._M_cur != __y._M_cur;
}
template <class _Tp>
inline bool
operator>(const _Deque_iterator_base<_Tp >& __x,
const _Deque_iterator_base<_Tp >& __y) {
return __y < __x;
}
template <class _Tp>
inline bool operator>=(const _Deque_iterator_base<_Tp >& __x,
const _Deque_iterator_base<_Tp >& __y) {
return !(__x < __y);
}
template <class _Tp>
inline bool operator<=(const _Deque_iterator_base<_Tp >& __x,
const _Deque_iterator_base<_Tp >& __y) {
return !(__y < __x);
}
template <class _Tp, class _Alloc>
class _Deque_base {
public:
typedef _Tp value_type;
typedef typename _Alloc_traits<_Tp,_Alloc>::allocator_type allocator_type;
typedef typename _Alloc_traits<_Tp*, _Alloc>::allocator_type _Map_alloc_type;
typedef _Deque_iterator<_Tp, _Nonconst_traits<_Tp> > iterator;
typedef _Deque_iterator<_Tp, _Const_traits<_Tp> > const_iterator;
static size_t buffer_size() { return (size_t)_Deque_iterator_base<_Tp>::__buffer_size; }
_Deque_base(const allocator_type& __a, size_t __num_elements)
: _M_start(), _M_finish(), _M_map(__a, 0),
_M_map_size(__a, (size_t)0) {
_M_initialize_map(__num_elements);
}
_Deque_base(const allocator_type& __a)
: _M_start(), _M_finish(), _M_map(__a, 0),
_M_map_size(__a, (size_t)0) {
}
~_Deque_base();
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 };
protected:
iterator _M_start;
iterator _M_finish;
_STLP_alloc_proxy<value_type**, value_type*, _Map_alloc_type> _M_map;
_STLP_alloc_proxy<size_t, value_type, allocator_type> _M_map_size;
};
template <class _Tp, class _Alloc = allocator< _Tp > >
class deque : protected _Deque_base<_Tp, _Alloc> {
typedef _Deque_base<_Tp, _Alloc> _Base;
typedef deque<_Tp, _Alloc> _Self;
public:
typedef _Tp value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef random_access_iterator_tag _Iterator_category;
typedef typename _Base::allocator_type allocator_type;
public:
typedef typename _Base::iterator iterator;
typedef typename _Base::const_iterator const_iterator;
typedef _STL::reverse_iterator<const_iterator> const_reverse_iterator; typedef _STL::reverse_iterator<iterator> reverse_iterator;
protected:
typedef pointer* _Map_pointer;
typedef typename __type_traits<_Tp>::has_trivial_assignment_operator _TrivialAss;
typedef typename __type_traits<_Tp>::has_trivial_assignment_operator _IsPODType;
public:
iterator begin() { return this->_M_start; }
iterator end() { return this->_M_finish; }
const_iterator begin() const { return const_iterator(this->_M_start); }
const_iterator end() const { return const_iterator(this->_M_finish); }
reverse_iterator rbegin() { return reverse_iterator(this->_M_finish); }
reverse_iterator rend() { return reverse_iterator(this->_M_start); }
const_reverse_iterator rbegin() const
{ return const_reverse_iterator(this->_M_finish); }
const_reverse_iterator rend() const
{ return const_reverse_iterator(this->_M_start); }
reference operator[](size_type __n)
{ return this->_M_start[difference_type(__n)]; }
const_reference operator[](size_type __n) const
{ return this->_M_start[difference_type(__n)]; }
void _M_range_check(size_type __n) const {
if (__n >= this->size())
__stl_throw_out_of_range("deque");
}
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 *this->_M_start; }
reference back() {
iterator __tmp = this->_M_finish;
--__tmp;
return *__tmp;
}
const_reference front() const { return *this->_M_start; }
const_reference back() const {
const_iterator __tmp = this->_M_finish;
--__tmp;
return *__tmp;
}
size_type size() const { return this->_M_finish - this->_M_start; }
size_type max_size() const { return size_type(-1); }
bool empty() const { return this->_M_finish == this->_M_start; }
allocator_type get_allocator() const { return this->_M_map_size; }
public:
explicit deque(const allocator_type& __a = allocator_type())
: _Deque_base<_Tp, _Alloc>(__a, 0) {}
deque(const _Self& __x) :
_Deque_base<_Tp, _Alloc>(__x.get_allocator(), __x.size()) {
__uninitialized_copy(__x.begin(), __x.end(), this->_M_start, _IsPODType());
}
deque(size_type __n, const value_type& __val,
const allocator_type& __a = allocator_type()) :
_Deque_base<_Tp, _Alloc>(__a, __n)
{ _M_fill_initialize(__val); }
explicit deque(size_type __n) : _Deque_base<_Tp, _Alloc>(allocator_type(), __n)
{ _M_fill_initialize(value_type()); }
template <class _Integer>
void _M_initialize_dispatch(_Integer __n, _Integer __x, const __true_type&) {
this->_M_initialize_map(__n);
_M_fill_initialize(__x);
}
template <class _InputIter>
void _M_initialize_dispatch(_InputIter __first, _InputIter __last,
const __false_type&) {
_M_range_initialize(__first, __last, typename iterator_traits< _InputIter >::iterator_category());
}
template <class _InputIterator>
deque(_InputIterator __first, _InputIterator __last,
const allocator_type& __a = allocator_type()) :
_Deque_base<_Tp, _Alloc>(__a) {
typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
_M_initialize_dispatch(__first, __last, _Integral());
}
~deque() {
_Destroy(this->_M_start, this->_M_finish);
}
_Self& operator= (const _Self& __x);
void swap(_Self& __x) {
_STL::swap(this->_M_start, __x._M_start);
_STL::swap(this->_M_finish, __x._M_finish);
_STL::swap(this->_M_map, __x._M_map);
_STL::swap(this->_M_map_size, __x._M_map_size);
}
public:
void _M_fill_assign(size_type __n, const _Tp& __val) {
if (__n > size()) {
_STL::fill(begin(), end(), __val);
insert(end(), __n - size(), __val);
}
else {
erase(begin() + __n, end());
_STL::fill(begin(), end(), __val);
}
}
void assign(size_type __n, const _Tp& __val) {
_M_fill_assign(__n, __val);
}
template <class _InputIterator>
void assign(_InputIterator __first, _InputIterator __last) {
typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
_M_assign_dispatch(__first, __last, _Integral());
}
private:
template <class _Integer>
void _M_assign_dispatch(_Integer __n, _Integer __val, const __true_type&)
{ _M_fill_assign((size_type) __n, (_Tp) __val); }
template <class _InputIterator>
void _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
const __false_type&) {
_M_assign_aux(__first, __last, typename iterator_traits< _InputIterator >::iterator_category());
}
template <class _InputIter>
void _M_assign_aux(_InputIter __first, _InputIter __last, const input_iterator_tag &) {
iterator __cur = begin();
for ( ; __first != __last && __cur != end(); ++__cur, ++__first)
*__cur = *__first;
if (__first == __last)
erase(__cur, end());
else
insert(end(), __first, __last);
}
template <class _ForwardIterator>
void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
const forward_iterator_tag &) {
size_type __len = distance(__first, __last);
if (__len > size()) {
_ForwardIterator __mid = __first;
advance(__mid, size());
copy(__first, __mid, begin());
insert(end(), __mid, __last);
}
else
erase(copy(__first, __last, begin()), end());
}
public:
void push_back(const value_type& __t) {
if (this->_M_finish._M_cur != this->_M_finish._M_last - 1) {
_Construct(this->_M_finish._M_cur, __t);
++this->_M_finish._M_cur;
}
else
_M_push_back_aux_v(__t);
}
void push_front(const value_type& __t) {
if (this->_M_start._M_cur != this->_M_start._M_first) {
_Construct(this->_M_start._M_cur - 1, __t);
--this->_M_start._M_cur;
}
else
_M_push_front_aux_v(__t);
}
void push_back() {
if (this->_M_finish._M_cur != this->_M_finish._M_last - 1) {
_Construct(this->_M_finish._M_cur);
++this->_M_finish._M_cur;
}
else
_M_push_back_aux();
}
void push_front() {
if (this->_M_start._M_cur != this->_M_start._M_first) {
_Construct(this->_M_start._M_cur - 1);
--this->_M_start._M_cur;
}
else
_M_push_front_aux();
}
void pop_back() {
if (this->_M_finish._M_cur != this->_M_finish._M_first) {
--this->_M_finish._M_cur;
_Destroy(this->_M_finish._M_cur);
}
else
_M_pop_back_aux();
}
void pop_front() {
if (this->_M_start._M_cur != this->_M_start._M_last - 1) {
_Destroy(this->_M_start._M_cur);
++this->_M_start._M_cur;
}
else
_M_pop_front_aux();
}
public:
iterator insert(iterator __position, const value_type& __x) {
if (__position._M_cur == this->_M_start._M_cur) {
push_front(__x);
return this->_M_start;
}
else if (__position._M_cur == this->_M_finish._M_cur) {
push_back(__x);
iterator __tmp = this->_M_finish;
--__tmp;
return __tmp;
}
else {
return _M_insert_aux(__position, __x);
}
}
iterator insert(iterator __position)
{ return insert(__position, value_type()); }
void insert(iterator __pos, size_type __n, const value_type& __x) {
_M_fill_insert(__pos, __n, __x);
}
void _M_fill_insert(iterator __pos, size_type __n, const value_type& __x);
template <class _InputIterator>
void insert(iterator __pos, _InputIterator __first, _InputIterator __last) {
typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
_M_insert_dispatch(__pos, __first, __last, _Integral());
}
template <class _Integer>
void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x,
const __true_type&) {
_M_fill_insert(__pos, (size_type) __n, (value_type) __x);
}
template <class _InputIterator>
void _M_insert_dispatch(iterator __pos,
_InputIterator __first, _InputIterator __last,
const __false_type&) {
insert(__pos, __first, __last, typename iterator_traits< _InputIterator >::iterator_category());
}
void resize(size_type __new_size, const value_type& __x) {
const size_type __len = size();
if (__new_size < __len)
erase(this->_M_start + __new_size, this->_M_finish);
else
insert(this->_M_finish, __new_size - __len, __x);
}
void resize(size_type new_size) { resize(new_size, value_type()); }
public:
iterator erase(iterator __pos) {
iterator __next = __pos;
++__next;
difference_type __index = __pos - this->_M_start;
if (size_type(__index) < this->size() >> 1) {
copy_backward(this->_M_start, __pos, __next);
pop_front();
}
else {
copy(__next, this->_M_finish, __pos);
pop_back();
}
return this->_M_start + __index;
}
iterator erase(iterator __first, iterator __last);
void clear();
protected:
void _M_fill_initialize(const value_type& __val);
template <class _InputIterator>
void _M_range_initialize(_InputIterator __first,
_InputIterator __last,
const input_iterator_tag &) {
this->_M_initialize_map(0);
try {
for ( ; __first != __last; ++__first)
push_back(*__first);
}
catch(...) { clear(); throw; };
}
template <class _ForwardIterator>
void _M_range_initialize(_ForwardIterator __first,
_ForwardIterator __last,
const forward_iterator_tag &) {
size_type __n = distance(__first, __last);
this->_M_initialize_map(__n);
_Map_pointer __cur_node;
try {
for (__cur_node = this->_M_start._M_node;
__cur_node < this->_M_finish._M_node;
++__cur_node) {
_ForwardIterator __mid = __first;
advance(__mid, this->buffer_size());
uninitialized_copy(__first, __mid, *__cur_node);
__first = __mid;
}
uninitialized_copy(__first, __last, this->_M_finish._M_first);
}
catch(...) { _Destroy(this->_M_start, iterator(*__cur_node, __cur_node)); throw; };
}
protected:
void _M_push_back_aux_v(const value_type&);
void _M_push_front_aux_v(const value_type&);
void _M_push_back_aux();
void _M_push_front_aux();
void _M_pop_back_aux();
void _M_pop_front_aux();
protected:
template <class _InputIterator>
void
insert(iterator __pos,
_InputIterator __first,
_InputIterator __last,
const input_iterator_tag &)
{
copy(__first, __last, inserter(*this, __pos));
}
template <class _ForwardIterator>
void insert(iterator __pos,
_ForwardIterator __first,
_ForwardIterator __last,
const forward_iterator_tag &)
{
size_type __n = distance(__first, __last);
if (__pos._M_cur == this->_M_start._M_cur) {
iterator __new_start = _M_reserve_elements_at_front(__n);
try {
uninitialized_copy(__first, __last, __new_start);
this->_M_start = __new_start;
}
catch(...) { this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node); throw; };
}
else if (__pos._M_cur == this->_M_finish._M_cur) {
iterator __new_finish = _M_reserve_elements_at_back(__n);
try {
uninitialized_copy(__first, __last, this->_M_finish);
this->_M_finish = __new_finish;
}
catch(...) { this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1); throw; };
}
else
_M_insert_aux(__pos, __first, __last, __n);
}
iterator _M_insert_aux(iterator __pos, const value_type& __x);
iterator _M_insert_aux(iterator __pos);
iterator _M_insert_aux_prepare(iterator __pos);
void _M_insert_aux(iterator __pos, size_type __n, const value_type& __x);
template <class _ForwardIterator>
void _M_insert_aux(iterator __pos,
_ForwardIterator __first,
_ForwardIterator __last,
size_type __n) {
const difference_type __elemsbefore = __pos - this->_M_start;
size_type __length = size();
if (__elemsbefore < difference_type(__length / 2)) {
iterator __new_start = _M_reserve_elements_at_front(__n);
iterator __old_start = this->_M_start;
__pos = this->_M_start + __elemsbefore;
try {
if (__elemsbefore >= difference_type(__n)) {
iterator __start_n = this->_M_start + difference_type(__n);
uninitialized_copy(this->_M_start, __start_n, __new_start);
this->_M_start = __new_start;
copy(__start_n, __pos, __old_start);
copy(__first, __last, __pos - difference_type(__n));
}
else {
_ForwardIterator __mid = __first;
advance(__mid, difference_type(__n) - __elemsbefore);
__uninitialized_copy_copy(this->_M_start, __pos, __first, __mid,
__new_start, _IsPODType());
this->_M_start = __new_start;
copy(__mid, __last, __old_start);
}
}
catch(...) { this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node); throw; };
}
else {
iterator __new_finish = _M_reserve_elements_at_back(__n);
iterator __old_finish = this->_M_finish;
const difference_type __elemsafter =
difference_type(__length) - __elemsbefore;
__pos = this->_M_finish - __elemsafter;
try {
if (__elemsafter > difference_type(__n)) {
iterator __finish_n = this->_M_finish - difference_type(__n);
uninitialized_copy(__finish_n, this->_M_finish, this->_M_finish);
this->_M_finish = __new_finish;
copy_backward(__pos, __finish_n, __old_finish);
copy(__first, __last, __pos);
}
else {
_ForwardIterator __mid = __first;
advance(__mid, __elemsafter);
__uninitialized_copy_copy(__mid, __last, __pos, this->_M_finish, this->_M_finish, _IsPODType());
this->_M_finish = __new_finish;
copy(__first, __mid, __pos);
}
}
catch(...) { this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1); throw; };
}
}
iterator _M_reserve_elements_at_front(size_type __n) {
size_type __vacancies = this->_M_start._M_cur - this->_M_start._M_first;
if (__n > __vacancies)
_M_new_elements_at_front(__n - __vacancies);
return this->_M_start - difference_type(__n);
}
iterator _M_reserve_elements_at_back(size_type __n) {
size_type __vacancies = (this->_M_finish._M_last - this->_M_finish._M_cur) - 1;
if (__n > __vacancies)
_M_new_elements_at_back(__n - __vacancies);
return this->_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);
protected:
void _M_reserve_map_at_back (size_type __nodes_to_add = 1) {
if (__nodes_to_add + 1 > this->_M_map_size._M_data - (this->_M_finish._M_node - this->_M_map._M_data))
_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_start._M_node - this->_M_map._M_data))
_M_reallocate_map(__nodes_to_add, true);
}
void _M_reallocate_map(size_type __nodes_to_add, bool __add_at_front);
};
template <class _Tp, class _Alloc >
inline bool operator==(const deque<_Tp, _Alloc>& __x,
const deque<_Tp, _Alloc>& __y)
{
return __x.size() == __y.size() &&
equal(__x.begin(), __x.end(), __y.begin());
}
template <class _Tp, class _Alloc >
inline bool operator<(const deque<_Tp, _Alloc>& __x,
const deque<_Tp, _Alloc>& __y)
{
return lexicographical_compare(__x.begin(), __x.end(),
__y.begin(), __y.end());
}
template <class _Tp, class _Alloc >
inline bool operator!=(const deque<_Tp, _Alloc>& __x,
const deque<_Tp, _Alloc>& __y)
{
return !(__x == __y);
}
template <class _Tp, class _Alloc >
inline bool operator>(const deque<_Tp, _Alloc>& __x,
const deque<_Tp, _Alloc>& __y)
{
return __y < __x;
}
template <class _Tp, class _Alloc >
inline bool operator>=(const deque<_Tp, _Alloc>& __x,
const deque<_Tp, _Alloc>& __y)
{
return !(__x < __y);
}
template <class _Tp, class _Alloc >
inline bool operator<=(const deque<_Tp, _Alloc>& __x,
const deque<_Tp, _Alloc>& __y)
{
return !(__y < __x);
}
template <class _Tp, class _Alloc>
inline void
swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y)
{
__x.swap(__y);
}
}
namespace _STL {
template <class _Tp, class _Alloc >
_Deque_base<_Tp,_Alloc >::~_Deque_base() {
if (_M_map._M_data) {
_M_destroy_nodes(_M_start._M_node, this->_M_finish._M_node + 1);
_M_map.deallocate(_M_map._M_data, _M_map_size._M_data);
}
}
template <class _Tp, class _Alloc >
void
_Deque_base<_Tp,_Alloc>::_M_initialize_map(size_t __num_elements)
{
size_t __num_nodes =
__num_elements / this->buffer_size() + 1 ;
_M_map_size._M_data = (max)((size_t) _S_initial_map_size, __num_nodes + 2);
_M_map._M_data = _M_map.allocate(_M_map_size._M_data);
_Tp** __nstart = _M_map._M_data + (_M_map_size._M_data - __num_nodes) / 2;
_Tp** __nfinish = __nstart + __num_nodes;
try {
_M_create_nodes(__nstart, __nfinish);
}
catch(...) { (_M_map.deallocate(_M_map._M_data, _M_map_size._M_data), _M_map._M_data = 0, _M_map_size._M_data = 0); throw; };
_M_start._M_set_node(__nstart);
this->_M_finish._M_set_node(__nfinish - 1);
_M_start._M_cur = _M_start._M_first;
this->_M_finish._M_cur = this->_M_finish._M_first +
__num_elements % this->buffer_size();
}
template <class _Tp, class _Alloc >
void
_Deque_base<_Tp,_Alloc>::_M_create_nodes(_Tp** __nstart,
_Tp** __nfinish)
{
_Tp** __cur;
try {
for (__cur = __nstart; __cur < __nfinish; ++__cur)
*__cur = _M_map_size.allocate(this->buffer_size());
}
catch(...) { _M_destroy_nodes(__nstart, __cur); throw; };
}
template <class _Tp, class _Alloc >
void
_Deque_base<_Tp,_Alloc>::_M_destroy_nodes(_Tp** __nstart,
_Tp** __nfinish)
{
for (_Tp** __n = __nstart; __n < __nfinish; ++__n)
_M_map_size.deallocate(*__n, this->buffer_size());
}
template <class _Tp, class _Alloc >
deque<_Tp, _Alloc >&
deque<_Tp, _Alloc >::operator= (const deque<_Tp, _Alloc >& __x) {
const size_type __len = size();
if (&__x != this) {
if (__len >= __x.size())
erase(copy(__x.begin(), __x.end(), this->_M_start), this->_M_finish);
else {
const_iterator __mid = __x.begin() + difference_type(__len);
copy(__x.begin(), __mid, this->_M_start);
insert(this->_M_finish, __mid, __x.end());
}
}
return *this;
}
template <class _Tp, class _Alloc >
void
deque<_Tp, _Alloc >::_M_fill_insert(iterator __pos,
size_type __n, const value_type& __x)
{
if (__pos._M_cur == this->_M_start._M_cur) {
iterator __new_start = _M_reserve_elements_at_front(__n);
try {
uninitialized_fill(__new_start, this->_M_start, __x);
}
catch(...) { this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node); throw; };
this->_M_start = __new_start;
}
else if (__pos._M_cur == this->_M_finish._M_cur) {
iterator __new_finish = _M_reserve_elements_at_back(__n);
try {
uninitialized_fill(this->_M_finish, __new_finish, __x);
}
catch(...) { this->_M_destroy_nodes(this->_M_finish._M_node+1, __new_finish._M_node+1); throw; };
this->_M_finish = __new_finish;
}
else
_M_insert_aux(__pos, __n, __x);
}
template <class _Tp, class _Alloc >
typename deque<_Tp, _Alloc>::iterator
deque<_Tp,_Alloc>::erase(iterator __first, iterator __last)
{
if (__first == this->_M_start && __last == this->_M_finish) {
clear();
return this->_M_finish;
}
else {
difference_type __n = __last - __first;
difference_type __elems_before = __first - this->_M_start;
if (__elems_before < difference_type(this->size() - __n) / 2) {
copy_backward(this->_M_start, __first, __last);
iterator __new_start = this->_M_start + __n;
_Destroy(this->_M_start, __new_start);
this->_M_destroy_nodes(this->_M_start._M_node, __new_start._M_node);
this->_M_start = __new_start;
}
else {
copy(__last, this->_M_finish, __first);
iterator __new_finish = this->_M_finish - __n;
_Destroy(__new_finish, this->_M_finish);
this->_M_destroy_nodes(__new_finish._M_node + 1, this->_M_finish._M_node + 1);
this->_M_finish = __new_finish;
}
return this->_M_start + __elems_before;
}
}
template <class _Tp, class _Alloc >
void deque<_Tp,_Alloc>::clear()
{
for (_Map_pointer __node = this->_M_start._M_node + 1;
__node < this->_M_finish._M_node;
++__node) {
_Destroy(*__node, *__node + this->buffer_size());
this->_M_map_size.deallocate(*__node, this->buffer_size());
}
if (this->_M_start._M_node != this->_M_finish._M_node) {
_Destroy(this->_M_start._M_cur, this->_M_start._M_last);
_Destroy(this->_M_finish._M_first, this->_M_finish._M_cur);
this->_M_map_size.deallocate(this->_M_finish._M_first, this->buffer_size());
}
else
_Destroy(this->_M_start._M_cur, this->_M_finish._M_cur);
this->_M_finish = this->_M_start;
}
template <class _Tp, class _Alloc >
void
deque<_Tp,_Alloc>::_M_fill_initialize(const value_type& __val) {
_Map_pointer __cur;
try {
for (__cur = this->_M_start._M_node; __cur < this->_M_finish._M_node; ++__cur)
uninitialized_fill(*__cur, *__cur + this->buffer_size(), __val);
uninitialized_fill(this->_M_finish._M_first, this->_M_finish._M_cur, __val);
}
catch(...) { _Destroy(this->_M_start, iterator(*__cur, __cur)); throw; };
}
template <class _Tp, class _Alloc >
void
deque<_Tp,_Alloc>::_M_push_back_aux_v(const value_type& __t)
{
value_type __t_copy = __t;
_M_reserve_map_at_back();
*(this->_M_finish._M_node + 1) = this->_M_map_size.allocate(this->buffer_size());
try {
_Construct(this->_M_finish._M_cur, __t_copy);
this->_M_finish._M_set_node(this->_M_finish._M_node + 1);
this->_M_finish._M_cur = this->_M_finish._M_first;
}
catch(...) { this->_M_map_size.deallocate(*(this->_M_finish._M_node + 1), this->buffer_size()); throw; };
}
template <class _Tp, class _Alloc >
void
deque<_Tp,_Alloc>::_M_push_back_aux()
{
_M_reserve_map_at_back();
*(this->_M_finish._M_node + 1) = this->_M_map_size.allocate(this->buffer_size());
try {
_Construct(this->_M_finish._M_cur);
this->_M_finish._M_set_node(this->_M_finish._M_node + 1);
this->_M_finish._M_cur = this->_M_finish._M_first;
}
catch(...) { this->_M_map_size.deallocate(*(this->_M_finish._M_node + 1), this->buffer_size()); throw; };
}
template <class _Tp, class _Alloc >
void
deque<_Tp,_Alloc>::_M_push_front_aux_v(const value_type& __t)
{
value_type __t_copy = __t;
_M_reserve_map_at_front();
*(this->_M_start._M_node - 1) = this->_M_map_size.allocate(this->buffer_size());
try {
this->_M_start._M_set_node(this->_M_start._M_node - 1);
this->_M_start._M_cur = this->_M_start._M_last - 1;
_Construct(this->_M_start._M_cur, __t_copy);
}
catch(...) { (++this->_M_start, this->_M_map_size.deallocate(*(this->_M_start._M_node - 1), this->buffer_size())); throw; };
}
template <class _Tp, class _Alloc >
void
deque<_Tp,_Alloc>::_M_push_front_aux()
{
_M_reserve_map_at_front();
*(this->_M_start._M_node - 1) = this->_M_map_size.allocate(this->buffer_size());
try {
this->_M_start._M_set_node(this->_M_start._M_node - 1);
this->_M_start._M_cur = this->_M_start._M_last - 1;
_Construct(this->_M_start._M_cur);
}
catch(...) { (++this->_M_start, this->_M_map_size.deallocate(*(this->_M_start._M_node - 1), this->buffer_size() )); throw; };
}
template <class _Tp, class _Alloc >
void
deque<_Tp,_Alloc>::_M_pop_back_aux()
{
this->_M_map_size.deallocate(this->_M_finish._M_first, this->buffer_size());
this->_M_finish._M_set_node(this->_M_finish._M_node - 1);
this->_M_finish._M_cur = this->_M_finish._M_last - 1;
_Destroy(this->_M_finish._M_cur);
}
template <class _Tp, class _Alloc >
void
deque<_Tp,_Alloc>::_M_pop_front_aux()
{
_Destroy(this->_M_start._M_cur);
this->_M_map_size.deallocate(this->_M_start._M_first, this->buffer_size());
this->_M_start._M_set_node(this->_M_start._M_node + 1);
this->_M_start._M_cur = this->_M_start._M_first;
}
template <class _Tp, class _Alloc >
typename deque<_Tp, _Alloc>::iterator
deque<_Tp,_Alloc>::_M_insert_aux_prepare(iterator __pos) {
difference_type __index = __pos - this->_M_start;
if (__index < difference_type(size() / 2)) {
push_front(front());
iterator __front1 = this->_M_start;
++__front1;
iterator __front2 = __front1;
++__front2;
__pos = this->_M_start + __index;
iterator __pos1 = __pos;
++__pos1;
copy(__front2, __pos1, __front1);
}
else {
push_back(back());
iterator __back1 = this->_M_finish;
--__back1;
iterator __back2 = __back1;
--__back2;
__pos = this->_M_start + __index;
copy_backward(__pos, __back2, __back1);
}
return __pos;
}
template <class _Tp, class _Alloc >
typename deque<_Tp, _Alloc>::iterator
deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos,
const value_type& __x) {
value_type __x_copy = __x;
__pos = _M_insert_aux_prepare(__pos);
*__pos = __x_copy;
return __pos;
}
template <class _Tp, class _Alloc >
typename deque<_Tp, _Alloc>::iterator
deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos)
{
__pos = _M_insert_aux_prepare(__pos);
*__pos = value_type();
return __pos;
}
template <class _Tp, class _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_start;
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_start;
__pos = this->_M_start + __elems_before;
try {
if (__elems_before >= difference_type(__n)) {
iterator __start_n = this->_M_start + difference_type(__n);
uninitialized_copy(this->_M_start, __start_n, __new_start);
this->_M_start = __new_start;
copy(__start_n, __pos, __old_start);
fill(__pos - difference_type(__n), __pos, __x_copy);
}
else {
__uninitialized_copy_fill(this->_M_start, __pos, __new_start,
this->_M_start, __x_copy);
this->_M_start = __new_start;
fill(__old_start, __pos, __x_copy);
}
}
catch(...) { this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node); throw; };
}
else {
iterator __new_finish = _M_reserve_elements_at_back(__n);
iterator __old_finish = this->_M_finish;
const difference_type __elems_after =
difference_type(__length) - __elems_before;
__pos = this->_M_finish - __elems_after;
try {
if (__elems_after > difference_type(__n)) {
iterator __finish_n = this->_M_finish - difference_type(__n);
uninitialized_copy(__finish_n, this->_M_finish, this->_M_finish);
this->_M_finish = __new_finish;
copy_backward(__pos, __finish_n, __old_finish);
fill(__pos, __pos + difference_type(__n), __x_copy);
}
else {
__uninitialized_fill_copy(this->_M_finish, __pos + difference_type(__n),
__x_copy, __pos, this->_M_finish);
this->_M_finish = __new_finish;
fill(__pos, __old_finish, __x_copy);
}
}
catch(...) { this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1); throw; };
}
}
template <class _Tp, class _Alloc >
void
deque<_Tp,_Alloc>::_M_new_elements_at_front(size_type __new_elems)
{
size_type __new_nodes
= (__new_elems + this->buffer_size() - 1) / this->buffer_size();
_M_reserve_map_at_front(__new_nodes);
size_type __i =1;
try {
for (; __i <= __new_nodes; ++__i)
*(this->_M_start._M_node - __i) = this->_M_map_size.allocate(this->buffer_size());
}
catch(...) {
for (size_type __j = 1; __j < __i; ++__j)
this->_M_map_size.deallocate(*(this->_M_start._M_node - __j), this->buffer_size());
throw;
}
}
template <class _Tp, class _Alloc >
void
deque<_Tp,_Alloc>::_M_new_elements_at_back(size_type __new_elems)
{
size_type __new_nodes
= (__new_elems + this->buffer_size() - 1) / this->buffer_size();
_M_reserve_map_at_back(__new_nodes);
size_type __i = 1;
try {
for (; __i <= __new_nodes; ++__i)
*(this->_M_finish._M_node + __i) = this->_M_map_size.allocate(this->buffer_size());
}
catch(...) {
for (size_type __j = 1; __j < __i; ++__j)
this->_M_map_size.deallocate(*(this->_M_finish._M_node + __j), this->buffer_size());
throw;
}
}
template <class _Tp, class _Alloc >
void
deque<_Tp,_Alloc>::_M_reallocate_map(size_type __nodes_to_add,
bool __add_at_front)
{
size_type __old_num_nodes = this->_M_finish._M_node - this->_M_start._M_node + 1;
size_type __new_num_nodes = __old_num_nodes + __nodes_to_add;
_Map_pointer __new_nstart;
if (this->_M_map_size._M_data > 2 * __new_num_nodes) {
__new_nstart = this->_M_map._M_data + (this->_M_map_size._M_data - __new_num_nodes) / 2
+ (__add_at_front ? __nodes_to_add : 0);
if (__new_nstart < this->_M_start._M_node)
copy(this->_M_start._M_node, this->_M_finish._M_node + 1, __new_nstart);
else
copy_backward(this->_M_start._M_node, this->_M_finish._M_node + 1,
__new_nstart + __old_num_nodes);
}
else {
size_type __new_map_size =
this->_M_map_size._M_data + (max)((size_t)this->_M_map_size._M_data, __nodes_to_add) + 2;
_Map_pointer __new_map = this->_M_map.allocate(__new_map_size);
__new_nstart = __new_map + (__new_map_size - __new_num_nodes) / 2
+ (__add_at_front ? __nodes_to_add : 0);
copy(this->_M_start._M_node, this->_M_finish._M_node + 1, __new_nstart);
this->_M_map.deallocate(this->_M_map._M_data, this->_M_map_size._M_data);
this->_M_map._M_data = __new_map;
this->_M_map_size._M_data = __new_map_size;
}
this->_M_start._M_set_node(__new_nstart);
this->_M_finish._M_set_node(__new_nstart + __old_num_nodes - 1);
}
}
namespace _STL {}
namespace std {
using namespace _STL;
}
typedef std::deque<std::string> Argv;
void Main(Argv&);
bool flagPresent(Argv& argv, const std::string& flag);
extern const char* originalProgramName;
extern const char* programName;
std::string SysErr();
std::string Str(bool);
std::string Str(char);
std::string Str(unsigned char);
std::string Str(signed char);
std::string Str(short);
std::string Str(unsigned short);
std::string Str(int);
std::string Str(unsigned);
std::string Str(long);
std::string Str(unsigned long);
std::string Str(long long);
std::string Str(unsigned long long);
std::string Str(const char*);
std::string Str(const std::string&);
std::string Hex(char, int minDigits = 1);
std::string Hex(unsigned char, int minDigits = 1);
std::string Hex(signed char, int minDigits = 1);
std::string Hex(short, int minDigits = 1);
std::string Hex(unsigned short, int minDigits = 1);
std::string Hex(int, int minDigits = 1);
std::string Hex(unsigned, int minDigits = 1);
std::string Hex(long, int minDigits = 1);
std::string Hex(unsigned long, int minDigits = 1);
std::string Hex(long long, int minDigits = 1);
std::string Hex(unsigned long long, int minDigits = 1);
std::string Hex(void*, int minDigits = 1);
std::string Dec(char, int minDigits = 1);
std::string Dec(unsigned char, int minDigits = 1);
std::string Dec(signed char, int minDigits = 1);
std::string Dec(short, int minDigits = 1);
std::string Dec(unsigned short, int minDigits = 1);
std::string Dec(int, int minDigits = 1);
std::string Dec(unsigned, int minDigits = 1);
std::string Dec(long, int minDigits = 1);
std::string Dec(unsigned long, int minDigits = 1);
std::string Dec(long long, int minDigits = 1);
std::string Dec(unsigned long long, int minDigits = 1);
std::string GetEnv(const std::string& name, const std::string& def = "");
bool GetEnvBool(const std::string& name, bool def = false);
std::string StateDir(const std::string& subdir = "");
using std::string;
using std::clog;
using std::cout;
using std::endl;
static bool gUseSyslog = GetEnvBool("OSWALD_USESYSLOG", true);
static bool gIsServer = false;
static inline void syslog(int level, string const& message)
{
if (gUseSyslog)
syslog((17<<3) | level, "%s", const_cast<char*>(message.c_str()));
}
namespace Logger
{
bool logDebug = GetEnvBool("OSWALD_DEBUG", false);
void isServer(bool v)
{
gIsServer = v;
}
void useSyslog(bool v)
{
gUseSyslog = v;
}
void warn(string const& message)
{
syslog(4, message);
if (!gUseSyslog || !gIsServer)
clog << programName << ": " << message << endl;
}
void fatal(string const& message)
{
syslog(2, message);
if (!gUseSyslog || !gIsServer)
clog << programName << ": " << message << endl;
}
void die(string const& message)
{
fatal(message);
throw Exit(1);
}
void info(string const& message)
{
syslog(6, message);
if (!gUseSyslog)
cout << message << endl;
}
void print(string const& message)
{
syslog(6, message);
if (!gUseSyslog || !gIsServer)
cout << message << endl;
}
void debug(string const& message)
{
syslog(7, message);
if (!gUseSyslog)
cout << "DEBUG: " << message << endl;
}
void syswarn(char const* file, int line)
{
warn(SysErr() + " at file \"" + file + "\", line " + Dec(line));
}
void sysdie(char const* file, int line)
{
die(SysErr() + " at file \"" + file + "\", line " + Dec(line));
}
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-02-22 2:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-22 2:36 c++/9798: g++: Internal error: Segmentation fault (program cc1plus) michael
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).